From 28345d35b6dc2e0931292ca8c82cd39b5a5fb90d Mon Sep 17 00:00:00 2001 From: Howard Su Date: Tue, 5 Dec 2023 13:03:47 +0800 Subject: [PATCH 01/54] move PSP UI to top level --- Source/{SysPSP => }/UI/AboutComponent.cpp | 0 Source/{SysPSP => }/UI/AboutComponent.h | 0 Source/{SysPSP => }/UI/AdjustDeadzoneScreen.cpp | 0 Source/{SysPSP => }/UI/AdjustDeadzoneScreen.h | 0 Source/{SysPSP => }/UI/AdvancedOptionsScreen.cpp | 0 Source/{SysPSP => }/UI/AdvancedOptionsScreen.h | 0 Source/{SysPSP => }/UI/CMakeLists.txt | 0 Source/{SysPSP => }/UI/CheatOptionsScreen.cpp | 0 Source/{SysPSP => }/UI/CheatOptionsScreen.h | 0 Source/{SysPSP => }/UI/ColourPulser.cpp | 0 Source/{SysPSP => }/UI/ColourPulser.h | 0 Source/{SysPSP => }/UI/Dialogs.cpp | 0 Source/{SysPSP => }/UI/Dialogs.h | 0 Source/{SysPSP => }/UI/GlobalSettingsComponent.cpp | 0 Source/{SysPSP => }/UI/GlobalSettingsComponent.h | 0 Source/{SysPSP => }/UI/MainMenuScreen.cpp | 0 Source/{SysPSP => }/UI/MainMenuScreen.h | 0 Source/{SysPSP => }/UI/PSPMenu.h | 0 Source/{SysPSP => }/UI/PauseOptionsComponent.cpp | 0 Source/{SysPSP => }/UI/PauseOptionsComponent.h | 0 Source/{SysPSP => }/UI/PauseScreen.cpp | 0 Source/{SysPSP => }/UI/PauseScreen.h | 0 Source/{SysPSP => }/UI/RomPreferencesScreen.cpp | 0 Source/{SysPSP => }/UI/RomPreferencesScreen.h | 0 Source/{SysPSP => }/UI/RomSelectorComponent.cpp | 0 Source/{SysPSP => }/UI/RomSelectorComponent.h | 0 Source/{SysPSP => }/UI/SavestateSelectorComponent.cpp | 0 Source/{SysPSP => }/UI/SavestateSelectorComponent.h | 0 Source/{SysPSP => }/UI/SelectedRomComponent.cpp | 0 Source/{SysPSP => }/UI/SelectedRomComponent.h | 0 Source/{SysPSP => }/UI/SplashScreen.cpp | 0 Source/{SysPSP => }/UI/SplashScreen.h | 0 Source/{SysPSP => }/UI/UIAlignment.h | 0 Source/{SysPSP => }/UI/UICommand.cpp | 0 Source/{SysPSP => }/UI/UICommand.h | 0 Source/{SysPSP => }/UI/UIComponent.cpp | 0 Source/{SysPSP => }/UI/UIComponent.h | 0 Source/{SysPSP => }/UI/UIContext.cpp | 0 Source/{SysPSP => }/UI/UIContext.h | 0 Source/{SysPSP => }/UI/UIElement.cpp | 0 Source/{SysPSP => }/UI/UIElement.h | 0 Source/{SysPSP => }/UI/UIScreen.cpp | 0 Source/{SysPSP => }/UI/UIScreen.h | 0 Source/{SysPSP => }/UI/UISetting.cpp | 0 Source/{SysPSP => }/UI/UISetting.h | 0 Source/{SysPSP => }/UI/UISpacer.h | 0 46 files changed, 0 insertions(+), 0 deletions(-) rename Source/{SysPSP => }/UI/AboutComponent.cpp (100%) rename Source/{SysPSP => }/UI/AboutComponent.h (100%) rename Source/{SysPSP => }/UI/AdjustDeadzoneScreen.cpp (100%) rename Source/{SysPSP => }/UI/AdjustDeadzoneScreen.h (100%) rename Source/{SysPSP => }/UI/AdvancedOptionsScreen.cpp (100%) rename Source/{SysPSP => }/UI/AdvancedOptionsScreen.h (100%) rename Source/{SysPSP => }/UI/CMakeLists.txt (100%) rename Source/{SysPSP => }/UI/CheatOptionsScreen.cpp (100%) rename Source/{SysPSP => }/UI/CheatOptionsScreen.h (100%) rename Source/{SysPSP => }/UI/ColourPulser.cpp (100%) rename Source/{SysPSP => }/UI/ColourPulser.h (100%) rename Source/{SysPSP => }/UI/Dialogs.cpp (100%) rename Source/{SysPSP => }/UI/Dialogs.h (100%) rename Source/{SysPSP => }/UI/GlobalSettingsComponent.cpp (100%) rename Source/{SysPSP => }/UI/GlobalSettingsComponent.h (100%) rename Source/{SysPSP => }/UI/MainMenuScreen.cpp (100%) rename Source/{SysPSP => }/UI/MainMenuScreen.h (100%) rename Source/{SysPSP => }/UI/PSPMenu.h (100%) rename Source/{SysPSP => }/UI/PauseOptionsComponent.cpp (100%) rename Source/{SysPSP => }/UI/PauseOptionsComponent.h (100%) rename Source/{SysPSP => }/UI/PauseScreen.cpp (100%) rename Source/{SysPSP => }/UI/PauseScreen.h (100%) rename Source/{SysPSP => }/UI/RomPreferencesScreen.cpp (100%) rename Source/{SysPSP => }/UI/RomPreferencesScreen.h (100%) rename Source/{SysPSP => }/UI/RomSelectorComponent.cpp (100%) rename Source/{SysPSP => }/UI/RomSelectorComponent.h (100%) rename Source/{SysPSP => }/UI/SavestateSelectorComponent.cpp (100%) rename Source/{SysPSP => }/UI/SavestateSelectorComponent.h (100%) rename Source/{SysPSP => }/UI/SelectedRomComponent.cpp (100%) rename Source/{SysPSP => }/UI/SelectedRomComponent.h (100%) rename Source/{SysPSP => }/UI/SplashScreen.cpp (100%) rename Source/{SysPSP => }/UI/SplashScreen.h (100%) rename Source/{SysPSP => }/UI/UIAlignment.h (100%) rename Source/{SysPSP => }/UI/UICommand.cpp (100%) rename Source/{SysPSP => }/UI/UICommand.h (100%) rename Source/{SysPSP => }/UI/UIComponent.cpp (100%) rename Source/{SysPSP => }/UI/UIComponent.h (100%) rename Source/{SysPSP => }/UI/UIContext.cpp (100%) rename Source/{SysPSP => }/UI/UIContext.h (100%) rename Source/{SysPSP => }/UI/UIElement.cpp (100%) rename Source/{SysPSP => }/UI/UIElement.h (100%) rename Source/{SysPSP => }/UI/UIScreen.cpp (100%) rename Source/{SysPSP => }/UI/UIScreen.h (100%) rename Source/{SysPSP => }/UI/UISetting.cpp (100%) rename Source/{SysPSP => }/UI/UISetting.h (100%) rename Source/{SysPSP => }/UI/UISpacer.h (100%) diff --git a/Source/SysPSP/UI/AboutComponent.cpp b/Source/UI/AboutComponent.cpp similarity index 100% rename from Source/SysPSP/UI/AboutComponent.cpp rename to Source/UI/AboutComponent.cpp diff --git a/Source/SysPSP/UI/AboutComponent.h b/Source/UI/AboutComponent.h similarity index 100% rename from Source/SysPSP/UI/AboutComponent.h rename to Source/UI/AboutComponent.h diff --git a/Source/SysPSP/UI/AdjustDeadzoneScreen.cpp b/Source/UI/AdjustDeadzoneScreen.cpp similarity index 100% rename from Source/SysPSP/UI/AdjustDeadzoneScreen.cpp rename to Source/UI/AdjustDeadzoneScreen.cpp diff --git a/Source/SysPSP/UI/AdjustDeadzoneScreen.h b/Source/UI/AdjustDeadzoneScreen.h similarity index 100% rename from Source/SysPSP/UI/AdjustDeadzoneScreen.h rename to Source/UI/AdjustDeadzoneScreen.h diff --git a/Source/SysPSP/UI/AdvancedOptionsScreen.cpp b/Source/UI/AdvancedOptionsScreen.cpp similarity index 100% rename from Source/SysPSP/UI/AdvancedOptionsScreen.cpp rename to Source/UI/AdvancedOptionsScreen.cpp diff --git a/Source/SysPSP/UI/AdvancedOptionsScreen.h b/Source/UI/AdvancedOptionsScreen.h similarity index 100% rename from Source/SysPSP/UI/AdvancedOptionsScreen.h rename to Source/UI/AdvancedOptionsScreen.h diff --git a/Source/SysPSP/UI/CMakeLists.txt b/Source/UI/CMakeLists.txt similarity index 100% rename from Source/SysPSP/UI/CMakeLists.txt rename to Source/UI/CMakeLists.txt diff --git a/Source/SysPSP/UI/CheatOptionsScreen.cpp b/Source/UI/CheatOptionsScreen.cpp similarity index 100% rename from Source/SysPSP/UI/CheatOptionsScreen.cpp rename to Source/UI/CheatOptionsScreen.cpp diff --git a/Source/SysPSP/UI/CheatOptionsScreen.h b/Source/UI/CheatOptionsScreen.h similarity index 100% rename from Source/SysPSP/UI/CheatOptionsScreen.h rename to Source/UI/CheatOptionsScreen.h diff --git a/Source/SysPSP/UI/ColourPulser.cpp b/Source/UI/ColourPulser.cpp similarity index 100% rename from Source/SysPSP/UI/ColourPulser.cpp rename to Source/UI/ColourPulser.cpp diff --git a/Source/SysPSP/UI/ColourPulser.h b/Source/UI/ColourPulser.h similarity index 100% rename from Source/SysPSP/UI/ColourPulser.h rename to Source/UI/ColourPulser.h diff --git a/Source/SysPSP/UI/Dialogs.cpp b/Source/UI/Dialogs.cpp similarity index 100% rename from Source/SysPSP/UI/Dialogs.cpp rename to Source/UI/Dialogs.cpp diff --git a/Source/SysPSP/UI/Dialogs.h b/Source/UI/Dialogs.h similarity index 100% rename from Source/SysPSP/UI/Dialogs.h rename to Source/UI/Dialogs.h diff --git a/Source/SysPSP/UI/GlobalSettingsComponent.cpp b/Source/UI/GlobalSettingsComponent.cpp similarity index 100% rename from Source/SysPSP/UI/GlobalSettingsComponent.cpp rename to Source/UI/GlobalSettingsComponent.cpp diff --git a/Source/SysPSP/UI/GlobalSettingsComponent.h b/Source/UI/GlobalSettingsComponent.h similarity index 100% rename from Source/SysPSP/UI/GlobalSettingsComponent.h rename to Source/UI/GlobalSettingsComponent.h diff --git a/Source/SysPSP/UI/MainMenuScreen.cpp b/Source/UI/MainMenuScreen.cpp similarity index 100% rename from Source/SysPSP/UI/MainMenuScreen.cpp rename to Source/UI/MainMenuScreen.cpp diff --git a/Source/SysPSP/UI/MainMenuScreen.h b/Source/UI/MainMenuScreen.h similarity index 100% rename from Source/SysPSP/UI/MainMenuScreen.h rename to Source/UI/MainMenuScreen.h diff --git a/Source/SysPSP/UI/PSPMenu.h b/Source/UI/PSPMenu.h similarity index 100% rename from Source/SysPSP/UI/PSPMenu.h rename to Source/UI/PSPMenu.h diff --git a/Source/SysPSP/UI/PauseOptionsComponent.cpp b/Source/UI/PauseOptionsComponent.cpp similarity index 100% rename from Source/SysPSP/UI/PauseOptionsComponent.cpp rename to Source/UI/PauseOptionsComponent.cpp diff --git a/Source/SysPSP/UI/PauseOptionsComponent.h b/Source/UI/PauseOptionsComponent.h similarity index 100% rename from Source/SysPSP/UI/PauseOptionsComponent.h rename to Source/UI/PauseOptionsComponent.h diff --git a/Source/SysPSP/UI/PauseScreen.cpp b/Source/UI/PauseScreen.cpp similarity index 100% rename from Source/SysPSP/UI/PauseScreen.cpp rename to Source/UI/PauseScreen.cpp diff --git a/Source/SysPSP/UI/PauseScreen.h b/Source/UI/PauseScreen.h similarity index 100% rename from Source/SysPSP/UI/PauseScreen.h rename to Source/UI/PauseScreen.h diff --git a/Source/SysPSP/UI/RomPreferencesScreen.cpp b/Source/UI/RomPreferencesScreen.cpp similarity index 100% rename from Source/SysPSP/UI/RomPreferencesScreen.cpp rename to Source/UI/RomPreferencesScreen.cpp diff --git a/Source/SysPSP/UI/RomPreferencesScreen.h b/Source/UI/RomPreferencesScreen.h similarity index 100% rename from Source/SysPSP/UI/RomPreferencesScreen.h rename to Source/UI/RomPreferencesScreen.h diff --git a/Source/SysPSP/UI/RomSelectorComponent.cpp b/Source/UI/RomSelectorComponent.cpp similarity index 100% rename from Source/SysPSP/UI/RomSelectorComponent.cpp rename to Source/UI/RomSelectorComponent.cpp diff --git a/Source/SysPSP/UI/RomSelectorComponent.h b/Source/UI/RomSelectorComponent.h similarity index 100% rename from Source/SysPSP/UI/RomSelectorComponent.h rename to Source/UI/RomSelectorComponent.h diff --git a/Source/SysPSP/UI/SavestateSelectorComponent.cpp b/Source/UI/SavestateSelectorComponent.cpp similarity index 100% rename from Source/SysPSP/UI/SavestateSelectorComponent.cpp rename to Source/UI/SavestateSelectorComponent.cpp diff --git a/Source/SysPSP/UI/SavestateSelectorComponent.h b/Source/UI/SavestateSelectorComponent.h similarity index 100% rename from Source/SysPSP/UI/SavestateSelectorComponent.h rename to Source/UI/SavestateSelectorComponent.h diff --git a/Source/SysPSP/UI/SelectedRomComponent.cpp b/Source/UI/SelectedRomComponent.cpp similarity index 100% rename from Source/SysPSP/UI/SelectedRomComponent.cpp rename to Source/UI/SelectedRomComponent.cpp diff --git a/Source/SysPSP/UI/SelectedRomComponent.h b/Source/UI/SelectedRomComponent.h similarity index 100% rename from Source/SysPSP/UI/SelectedRomComponent.h rename to Source/UI/SelectedRomComponent.h diff --git a/Source/SysPSP/UI/SplashScreen.cpp b/Source/UI/SplashScreen.cpp similarity index 100% rename from Source/SysPSP/UI/SplashScreen.cpp rename to Source/UI/SplashScreen.cpp diff --git a/Source/SysPSP/UI/SplashScreen.h b/Source/UI/SplashScreen.h similarity index 100% rename from Source/SysPSP/UI/SplashScreen.h rename to Source/UI/SplashScreen.h diff --git a/Source/SysPSP/UI/UIAlignment.h b/Source/UI/UIAlignment.h similarity index 100% rename from Source/SysPSP/UI/UIAlignment.h rename to Source/UI/UIAlignment.h diff --git a/Source/SysPSP/UI/UICommand.cpp b/Source/UI/UICommand.cpp similarity index 100% rename from Source/SysPSP/UI/UICommand.cpp rename to Source/UI/UICommand.cpp diff --git a/Source/SysPSP/UI/UICommand.h b/Source/UI/UICommand.h similarity index 100% rename from Source/SysPSP/UI/UICommand.h rename to Source/UI/UICommand.h diff --git a/Source/SysPSP/UI/UIComponent.cpp b/Source/UI/UIComponent.cpp similarity index 100% rename from Source/SysPSP/UI/UIComponent.cpp rename to Source/UI/UIComponent.cpp diff --git a/Source/SysPSP/UI/UIComponent.h b/Source/UI/UIComponent.h similarity index 100% rename from Source/SysPSP/UI/UIComponent.h rename to Source/UI/UIComponent.h diff --git a/Source/SysPSP/UI/UIContext.cpp b/Source/UI/UIContext.cpp similarity index 100% rename from Source/SysPSP/UI/UIContext.cpp rename to Source/UI/UIContext.cpp diff --git a/Source/SysPSP/UI/UIContext.h b/Source/UI/UIContext.h similarity index 100% rename from Source/SysPSP/UI/UIContext.h rename to Source/UI/UIContext.h diff --git a/Source/SysPSP/UI/UIElement.cpp b/Source/UI/UIElement.cpp similarity index 100% rename from Source/SysPSP/UI/UIElement.cpp rename to Source/UI/UIElement.cpp diff --git a/Source/SysPSP/UI/UIElement.h b/Source/UI/UIElement.h similarity index 100% rename from Source/SysPSP/UI/UIElement.h rename to Source/UI/UIElement.h diff --git a/Source/SysPSP/UI/UIScreen.cpp b/Source/UI/UIScreen.cpp similarity index 100% rename from Source/SysPSP/UI/UIScreen.cpp rename to Source/UI/UIScreen.cpp diff --git a/Source/SysPSP/UI/UIScreen.h b/Source/UI/UIScreen.h similarity index 100% rename from Source/SysPSP/UI/UIScreen.h rename to Source/UI/UIScreen.h diff --git a/Source/SysPSP/UI/UISetting.cpp b/Source/UI/UISetting.cpp similarity index 100% rename from Source/SysPSP/UI/UISetting.cpp rename to Source/UI/UISetting.cpp diff --git a/Source/SysPSP/UI/UISetting.h b/Source/UI/UISetting.h similarity index 100% rename from Source/SysPSP/UI/UISetting.h rename to Source/UI/UISetting.h diff --git a/Source/SysPSP/UI/UISpacer.h b/Source/UI/UISpacer.h similarity index 100% rename from Source/SysPSP/UI/UISpacer.h rename to Source/UI/UISpacer.h From d3c304abae36c739c68caa5e5e702bd0bb621ecb Mon Sep 17 00:00:00 2001 From: Howard Su Date: Tue, 5 Dec 2023 14:15:25 +0800 Subject: [PATCH 02/54] Cleanup UI code for platform independent --- Source/CMakeLists.txt | 1 + Source/Core/Cheats.cpp | 2 +- Source/Graphics/GraphicsContext.h | 9 ++-- Source/Input/InputManager.h | 5 +-- Source/Interface/Preferences.cpp | 2 +- Source/SysPSP/CMakeLists.txt | 1 - Source/SysPSP/Graphics/DrawText.cpp | 10 ----- Source/SysPSP/Graphics/DrawText.h | 9 +--- Source/SysPSP/Graphics/GraphicsContext.cpp | 5 ++- Source/SysPSP/Graphics/VideoMemoryManager.cpp | 2 +- Source/SysPSP/Input/InputManagerPSP.cpp | 2 +- Source/{UI => SysPSP}/UIContext.cpp | 2 +- Source/SysPSP/main.cpp | 10 ++--- Source/System/SystemInit.cpp | 2 +- Source/UI/AboutComponent.cpp | 14 +++---- Source/UI/AdjustDeadzoneScreen.cpp | 11 +++-- Source/UI/AdvancedOptionsScreen.cpp | 16 ++++---- Source/UI/CMakeLists.txt | 2 +- Source/UI/CheatOptionsScreen.cpp | 19 ++++----- Source/UI/ColourPulser.cpp | 2 +- Source/UI/Dialogs.cpp | 10 ++--- Source/UI/DrawTextUtilities.cpp | 22 ++++++++++ Source/UI/DrawTextUtilities.h | 21 ++++++++++ Source/UI/GlobalSettingsComponent.cpp | 23 +++++------ Source/UI/GlobalSettingsComponent.h | 2 +- Source/UI/MainMenuScreen.cpp | 29 +++++-------- Source/UI/PSPMenu.h | 1 - Source/UI/PauseOptionsComponent.cpp | 31 +++++++------- Source/UI/PauseOptionsComponent.h | 2 +- Source/UI/PauseScreen.cpp | 40 +++++++++--------- Source/UI/RomPreferencesScreen.cpp | 18 ++++---- Source/UI/RomSelectorComponent.cpp | 27 +++++------- Source/UI/RomSelectorComponent.h | 4 +- Source/UI/SavestateSelectorComponent.cpp | 41 ++++++++++++------- Source/UI/SavestateSelectorComponent.h | 4 +- Source/UI/SelectedRomComponent.cpp | 31 +++++--------- Source/UI/SelectedRomComponent.h | 4 +- Source/UI/SplashScreen.cpp | 13 +++--- Source/UI/UICommand.cpp | 8 ++-- Source/UI/UICommand.h | 4 +- Source/UI/UIComponent.cpp | 8 ++-- Source/UI/UIContext.h | 30 +++++++++++++- Source/UI/UIElement.cpp | 4 +- Source/UI/UIElement.h | 2 +- Source/UI/UIScreen.cpp | 13 +----- Source/UI/UISetting.cpp | 6 +-- Source/UI/UISetting.h | 2 +- Source/UI/UISpacer.h | 2 +- Source/Utility/CMakeLists.txt | 3 +- Source/{SysPSP => }/Utility/Functor.h | 0 Source/{SysPSP => }/Utility/Translate.cpp | 4 +- Source/{SysPSP => }/Utility/Translate.h | 0 Source/{SysPSP => }/Utility/VolatileMem.h | 0 53 files changed, 271 insertions(+), 264 deletions(-) rename Source/{UI => SysPSP}/UIContext.cpp (99%) create mode 100644 Source/UI/DrawTextUtilities.cpp create mode 100644 Source/UI/DrawTextUtilities.h rename Source/{SysPSP => }/Utility/Functor.h (100%) rename Source/{SysPSP => }/Utility/Translate.cpp (95%) rename Source/{SysPSP => }/Utility/Translate.h (100%) rename Source/{SysPSP => }/Utility/VolatileMem.h (100%) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index e877614ad..d6d2491b7 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -204,6 +204,7 @@ if(WIN32) add_subdirectory(System) add_subdirectory(Test) add_subdirectory(Utility) + add_subdirectory(UI) if(UNIX) add_subdirectory(SysPosix) diff --git a/Source/Core/Cheats.cpp b/Source/Core/Cheats.cpp index 9883dc7e0..53c22a16e 100644 --- a/Source/Core/Cheats.cpp +++ b/Source/Core/Cheats.cpp @@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Ultra/ultra_R4300.h" #include "System/IO.h" #include "Utility/StringUtil.h" -#include "SysPSP/Utility/VolatileMem.h" +#include "Utility/VolatileMem.h" #include // diff --git a/Source/Graphics/GraphicsContext.h b/Source/Graphics/GraphicsContext.h index 134910fd6..310750071 100644 --- a/Source/Graphics/GraphicsContext.h +++ b/Source/Graphics/GraphicsContext.h @@ -47,11 +47,10 @@ class CGraphicsContext : public CSingleton< CGraphicsContext > virtual bool IsInitialised() const = 0; -#ifdef DAEDALUS_PSP - virtual void SwitchToChosenDisplay() = 0; - virtual void SwitchToLcdDisplay() = 0; - virtual void StoreSaveScreenData() = 0; -#endif + virtual void SwitchToChosenDisplay() {}; + virtual void SwitchToLcdDisplay() {}; + virtual void StoreSaveScreenData() {}; + #ifdef DAEDALUS_CTR virtual void ResetVertexBuffer() = 0; #endif diff --git a/Source/Input/InputManager.h b/Source/Input/InputManager.h index 2f17f355e..49ba31c28 100644 --- a/Source/Input/InputManager.h +++ b/Source/Input/InputManager.h @@ -11,14 +11,13 @@ class CInputManager : public CSingleton< CInputManager > public: virtual ~CInputManager() {} -#if defined(DAEDALUS_PSP) || defined(DAEDALUS_CTR) virtual u32 GetNumConfigurations() const = 0; virtual const char * GetConfigurationName( u32 configuration_idx ) const = 0; virtual const char * GetConfigurationDescription( u32 configuration_idx ) const = 0; virtual void SetConfiguration( u32 configuration_idx ) = 0; virtual u32 GetConfigurationFromName( const char * name ) const = 0; -#endif + virtual bool Initialise() = 0; virtual void Finalise() = 0; @@ -28,8 +27,6 @@ class CInputManager : public CSingleton< CInputManager > static void Fini() { CInputManager::Get()->Finalise();} }; -#ifdef DAEDALUS_PSP v2 ApplyDeadzone( const v2 & in, f32 min_deadzone, f32 max_deadzone ); -#endif #endif // INPUT_INPUTMANAGER_H_ diff --git a/Source/Interface/Preferences.cpp b/Source/Interface/Preferences.cpp index 2b5802ddc..d309509b3 100644 --- a/Source/Interface/Preferences.cpp +++ b/Source/Interface/Preferences.cpp @@ -40,7 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Path.h" #ifdef DAEDALUS_PSP -#include "SysPSP/Utility/Translate.h" +#include "Utility/Translate.h" #endif // Audio is disabled on the PSP by default, but enabled on other platforms. diff --git a/Source/SysPSP/CMakeLists.txt b/Source/SysPSP/CMakeLists.txt index 0bd85ffbf..56dae7ca7 100644 --- a/Source/SysPSP/CMakeLists.txt +++ b/Source/SysPSP/CMakeLists.txt @@ -4,7 +4,6 @@ add_subdirectory(HLEAudio) add_subdirectory(HLEGraphics) add_subdirectory(Input) add_subdirectory(PRX) -add_subdirectory(UI) add_subdirectory(Utility) # Create and install Plugin files diff --git a/Source/SysPSP/Graphics/DrawText.cpp b/Source/SysPSP/Graphics/DrawText.cpp index f43dd986f..205100eb8 100644 --- a/Source/SysPSP/Graphics/DrawText.cpp +++ b/Source/SysPSP/Graphics/DrawText.cpp @@ -149,16 +149,6 @@ s32 CDrawText::GetFontHeight(EFont font_type) //************************************************************************************* namespace DrawTextUtilities { - const c32 TextWhite = c32(255, 255, 255); - const c32 TextWhiteDisabled = c32(208, 208, 208); - const c32 TextBlue = c32(80, 80, 208); - const c32 TextBlueDisabled = c32(80, 80, 178); - const c32 TextRed = c32(255, 0, 0); - const c32 TextRedDisabled = c32(208, 208, 208); - - static c32 COLOUR_SHADOW_HEAVY = c32(0x80000000); - static c32 COLOUR_SHADOW_LIGHT = c32(0x50000000); - const char *FindPreviousSpace(const char *p_str_start, const char *p_str_end) { while (p_str_end > p_str_start) diff --git a/Source/SysPSP/Graphics/DrawText.h b/Source/SysPSP/Graphics/DrawText.h index 6fdc60fba..4cfbae4cc 100644 --- a/Source/SysPSP/Graphics/DrawText.h +++ b/Source/SysPSP/Graphics/DrawText.h @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "Graphics/ColourValue.h" -#include "SysPSP/UI/UIAlignment.h" +#include "UI/UIAlignment.h" class CDrawText { @@ -56,13 +56,6 @@ class CDrawText namespace DrawTextUtilities { - extern const c32 TextWhite; - extern const c32 TextWhiteDisabled; - extern const c32 TextBlue; - extern const c32 TextBlueDisabled; - extern const c32 TextRed; - extern const c32 TextRedDisabled; - void WrapText( CDrawText::EFont font, s32 width, const char * p_str, u32 length, std::vector & lengths, bool & match ); //inline void WrapText( CDrawText::EFont font, s32 width, const char * p_str, std::vector & lengths ) { WrapText( font, width, p_str, strlen( p_str ), lengths ); } } diff --git a/Source/SysPSP/Graphics/GraphicsContext.cpp b/Source/SysPSP/Graphics/GraphicsContext.cpp index 9e201d856..1bfaea7de 100644 --- a/Source/SysPSP/Graphics/GraphicsContext.cpp +++ b/Source/SysPSP/Graphics/GraphicsContext.cpp @@ -37,7 +37,7 @@ #include "System/IO.h" #include "Interface/Preferences.h" #include "Utility/Profiler.h" -#include "SysPSP/Utility/VolatileMem.h" +#include "Utility/VolatileMem.h" namespace { @@ -825,6 +825,9 @@ bool IGraphicsContext::Initialise() sceGuStart(GU_CALL,list[1]); sceGuFinish(); + // Initialize DrawText + CDrawText::Initialise(); + // The app is ready to go mInitialised = true; return true; diff --git a/Source/SysPSP/Graphics/VideoMemoryManager.cpp b/Source/SysPSP/Graphics/VideoMemoryManager.cpp index c1ccbedba..0af5bf0ff 100644 --- a/Source/SysPSP/Graphics/VideoMemoryManager.cpp +++ b/Source/SysPSP/Graphics/VideoMemoryManager.cpp @@ -6,7 +6,7 @@ #include #include -#include "SysPSP/Utility/VolatileMem.h" +#include "Utility/VolatileMem.h" #include "Utility/MemoryHeap.h" #include "Base/MathUtil.h" #include "SysPSP/Graphics/VideoMemoryManager.h" diff --git a/Source/SysPSP/Input/InputManagerPSP.cpp b/Source/SysPSP/Input/InputManagerPSP.cpp index cb59362b7..1bb97b901 100644 --- a/Source/SysPSP/Input/InputManagerPSP.cpp +++ b/Source/SysPSP/Input/InputManagerPSP.cpp @@ -1007,7 +1007,7 @@ v2 ProjectToUnitSquare( const v2 & in ) //************************************************************************************* v2 ApplyDeadzone( const v2 & in, f32 min_deadzone, f32 max_deadzone ) { - #ifdef DAEDALUS_ENABLE_ASSERTS +#ifdef DAEDALUS_ENABLE_ASSERTS DAEDALUS_ASSERT( min_deadzone >= 0.0f && min_deadzone <= 1.0f, "Invalid min deadzone" ); DAEDALUS_ASSERT( max_deadzone >= 0.0f && max_deadzone <= 1.0f, "Invalid max deadzone" ); diff --git a/Source/UI/UIContext.cpp b/Source/SysPSP/UIContext.cpp similarity index 99% rename from Source/UI/UIContext.cpp rename to Source/SysPSP/UIContext.cpp index 4ab41c630..47e52b503 100644 --- a/Source/UI/UIContext.cpp +++ b/Source/SysPSP/UIContext.cpp @@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Graphics/GraphicsContext.h" #include "Graphics/NativeTexture.h" #include "SysPSP/Graphics/DrawText.h" -#include "SysPSP/UI/UIContext.h" +#include "UIContext.h" #define GL_TRUE 1 diff --git a/Source/SysPSP/main.cpp b/Source/SysPSP/main.cpp index da48faac4..e156d0255 100644 --- a/Source/SysPSP/main.cpp +++ b/Source/SysPSP/main.cpp @@ -53,10 +53,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Input/InputManager.h" #include "Interface/RomDB.h" #include "SysPSP/Graphics/DrawText.h" -#include "SysPSP/UI/MainMenuScreen.h" -#include "SysPSP/UI/PauseScreen.h" -#include "SysPSP/UI/SplashScreen.h" -#include "SysPSP/UI/UIContext.h" +#include "UI/MainMenuScreen.h" +#include "UI/PauseScreen.h" +#include "UI/SplashScreen.h" +#include "UI/UIContext.h" #include #include "System/SystemInit.h" @@ -66,7 +66,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Interface/Preferences.h" #include "Utility/Profiler.h" #include "System/Thread.h" -#include "SysPSP/Utility/Translate.h" +#include "Utility/Translate.h" #include "Utility/Timer.h" diff --git a/Source/System/SystemInit.cpp b/Source/System/SystemInit.cpp index 9bf9ec88b..dced2ba63 100644 --- a/Source/System/SystemInit.cpp +++ b/Source/System/SystemInit.cpp @@ -52,7 +52,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Utility/Profiler.h" #include "Interface/Preferences.h" #ifdef DAEDALUS_PSP -#include "SysPSP/Utility/Translate.h" +#include "Utility/Translate.h" #endif #include "Input/InputManager.h" // CInputManager::Create/Destroy diff --git a/Source/UI/AboutComponent.cpp b/Source/UI/AboutComponent.cpp index dfd6beb47..9cf7cb0b2 100644 --- a/Source/UI/AboutComponent.cpp +++ b/Source/UI/AboutComponent.cpp @@ -19,24 +19,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "SysPSP/UI/AboutComponent.h" +#include "AboutComponent.h" -#include "SysPSP/UI/UIContext.h" -#include "SysPSP/UI/UIScreen.h" +#include "UIContext.h" +#include "UIScreen.h" #include "Graphics/ColourValue.h" #include "Graphics/NativeTexture.h" #include "Base/MathUtil.h" #include "Math/Vector2.h" -#include "SysPSP/Graphics/DrawText.h" +#include "DrawTextUtilities.h" #include "Base/Macros.h" -#include "SysPSP/Utility/Translate.h" -#include "SysPSP/UI/PSPMenu.h" +#include "Utility/Translate.h" +#include "PSPMenu.h" #include -#include -#include class IAboutComponent : public CAboutComponent { diff --git a/Source/UI/AdjustDeadzoneScreen.cpp b/Source/UI/AdjustDeadzoneScreen.cpp index 26e32e315..be0b96f6d 100644 --- a/Source/UI/AdjustDeadzoneScreen.cpp +++ b/Source/UI/AdjustDeadzoneScreen.cpp @@ -19,12 +19,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "SysPSP/UI/AdjustDeadzoneScreen.h" +#include "AdjustDeadzoneScreen.h" #include +#include -#include -#include #include "UIContext.h" #include "UIScreen.h" @@ -33,10 +32,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Math/Math.h" // VFPU Math #include "Base/MathUtil.h" #include "Math/Vector2.h" -#include "SysPSP/Graphics/DrawText.h" +#include "DrawTextUtilities.h" #include "Interface/Preferences.h" -#include "SysPSP/Utility/Translate.h" -#include "SysPSP/UI/PSPMenu.h" +#include "Utility/Translate.h" +#include "PSPMenu.h" #include diff --git a/Source/UI/AdvancedOptionsScreen.cpp b/Source/UI/AdvancedOptionsScreen.cpp index ff981b39d..2571975a7 100644 --- a/Source/UI/AdvancedOptionsScreen.cpp +++ b/Source/UI/AdvancedOptionsScreen.cpp @@ -21,21 +21,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" #include "AdvancedOptionsScreen.h" -#include - -#include "SysPSP/UI/PSPMenu.h" -#include "SysPSP/UI/UIContext.h" -#include "SysPSP/UI/UIScreen.h" -#include "SysPSP/UI/UISetting.h" -#include "SysPSP/UI/UISpacer.h" -#include "SysPSP/UI/UICommand.h" +#include "PSPMenu.h" +#include "UIContext.h" +#include "UIScreen.h" +#include "UISetting.h" +#include "UISpacer.h" +#include "UICommand.h" #include "Config/ConfigOptions.h" #include "Core/ROM.h" #include "Core/RomSettings.h" #include "Graphics/ColourValue.h" #include "Input/InputManager.h" -#include "SysPSP/Graphics/DrawText.h" +#include "DrawTextUtilities.h" #include "Interface/Preferences.h" diff --git a/Source/UI/CMakeLists.txt b/Source/UI/CMakeLists.txt index 11f3cb0d2..4e082f0f3 100644 --- a/Source/UI/CMakeLists.txt +++ b/Source/UI/CMakeLists.txt @@ -16,10 +16,10 @@ add_library(UI_PSP OBJECT SplashScreen.cpp UICommand.cpp UIComponent.cpp - UIContext.cpp UIElement.cpp UIScreen.cpp UISetting.cpp + DrawTextUtilities.cpp ) diff --git a/Source/UI/CheatOptionsScreen.cpp b/Source/UI/CheatOptionsScreen.cpp index 528bdbd52..ac7089aed 100644 --- a/Source/UI/CheatOptionsScreen.cpp +++ b/Source/UI/CheatOptionsScreen.cpp @@ -17,18 +17,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include - - #include "Base/Types.h" -#include "SysPSP/UI/CheatOptionsScreen.h" -#include "SysPSP/UI/PSPMenu.h" -#include "SysPSP/UI/UIContext.h" -#include "SysPSP/UI/UIScreen.h" -#include "SysPSP/UI/UISetting.h" -#include "SysPSP/UI/UISpacer.h" -#include "SysPSP/UI/UICommand.h" +#include "CheatOptionsScreen.h" +#include "PSPMenu.h" +#include "UIContext.h" +#include "UIScreen.h" +#include "UISetting.h" +#include "UISpacer.h" +#include "UICommand.h" #include "Config/ConfigOptions.h" #include "Core/Cheats.h" @@ -36,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/RomSettings.h" #include "Graphics/ColourValue.h" #include "Input/InputManager.h" -#include "SysPSP/Graphics/DrawText.h" +#include "DrawTextUtilities.h" #include "System/IO.h" #include "Interface/Preferences.h" #include "Utility/Stream.h" diff --git a/Source/UI/ColourPulser.cpp b/Source/UI/ColourPulser.cpp index d2b592b80..7b0df0625 100644 --- a/Source/UI/ColourPulser.cpp +++ b/Source/UI/ColourPulser.cpp @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Graphics/ColourValue.h" #include "Math/Math.h" // VFPU Math -#include "SysPSP/UI/ColourPulser.h" +#include "ColourPulser.h" CColourPulser::CColourPulser( c32 dim_colour, c32 bright_colour, u32 cycle_period ) diff --git a/Source/UI/Dialogs.cpp b/Source/UI/Dialogs.cpp index eb5de147b..443dd519d 100644 --- a/Source/UI/Dialogs.cpp +++ b/Source/UI/Dialogs.cpp @@ -19,15 +19,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "SysPSP/UI/Dialogs.h" -#include "SysPSP/UI/UIContext.h" +#include "Dialogs.h" +#include "UIContext.h" #include "Graphics/ColourValue.h" -#include "SysPSP/Graphics/DrawText.h" - -#include -#include -#include +#include "DrawTextUtilities.h" CDialog gShowDialog; diff --git a/Source/UI/DrawTextUtilities.cpp b/Source/UI/DrawTextUtilities.cpp new file mode 100644 index 000000000..2188a5bdc --- /dev/null +++ b/Source/UI/DrawTextUtilities.cpp @@ -0,0 +1,22 @@ +#include "Base/Types.h" +#include "Dialogs.h" +#include "UIContext.h" + +#include "Graphics/ColourValue.h" +#include "DrawTextUtilities.h" + +//************************************************************************************* +// +//************************************************************************************* +namespace DrawTextUtilities +{ + const c32 TextWhite = c32(255, 255, 255); + const c32 TextWhiteDisabled = c32(208, 208, 208); + const c32 TextBlue = c32(80, 80, 208); + const c32 TextBlueDisabled = c32(80, 80, 178); + const c32 TextRed = c32(255, 0, 0); + const c32 TextRedDisabled = c32(208, 208, 208); + + static c32 COLOUR_SHADOW_HEAVY = c32(0x80000000); + static c32 COLOUR_SHADOW_LIGHT = c32(0x50000000); +} // namespace DrawTextUtilities diff --git a/Source/UI/DrawTextUtilities.h b/Source/UI/DrawTextUtilities.h new file mode 100644 index 000000000..096cc7bd5 --- /dev/null +++ b/Source/UI/DrawTextUtilities.h @@ -0,0 +1,21 @@ +#ifndef DRAWTEXT_UTILIEIES_H_ +#define DRAWTEXT_UTILIEIES_H_ + +#include + +#include + +#include "Graphics/ColourValue.h" +#include "UI/UIAlignment.h" + +namespace DrawTextUtilities +{ + extern const c32 TextWhite; + extern const c32 TextWhiteDisabled; + extern const c32 TextBlue; + extern const c32 TextBlueDisabled; + extern const c32 TextRed; + extern const c32 TextRedDisabled; +} + +#endif \ No newline at end of file diff --git a/Source/UI/GlobalSettingsComponent.cpp b/Source/UI/GlobalSettingsComponent.cpp index c8b850bbf..4bc42cec5 100644 --- a/Source/UI/GlobalSettingsComponent.cpp +++ b/Source/UI/GlobalSettingsComponent.cpp @@ -22,27 +22,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -#include -#include -#include #include "Graphics/ColourValue.h" -#include "SysPSP/UI/AdjustDeadzoneScreen.h" -#include "SysPSP/UI/GlobalSettingsComponent.h" -#include "SysPSP/Graphics/DrawText.h" -#include "SysPSP/UI/Dialogs.h" -#include "SysPSP/UI/UIContext.h" -#include "SysPSP/UI/UIScreen.h" -#include "SysPSP/UI/UISetting.h" -#include "SysPSP/UI/PSPMenu.h" +#include "AdjustDeadzoneScreen.h" +#include "GlobalSettingsComponent.h" +#include "DrawTextUtilities.h" +#include "Dialogs.h" +#include "UIContext.h" +#include "UIScreen.h" +#include "UISetting.h" +#include "PSPMenu.h" #include "System/Thread.h" #include "Core/FramerateLimiter.h" #include "Interface/Preferences.h" #include "System/IO.h" -#include "SysPSP/Utility/Translate.h" +#include "Utility/Translate.h" #include "Input/InputManager.h" @@ -209,7 +206,7 @@ namespace if(gShowDialog.Render( mpContext,"Reset settings?", false) ) { std::filesystem::remove("preferences.ini"); - std::filesystem::remove("rom.db"); + std::filesystem::remove("rom.db"); ThreadSleepMs(1000); //safety wait for s gShowDialog.Render( mpContext,"Daedalus will exit now",true); diff --git a/Source/UI/GlobalSettingsComponent.h b/Source/UI/GlobalSettingsComponent.h index 245e6b186..0cbce2982 100644 --- a/Source/UI/GlobalSettingsComponent.h +++ b/Source/UI/GlobalSettingsComponent.h @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SYSPSP_UI_GLOBALSETTINGSCOMPONENT_H_ #define SYSPSP_UI_GLOBALSETTINGSCOMPONENT_H_ -#include "SysPSP/UI/UIComponent.h" +#include "UIComponent.h" class CGlobalSettingsComponent : public CUIComponent { diff --git a/Source/UI/MainMenuScreen.cpp b/Source/UI/MainMenuScreen.cpp index 8e6a20eab..d88931ff1 100644 --- a/Source/UI/MainMenuScreen.cpp +++ b/Source/UI/MainMenuScreen.cpp @@ -23,9 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -#include -#include - #include "Core/CPU.h" #include "Core/ROM.h" #include "Core/RomSettings.h" @@ -33,17 +30,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Graphics/ColourValue.h" #include "Graphics/GraphicsContext.h" #include "Base/MathUtil.h" -#include "SysPSP/Graphics/DrawText.h" -#include "SysPSP/UI/AboutComponent.h" -#include "SysPSP/UI/GlobalSettingsComponent.h" -#include "SysPSP/UI/MainMenuScreen.h" -#include "SysPSP/UI/PSPMenu.h" -#include "SysPSP/UI/RomSelectorComponent.h" -#include "SysPSP/UI/SelectedRomComponent.h" -#include "SysPSP/UI/SavestateSelectorComponent.h" -#include "SysPSP/UI/UIContext.h" -#include "SysPSP/UI/UIScreen.h" -#include "SysPSP/UI/SplashScreen.h" +#include "DrawTextUtilities.h" +#include "AboutComponent.h" +#include "GlobalSettingsComponent.h" +#include "MainMenuScreen.h" +#include "PSPMenu.h" +#include "RomSelectorComponent.h" +#include "SelectedRomComponent.h" +#include "SavestateSelectorComponent.h" +#include "UIContext.h" +#include "UIScreen.h" +#include "SplashScreen.h" #include "System/SystemInit.h" #include "Interface/Preferences.h" @@ -381,8 +378,6 @@ void DisplayRomsAndChoose(bool show_splash) // switch back to the LCD display CGraphicsContext::Get()->SwitchToLcdDisplay(); - CDrawText::Initialise(); - CUIContext * p_context( CUIContext::Create() ); if(p_context != NULL) @@ -401,7 +396,5 @@ void DisplayRomsAndChoose(bool show_splash) } delete p_context; - - CDrawText::Destroy(); } diff --git a/Source/UI/PSPMenu.h b/Source/UI/PSPMenu.h index c32438dbd..83b14a53b 100644 --- a/Source/UI/PSPMenu.h +++ b/Source/UI/PSPMenu.h @@ -4,7 +4,6 @@ #include "Base/Types.h" #include - // User Interface Variables const s16 SCREEN_WIDTH {480}; const s16 SCREEN_HEIGHT {272}; diff --git a/Source/UI/PauseOptionsComponent.cpp b/Source/UI/PauseOptionsComponent.cpp index c92b97fd7..f8cb0ae7a 100644 --- a/Source/UI/PauseOptionsComponent.cpp +++ b/Source/UI/PauseOptionsComponent.cpp @@ -28,25 +28,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "HLEGraphics/DisplayListDebugger.h" #include "Graphics/ColourValue.h" #include "Graphics/GraphicsContext.h" -#include "SysPSP/Graphics/DrawText.h" -#include "SysPSP/UI/AdvancedOptionsScreen.h" -#include "SysPSP/UI/SavestateSelectorComponent.h" -#include "SysPSP/UI/CheatOptionsScreen.h" -#include "SysPSP/UI/Dialogs.h" -#include "SysPSP/UI/PauseOptionsComponent.h" -#include "SysPSP/UI/PSPMenu.h" -#include "SysPSP/UI/RomPreferencesScreen.h" -#include "SysPSP/UI/UIContext.h" -#include "SysPSP/UI/UIScreen.h" -#include "SysPSP/UI/UISetting.h" -#include "SysPSP/UI/UICommand.h" -#include "SysPSP/UI/UISpacer.h" -#include "SysPSP/Utility/Functor.h" +#include "DrawTextUtilities.h" +#include "AdvancedOptionsScreen.h" +#include "SavestateSelectorComponent.h" +#include "CheatOptionsScreen.h" +#include "Dialogs.h" +#include "PauseOptionsComponent.h" +#include "PSPMenu.h" +#include "RomPreferencesScreen.h" +#include "UIContext.h" +#include "UIScreen.h" +#include "UISetting.h" +#include "UICommand.h" +#include "UISpacer.h" +#include "Utility/Functor.h" #include "System/IO.h" -#include -#include - extern bool gTakeScreenshot; extern bool gTakeScreenshotSS; diff --git a/Source/UI/PauseOptionsComponent.h b/Source/UI/PauseOptionsComponent.h index 74f5bf2af..3978b9513 100644 --- a/Source/UI/PauseOptionsComponent.h +++ b/Source/UI/PauseOptionsComponent.h @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SYSPSP_UI_PAUSEOPTIONSCOMPONENT_H_ #define SYSPSP_UI_PAUSEOPTIONSCOMPONENT_H_ -#include "SysPSP/UI/UIComponent.h" +#include "UIComponent.h" class CFunctor; diff --git a/Source/UI/PauseScreen.cpp b/Source/UI/PauseScreen.cpp index 3e991a6db..2590e3489 100644 --- a/Source/UI/PauseScreen.cpp +++ b/Source/UI/PauseScreen.cpp @@ -23,11 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -#include -#include -#include -#include - #include @@ -37,16 +32,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Graphics/ColourValue.h" #include "Graphics/GraphicsContext.h" #include "Base/MathUtil.h" -#include "SysPSP/Graphics/DrawText.h" -#include "SysPSP/UI/UIContext.h" -#include "SysPSP/UI/UIScreen.h" -#include "SysPSP/UI/AboutComponent.h" -#include "SysPSP/UI/GlobalSettingsComponent.h" -#include "SysPSP/UI/PauseOptionsComponent.h" -#include "SysPSP/UI/PauseScreen.h" - -#include "SysPSP/Utility/Functor.h" -#include "SysPSP/Utility/Translate.h" +#include "DrawTextUtilities.h" +#include "UIContext.h" +#include "UIScreen.h" +#include "AboutComponent.h" +#include "GlobalSettingsComponent.h" +#include "PauseOptionsComponent.h" +#include "PauseScreen.h" + +#include "Utility/Functor.h" +#include "Utility/Translate.h" #include "PSPMenu.h" extern void battery_info(); @@ -237,12 +232,12 @@ void IPauseScreen::Render() EMenuOption current( GetCurrentOption() ); EMenuOption next( GetNextOption() ); - s32 bat = scePowerGetBatteryLifePercent(); - s32 batteryLifeTime = scePowerGetBatteryLifeTime(); - // Meh should be big enough regarding if translated.. char info[120]; +#if DAEDALUS_PSP + s32 bat = scePowerGetBatteryLifePercent(); + s32 batteryLifeTime = scePowerGetBatteryLifeTime(); if(!scePowerIsBatteryCharging()) { snprintf(info, sizeof(info), " [%s %d%% %s %2dh %2dm]", @@ -255,10 +250,13 @@ void IPauseScreen::Render() snprintf(info, sizeof(info), "[%s]" , Translate_String("Battery is Charging")); } -// Battery Info +#else + snprintf(info, sizeof(info), "PAUSED"); +#endif + + // Battery Info mpContext->SetFontStyle( CUIContext::FS_REGULAR ); mpContext->DrawTextAlign( 0, SCREEN_WIDTH - LIST_TEXT_LEFT, AT_RIGHT, CATEGORY_TEXT_TOP, info, DrawTextUtilities::TextWhiteDisabled, DrawTextUtilities::TextBlueDisabled ); - p_option_text = gMenuOptionNames[ previous ]; mpContext->DrawTextAlign( LIST_TEXT_LEFT, LIST_TEXT_WIDTH, AT_LEFT, y + mpContext->GetFontHeight(), p_option_text, IsOptionValid( previous ) ? valid_colour : invalid_colour ); @@ -280,7 +278,9 @@ void IPauseScreen::Run() mIsFinished = false; CUIScreen::Run(); +#ifdef DAEDALUS_PSP CGraphicsContext::Get()->SwitchToChosenDisplay(); +#endif CGraphicsContext::Get()->ClearAllSurfaces(); } diff --git a/Source/UI/RomPreferencesScreen.cpp b/Source/UI/RomPreferencesScreen.cpp index e058033a5..1d1fc9e4c 100644 --- a/Source/UI/RomPreferencesScreen.cpp +++ b/Source/UI/RomPreferencesScreen.cpp @@ -20,24 +20,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" - #include -#include #include "Config/ConfigOptions.h" #include "Core/ROM.h" #include "Core/RomSettings.h" #include "Graphics/ColourValue.h" #include "Input/InputManager.h" -#include "SysPSP/Graphics/DrawText.h" -#include "SysPSP/UI/PSPMenu.h" -#include "SysPSP/UI/RomPreferencesScreen.h" -#include "SysPSP/UI/UIContext.h" -#include "SysPSP/UI/UIScreen.h" -#include "SysPSP/UI/UISetting.h" -#include "SysPSP/UI/UISpacer.h" -#include "SysPSP/UI/UICommand.h" +#include "DrawTextUtilities.h" +#include "PSPMenu.h" +#include "RomPreferencesScreen.h" +#include "UIContext.h" +#include "UIScreen.h" +#include "UISetting.h" +#include "UISpacer.h" +#include "UICommand.h" #include "Interface/Preferences.h" diff --git a/Source/UI/RomSelectorComponent.cpp b/Source/UI/RomSelectorComponent.cpp index a26ddc4e1..82cb2b3f3 100644 --- a/Source/UI/RomSelectorComponent.cpp +++ b/Source/UI/RomSelectorComponent.cpp @@ -21,13 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -#include -#include -#include -#include -#include -#include - #include "Base/Types.h" @@ -38,21 +31,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Input/InputManager.h" #include "Base/MathUtil.h" #include "Math/Vector2.h" -#include "SysPSP/Graphics/DrawText.h" -#include "SysPSP/UI/PSPMenu.h" -#include "SysPSP/UI/RomSelectorComponent.h" -#include "SysPSP/UI/UIContext.h" -#include "SysPSP/UI/UIScreen.h" +#include "DrawTextUtilities.h" +#include "PSPMenu.h" +#include "RomSelectorComponent.h" +#include "UIContext.h" +#include "UIScreen.h" #include "System/IO.h" #include "Interface/Preferences.h" #include "RomFile/RomFile.h" - - - - namespace { @@ -444,8 +433,10 @@ void IRomSelectorComponent::RenderRomList() x = LIST_TEXT_LEFT; y = BELOW_MENU_MIN + mCurrentScrollOffset + font_height; +#ifdef DAEDALUS_PSP sceGuEnable(GU_SCISSOR_TEST); sceGuScissor(LIST_TEXT_LEFT, BELOW_MENU_MIN, LIST_TEXT_LEFT+LIST_TEXT_WIDTH, BELOW_MENU_MIN+LIST_TEXT_HEIGHT); +#endif const char * const ptr_text( "> " ); u32 ptr_text_width( mpContext->GetTextWidth( ptr_text ) ); @@ -483,8 +474,10 @@ void IRomSelectorComponent::RenderRomList() y += line_height; } +#ifdef DAEDALUS_PSP // Restore scissoring sceGuScissor(0,0, 480,272); +#endif } void IRomSelectorComponent::RenderCategoryList() @@ -769,7 +762,7 @@ void IRomSelectorComponent::Update( float elapsed_time, const v2 & stick, u32 ol if( !mRomsList[ mCurrentSelection ]->mSettings.Preview.empty() ) { - IO::Filename preview_filename; + IO::Filename preview_filename; IO::Path::Combine( preview_filename, gPreviewDirectory, mRomsList[ mCurrentSelection ]->mSettings.Preview.c_str() ); mpPreviewTexture = CNativeTexture::CreateFromPng( preview_filename, TexFmt_8888 ); diff --git a/Source/UI/RomSelectorComponent.h b/Source/UI/RomSelectorComponent.h index b6198d477..96e1c478a 100644 --- a/Source/UI/RomSelectorComponent.h +++ b/Source/UI/RomSelectorComponent.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SYSPSP_UI_ROMSELECTORCOMPONENT_H_ #define SYSPSP_UI_ROMSELECTORCOMPONENT_H_ -#include "SysPSP/UI/UIComponent.h" -#include "SysPSP/Utility/Functor.h" +#include "UIComponent.h" +#include "Utility/Functor.h" class CRomSelectorComponent : public CUIComponent { diff --git a/Source/UI/SavestateSelectorComponent.cpp b/Source/UI/SavestateSelectorComponent.cpp index ba9d4134e..e5ca0925b 100644 --- a/Source/UI/SavestateSelectorComponent.cpp +++ b/Source/UI/SavestateSelectorComponent.cpp @@ -22,24 +22,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include - -#include -#include +#include +#include #include "Core/ROM.h" #include "Interface/SaveState.h" #include "Graphics/NativeTexture.h" #include "Math/Vector2.h" -#include "SysPSP/Graphics/DrawText.h" -#include "SysPSP/UI/UICommand.h" -#include "SysPSP/UI/UIContext.h" -#include "SysPSP/UI/UIElement.h" -#include "SysPSP/UI/UIScreen.h" -#include "SysPSP/UI/PSPMenu.h" -#include "SysPSP/UI/SavestateSelectorComponent.h" +#include "DrawTextUtilities.h" +#include "UICommand.h" +#include "UIContext.h" +#include "UIElement.h" +#include "UIScreen.h" +#include "PSPMenu.h" +#include "SavestateSelectorComponent.h" #include "System/IO.h" #include "Utility/Stream.h" -#include "SysPSP/Utility/Translate.h" +#include "Utility/Translate.h" class ISavestateSelectorComponent : public CSavestateSelectorComponent @@ -213,7 +212,6 @@ void ISavestateSelectorComponent::LoadFolders(){ void ISavestateSelectorComponent::LoadSlots(){ const char * description_text( mAccessType == AT_SAVING ? "Select the slot in which to save [X:save O:back]" : "Select the slot from which to load [X:load O:back []:delete]" ); - SceIoStat file_stat; char date_string[30]; // We're using the same vector for directory names and slots, so we have to clear it mElements.Clear(); @@ -232,9 +230,22 @@ void ISavestateSelectorComponent::LoadSlots(){ CUIElement *element; if( !rom_id.Empty() && CRomSettingsDB::Get()->GetSettings( rom_id, &settings ) ) { - // IO::File::Stat(filename_ss, &file_stat); - sceIoGetstat ( filename_ss, &file_stat ); - snprintf(date_string, sizeof(date_string), "%02d/%02d/%d %02d:%02d:%02d", file_stat.sce_st_ctime.month, file_stat.sce_st_ctime.day, file_stat.sce_st_ctime.year, file_stat.sce_st_ctime.hour, file_stat.sce_st_ctime.minute, file_stat.sce_st_ctime.second); // settings.GameName.c_str(); + // Get the last write time of the file + auto last_write_time = std::filesystem::last_write_time(filename_ss); + + // Convert the time duration to a system_clock::time_point + std::chrono::system_clock::time_point time_point = + std::chrono::time_point(std::chrono::duration_cast(last_write_time.time_since_epoch())); + + // Convert the time_point to a time_t to use with std::localtime + std::time_t tt = std::chrono::system_clock::to_time_t(time_point); + + // Convert the time_t to a local time and format it + std::tm* timeinfo = std::localtime(&tt); + + // Format the date string + std::strftime(date_string, sizeof(date_string), "%m/%d/%Y %H:%M:%S", timeinfo); + str << date_string; mSlotEmpty[ i ] = false; } diff --git a/Source/UI/SavestateSelectorComponent.h b/Source/UI/SavestateSelectorComponent.h index 5c1d20516..0c958a22d 100644 --- a/Source/UI/SavestateSelectorComponent.h +++ b/Source/UI/SavestateSelectorComponent.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SYSPSP_UI_SAVESTATESELECTORCOMPONENT_H_ #define SYSPSP_UI_SAVESTATESELECTORCOMPONENT_H_ -#include "SysPSP/UI/UIComponent.h" -#include "SysPSP/Utility/Functor.h" +#include "UIComponent.h" +#include "Utility/Functor.h" class CSavestateSelectorComponent : public CUIComponent { diff --git a/Source/UI/SelectedRomComponent.cpp b/Source/UI/SelectedRomComponent.cpp index cb177c7da..59518775e 100644 --- a/Source/UI/SelectedRomComponent.cpp +++ b/Source/UI/SelectedRomComponent.cpp @@ -23,26 +23,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/ROM.h" #include "Graphics/ColourValue.h" #include "Input/InputManager.h" -#include "SysPSP/Graphics/DrawText.h" -#include "SysPSP/UI/AdvancedOptionsScreen.h" -#include "SysPSP/UI/CheatOptionsScreen.h" -#include "SysPSP/UI/PSPMenu.h" -#include "SysPSP/UI/RomPreferencesScreen.h" -#include "SysPSP/UI/SelectedRomComponent.h" -#include "SysPSP/UI/UIContext.h" -#include "SysPSP/UI/UIScreen.h" -#include "SysPSP/UI/UISetting.h" -#include "SysPSP/UI/UICommand.h" -#include "SysPSP/UI/UISpacer.h" - - - - - - -#include -#include - +#include "DrawTextUtilities.h" +#include "AdvancedOptionsScreen.h" +#include "CheatOptionsScreen.h" +#include "PSPMenu.h" +#include "RomPreferencesScreen.h" +#include "SelectedRomComponent.h" +#include "UIContext.h" +#include "UIScreen.h" +#include "UISetting.h" +#include "UICommand.h" +#include "UISpacer.h" // diff --git a/Source/UI/SelectedRomComponent.h b/Source/UI/SelectedRomComponent.h index ac96bb42e..da085179d 100644 --- a/Source/UI/SelectedRomComponent.h +++ b/Source/UI/SelectedRomComponent.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SYSPSP_UI_SELECTEDROMCOMPONENT_H_ #define SYSPSP_UI_SELECTEDROMCOMPONENT_H_ -#include "SysPSP/UI/UIComponent.h" -#include "SysPSP/Utility/Functor.h" +#include "UIComponent.h" +#include "Utility/Functor.h" class RomID; diff --git a/Source/UI/SplashScreen.cpp b/Source/UI/SplashScreen.cpp index 2de0d1515..04393e9ab 100644 --- a/Source/UI/SplashScreen.cpp +++ b/Source/UI/SplashScreen.cpp @@ -20,18 +20,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include -#include - #include "Graphics/ColourValue.h" #include "Graphics/GraphicsContext.h" #include "Graphics/NativeTexture.h" #include "Math/Math.h" // VFPU Math -#include "SysPSP/Graphics/DrawText.h" -#include "SysPSP/UI/PSPMenu.h" -#include "SysPSP/UI/SplashScreen.h" -#include "SysPSP/UI/UIContext.h" -#include "SysPSP/UI/UIScreen.h" +#include "DrawTextUtilities.h" +#include "PSPMenu.h" +#include "SplashScreen.h" +#include "UIContext.h" +#include "UIScreen.h" #include "Interface/Preferences.h" diff --git a/Source/UI/UICommand.cpp b/Source/UI/UICommand.cpp index 65f5bf056..0d3773e27 100644 --- a/Source/UI/UICommand.cpp +++ b/Source/UI/UICommand.cpp @@ -19,11 +19,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "SysPSP/Graphics/DrawText.h" -#include "SysPSP/UI/UICommand.h" -#include "SysPSP/UI/UIContext.h" - - +#include "DrawTextUtilities.h" +#include "UICommand.h" +#include "UIContext.h" u32 CUICommand::GetHeight( CUIContext * context ) const diff --git a/Source/UI/UICommand.h b/Source/UI/UICommand.h index 5f09cf699..7cb2cf970 100644 --- a/Source/UI/UICommand.h +++ b/Source/UI/UICommand.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SYSPSP_UI_UICOMMAND_H_ #define SYSPSP_UI_UICOMMAND_H_ -#include "SysPSP/UI/UIElement.h" -#include "SysPSP/Utility/Functor.h" +#include "UIElement.h" +#include "Utility/Functor.h" #include diff --git a/Source/UI/UIComponent.cpp b/Source/UI/UIComponent.cpp index bf595dc24..81dafece7 100644 --- a/Source/UI/UIComponent.cpp +++ b/Source/UI/UIComponent.cpp @@ -19,12 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "SysPSP/UI/PSPMenu.h" +#include "PSPMenu.h" -#include "SysPSP/UI/UIComponent.h" -#include "SysPSP/UI/UIContext.h" +#include "UIComponent.h" +#include "UIContext.h" -#include "SysPSP/Graphics/DrawText.h" +#include "DrawTextUtilities.h" CUIComponent::CUIComponent( CUIContext * p_context ) : mpContext( p_context ) diff --git a/Source/UI/UIContext.h b/Source/UI/UIContext.h index ed18aa13e..0c9cdcff0 100644 --- a/Source/UI/UIContext.h +++ b/Source/UI/UIContext.h @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define SYSPSP_UI_UICONTEXT_H_ #include "Graphics/ColourValue.h" -#include "SysPSP/UI/UIAlignment.h" +#include "UIAlignment.h" #include "Interface/Preferences.h" class CNativeTexture; @@ -105,4 +105,32 @@ class CUIContext virtual u32 GetTextWidth( const char * text ) const = 0; }; +//############################################### Emulate PSP API for now ################################ +#ifdef DAEDALUS_PSP + #include + #include +#else + #define PSP_CTRL_DOWN 0x01 + #define PSP_CTRL_UP 0x02 + #define PSP_CTRL_LEFT 0x04 + #define PSP_CTRL_RIGHT 0x08 + #define PSP_CTRL_TRIANGLE 0x10 + #define PSP_CTRL_CIRCLE 0x20 + #define PSP_CTRL_SELECT 0x40 + #define PSP_CTRL_CROSS 0x80 + #define PSP_CTRL_START 0x100 + #define PSP_CTRL_LTRIGGER 0x200 + #define PSP_CTRL_RTRIGGER 0x400 + #define PSP_CTRL_SQUARE 0x800 + + struct SceCtrlData { + u16 Lx, Ly; + u16 Buttons; + }; + + void sceCtrlPeekBufferPositive(struct SceCtrlData*, int n); + void sceKernelExitGame(); +#endif +//########################################################################################################## + #endif // SYSPSP_UI_UICONTEXT_H_ diff --git a/Source/UI/UIElement.cpp b/Source/UI/UIElement.cpp index f2f65f85a..620637ec5 100644 --- a/Source/UI/UIElement.cpp +++ b/Source/UI/UIElement.cpp @@ -19,9 +19,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "SysPSP/UI/UIElement.h" +#include "UIElement.h" -#include "SysPSP/UI/UIContext.h" +#include "UIContext.h" CUIElement::~CUIElement() {} diff --git a/Source/UI/UIElement.h b/Source/UI/UIElement.h index f6f433629..25a0b152b 100644 --- a/Source/UI/UIElement.h +++ b/Source/UI/UIElement.h @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "SysPSP/UI/UIAlignment.h" +#include "UIAlignment.h" class CUIContext; class c32; diff --git a/Source/UI/UIScreen.cpp b/Source/UI/UIScreen.cpp index 56e230373..2cfe1d973 100644 --- a/Source/UI/UIScreen.cpp +++ b/Source/UI/UIScreen.cpp @@ -16,24 +16,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#include - - #include "Base/Types.h" - #include "Graphics/GraphicsContext.h" #include "Math/Vector2.h" -#include "SysPSP/UI/UIContext.h" -#include "SysPSP/UI/UIScreen.h" +#include "UIContext.h" +#include "UIScreen.h" #include "Utility/Timer.h" - - - - CUIScreen::CUIScreen( CUIContext * p_context ) : mpContext( p_context ) {} diff --git a/Source/UI/UISetting.cpp b/Source/UI/UISetting.cpp index 636ec9960..e51d623bd 100644 --- a/Source/UI/UISetting.cpp +++ b/Source/UI/UISetting.cpp @@ -20,9 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "SysPSP/Graphics/DrawText.h" -#include "SysPSP/UI/UISetting.h" -#include "SysPSP/UI/UIContext.h" +#include "DrawTextUtilities.h" +#include "UISetting.h" +#include "UIContext.h" CUISetting::CUISetting( const char * name, const char * description ) diff --git a/Source/UI/UISetting.h b/Source/UI/UISetting.h index 950c31bb6..83574af03 100644 --- a/Source/UI/UISetting.h +++ b/Source/UI/UISetting.h @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SYSPSP_UI_UISETTING_H_ #define SYSPSP_UI_UISETTING_H_ -#include "SysPSP/UI/UIElement.h" +#include "UIElement.h" class CUISetting : public CUIElement diff --git a/Source/UI/UISpacer.h b/Source/UI/UISpacer.h index 3305981a9..10c8b6d84 100644 --- a/Source/UI/UISpacer.h +++ b/Source/UI/UISpacer.h @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SYSPSP_UI_UISPACER_H_ #define SYSPSP_UI_UISPACER_H_ -#include "SysPSP/UI/UIElement.h" +#include "UIElement.h" class CUISpacer : public CUIElement diff --git a/Source/Utility/CMakeLists.txt b/Source/Utility/CMakeLists.txt index ad1d67274..54a121662 100644 --- a/Source/Utility/CMakeLists.txt +++ b/Source/Utility/CMakeLists.txt @@ -6,7 +6,8 @@ add_library(Utility OBJECT MemoryHeap.cpp Profiler.cpp Stream.cpp - StringUtil.cpp + StringUtil.cpp + Translate.cpp Timer.cpp ) diff --git a/Source/SysPSP/Utility/Functor.h b/Source/Utility/Functor.h similarity index 100% rename from Source/SysPSP/Utility/Functor.h rename to Source/Utility/Functor.h diff --git a/Source/SysPSP/Utility/Translate.cpp b/Source/Utility/Translate.cpp similarity index 95% rename from Source/SysPSP/Utility/Translate.cpp rename to Source/Utility/Translate.cpp index 7a44d5cae..a16c70dc0 100644 --- a/Source/SysPSP/Utility/Translate.cpp +++ b/Source/Utility/Translate.cpp @@ -27,8 +27,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "System/IO.h" #include "Utility/StringUtil.h" -#include "SysPSP/Utility/Translate.h" -#include "SysPSP/Utility/VolatileMem.h" +#include "Utility/Translate.h" +#include "Utility/VolatileMem.h" diff --git a/Source/SysPSP/Utility/Translate.h b/Source/Utility/Translate.h similarity index 100% rename from Source/SysPSP/Utility/Translate.h rename to Source/Utility/Translate.h diff --git a/Source/SysPSP/Utility/VolatileMem.h b/Source/Utility/VolatileMem.h similarity index 100% rename from Source/SysPSP/Utility/VolatileMem.h rename to Source/Utility/VolatileMem.h From c580dfc327dd2ba6f7f0594d00478ee71f058156 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Tue, 5 Dec 2023 14:47:01 +0800 Subject: [PATCH 03/54] Get Code compiled --- Source/SysGL/Graphics/CMakeLists.txt | 2 +- Source/SysGL/Graphics/GraphicsContextGL.cpp | 25 -- Source/SysGL/Graphics/UIContext.cpp | 394 ++++++++++++++++++ Source/SysGL/HLEGraphics/GraphicsPluginGL.cpp | 1 + Source/SysGL/Input/InputManagerGL.cpp | 15 + Source/SysPSP/CMakeLists.txt | 2 +- Source/SysPSP/Graphics/DrawText.cpp | 8 - Source/SysPSP/Graphics/DrawText.h | 1 - Source/SysPSP/UIContext.cpp | 7 +- Source/UI/GlobalSettingsComponent.cpp | 9 +- 10 files changed, 424 insertions(+), 40 deletions(-) create mode 100644 Source/SysGL/Graphics/UIContext.cpp diff --git a/Source/SysGL/Graphics/CMakeLists.txt b/Source/SysGL/Graphics/CMakeLists.txt index 50a1441ab..bc0dec4f2 100644 --- a/Source/SysGL/Graphics/CMakeLists.txt +++ b/Source/SysGL/Graphics/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(Graphics_GL OBJECT GraphicsContextGL.cpp NativeTextureGL.cpp) +add_library(Graphics_GL OBJECT GraphicsContextGL.cpp NativeTextureGL.cpp UIContext.cpp) list(APPEND include_dirs ${PROJECT_SOURCE_DIR}/Source/third_party/imgui) diff --git a/Source/SysGL/Graphics/GraphicsContextGL.cpp b/Source/SysGL/Graphics/GraphicsContextGL.cpp index aa59cf888..6a52bd69e 100644 --- a/Source/SysGL/Graphics/GraphicsContextGL.cpp +++ b/Source/SysGL/Graphics/GraphicsContextGL.cpp @@ -9,11 +9,6 @@ #include "Graphics/GraphicsContext.h" #include "Graphics/ColourValue.h" -#include "third_party/imgui/imgui.h" -#include "third_party/imgui/backends/imgui_impl_sdl.h" -#include "third_party/imgui/backends/imgui_impl_opengl3.h" - - static u32 SCR_WIDTH = 640; static u32 SCR_HEIGHT = 480; @@ -117,26 +112,6 @@ bool GraphicsContextGL::Initialise() SDL_GL_SetSwapInterval(1); - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplSDL2_InitForOpenGL(gWindow, gContext); - ImGui_ImplOpenGL3_Init(glsl_version); - - - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - - GLenum err = glewInit(); if (err != GLEW_OK || !GLEW_VERSION_3_2) { diff --git a/Source/SysGL/Graphics/UIContext.cpp b/Source/SysGL/Graphics/UIContext.cpp new file mode 100644 index 000000000..c1153f85a --- /dev/null +++ b/Source/SysGL/Graphics/UIContext.cpp @@ -0,0 +1,394 @@ +/* +Copyright (C) 2006 StrmnNrmn + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + + +#include "Base/Types.h" + + +#include "SysGL/GL.h" + +#include "UI/ColourPulser.h" +#include "Math/Vector2.h" +#include "Math/Vector3.h" +#include "Math/Matrix4x4.h" +#include "Graphics/GraphicsContext.h" +#include "Graphics/NativeTexture.h" +#include "SysPSP/Graphics/DrawText.h" +#include "UI/UIContext.h" +#include "UI/DrawTextUtilities.h" +#include "Utility/Translate.h" + +#define GL_TRUE 1 +#define GL_FALSE 0 + +namespace +{ +const u32 BACKGROUND_WIDTH = 480; +const u32 BACKGROUND_HEIGHT = 272; + +const u32 MS_PER_COLOUR_CYCLE = 1200; + +const c32 COLOUR_SELECTION_DIM = c32( 0xe0, 0xe0, 0x80 ); +const c32 COLOUR_SELECTION_BRIGHT = c32( 0xff, 0xff, 0x80 ); +} + + +class IUIContext : public CUIContext +{ + public: + + IUIContext(); + ~IUIContext(); + + virtual void BeginRender(); + virtual void EndRender(); + + virtual c32 GetBackgroundColour() const { return mBackgroundColour; } + virtual void SetBackgroundColour( c32 colour ) { mBackgroundColour = colour; } + + virtual u32 GetScreenWidth() const { return BACKGROUND_WIDTH; } + virtual u32 GetScreenHeight() const { return BACKGROUND_HEIGHT; } + + virtual c32 GetDefaultTextColour() const { return DrawTextUtilities::TextWhite; } + virtual c32 GetSelectedTextColour() const { return mColourPulser.GetCurrentColour(); } + + virtual void Update( float elapsed_time ); + + virtual void RenderTexture( const std::shared_ptr texture, const v2 & tl, const v2 & wh, c32 colour ); + virtual void RenderTexture( const std::shared_ptr texture, s32 x, s32 y, c32 colour ); + virtual void ClearBackground( c32 colour ); + virtual void DrawRect( s32 x, s32 y, u32 w, u32 h, c32 colour ); + virtual void DrawLine( s32 x0, s32 y0, s32 x1, s32 y1, c32 colour ); + + virtual void SetFontStyle( EFontStyle font_style ); + + virtual u32 DrawText( s32 x, s32 y, const char * text, u32 length, c32 colour ); + virtual u32 DrawText( s32 x, s32 y, const char * text, u32 length, c32 colour, c32 drop_colour ); + virtual u32 DrawTextScale( s32 x, s32 y, float scale, const char * text, u32 length, c32 colour ); + virtual u32 DrawTextScale( s32 x, s32 y, float scale, const char * text, u32 length, c32 colour, c32 drop_colour ); + virtual u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour ); + virtual u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour, c32 drop_colour ); + virtual s32 DrawTextArea( s32 left, s32 top, u32 width, u32 height, const char * text, c32 colour, EVerticalAlign vertical_align ); + + virtual u32 GetFontHeight() const; + virtual u32 GetTextWidth( const char * text ) const; + + private: + s32 AlignText( s32 min_x, s32 max_x, const char * p_str, u32 length, EAlignType align_type ); + + private: + CDrawText::EFont mCurrentFont; + CColourPulser mColourPulser; + c32 mBackgroundColour; +}; + +CUIContext::~CUIContext() {} +CUIContext * CUIContext::Create() { return new IUIContext; } + + + +IUIContext::IUIContext() +: mCurrentFont( CDrawText::F_REGULAR ) +, mColourPulser( COLOUR_SELECTION_DIM, COLOUR_SELECTION_BRIGHT, MS_PER_COLOUR_CYCLE ) +, mBackgroundColour( 0,0,0 ) +{} + + +IUIContext::~IUIContext() +{ + // Clear everything to black + for( u32 i = 0; i < 2; ++i ) + { + CGraphicsContext::Get()->BeginFrame(); + CGraphicsContext::Get()->ClearToBlack(); + CGraphicsContext::Get()->EndFrame(); + CGraphicsContext::Get()->UpdateFrame( false ); + } +} + + +void IUIContext::Update( float elapsed_time ) +{ + s32 elapsed_ms = s32( 1000.0f * elapsed_time ); + mColourPulser.Update( elapsed_ms ); +} + + +void IUIContext::RenderTexture( const std::shared_ptr texture, s32 x, s32 y, c32 colour ) +{ + if(texture == NULL) + return; + + v2 tl = v2( f32( x ), f32( y ) ); + v2 wh = v2( f32( texture->GetWidth() ), f32( texture->GetHeight() ) ); + + RenderTexture( texture, tl, wh, colour ); +} + +void IUIContext::RenderTexture( const std::shared_ptr texture, const v2 & tl, const v2 & wh, c32 colour ) +{ + if(texture == NULL) + return; + + // u32 num_verts( 2 ); + // BackgroundTextureVtx* p_verts = (BackgroundTextureVtx*)sceGuGetMemory(num_verts*sizeof(BackgroundTextureVtx)); + + // sceGuDisable(GU_DEPTH_TEST); + // sceGuDepthMask( GL_TRUE ); // GL_TRUE to disable z-writes + // sceGuShadeModel( GU_FLAT ); + + // sceGuTexFilter(GU_LINEAR,GU_LINEAR); + // sceGuTexScale(1.0f,1.0f); + // sceGuTexOffset(0.0f,0.0f); + + // u32 width( texture->GetWidth() ); + // u32 height( texture->GetHeight() ); + + // texture->InstallTexture(); + + // sceGuDisable(GU_ALPHA_TEST); + // sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); + // sceGuEnable(GU_BLEND); + // sceGuTexFunc(GU_TFX_MODULATE,GU_TCC_RGBA); + + // sceGuSetMatrix( GU_PROJECTION, reinterpret_cast< const ScePspFMatrix4 * >( &gMatrixIdentity ) ); + + // v2 tex_uv0( (float)0, (float)0 ); + // v2 tex_uv1( (float)width, (float)height ); + + // p_verts[0].pos = v3( tl.x, tl.y, 0.0f ); + // p_verts[0].t0 = v2( 0.0f, 0.0f ); + // p_verts[0].colour = colour; + + // p_verts[1].pos = v3( tl.x + wh.x, tl.y + wh.y, 0.0f ); + // p_verts[1].t0 = v2( (float)width, (float)height ); + // p_verts[1].colour = colour; + + // sceGuDrawArray(GU_SPRITES,BackgroundTextureVtx::Flags|GU_TRANSFORM_2D,num_verts,NULL,p_verts); +} + + +void IUIContext::ClearBackground( c32 colour ) +{ + CGraphicsContext::Get()->ClearColBufferAndDepth( colour ); +} + + +void IUIContext::DrawRect( s32 x, s32 y, u32 w, u32 h, c32 colour ) +{ + // u32 num_verts( 2 ); + // BackgroundColourVtx* p_verts = (BackgroundColourVtx*)sceGuGetMemory(num_verts*sizeof(BackgroundColourVtx)); + + // sceGuDisable(GU_DEPTH_TEST); + // sceGuDepthMask( GL_TRUE ); // GL_TRUE to disable z-writes + // sceGuShadeModel( GU_FLAT ); + + // sceGuDisable(GU_TEXTURE_2D); + + // sceGuDisable(GU_ALPHA_TEST); + // sceGuDisable(GU_BLEND); + + // sceGuSetMatrix( GU_PROJECTION, reinterpret_cast< const ScePspFMatrix4 * >( &gMatrixIdentity ) ); + + // p_verts[0].pos = v3( float( x ), float( y ), 0.0f ); + // p_verts[0].colour = colour; + + // p_verts[1].pos = v3( float( x + w ), float( y + h ), 0.0f ); + // p_verts[1].colour = colour; + + // sceGuDrawArray(GU_SPRITES,BackgroundColourVtx::Flags|GU_TRANSFORM_2D,num_verts,NULL,p_verts); + +} + +void IUIContext::DrawLine( s32 x0, s32 y0, s32 x1, s32 y1, c32 colour ) +{ + // u32 num_verts( 2 ); + // BackgroundColourVtx* p_verts = (BackgroundColourVtx*)sceGuGetMemory(num_verts*sizeof(BackgroundColourVtx)); + + // sceGuDisable(GU_DEPTH_TEST); + // sceGuDepthMask( GL_TRUE ); // GL_TRUE to disable z-writes + // sceGuShadeModel( GU_FLAT ); + + // sceGuDisable(GU_TEXTURE_2D); + + // sceGuDisable(GU_ALPHA_TEST); + // sceGuDisable(GU_BLEND); + + // sceGuSetMatrix( GU_PROJECTION, reinterpret_cast< const ScePspFMatrix4 * >( &gMatrixIdentity ) ); + + // p_verts[0].pos = v3( float( x0 ), float( y0 ), 0.0f ); + // p_verts[0].colour = colour; + + // p_verts[1].pos = v3( float( x1 ), float( y1 ), 0.0f ); + // p_verts[1].colour = colour; + + // sceGuDrawArray(GU_LINES,BackgroundColourVtx::Flags|GU_TRANSFORM_2D,num_verts,NULL,p_verts); + +} + + +void IUIContext::SetFontStyle( EFontStyle font_style ) +{ +// switch( font_style ) +// { +// case FS_REGULAR: mCurrentFont = CDrawText::F_REGULAR; return; +// case FS_HEADING: mCurrentFont = CDrawText::F_LARGE_BOLD; return; +// } +// #ifdef DAEDALUS_DEBUG_CONSOLE +// DAEDALUS_ERROR( "Unhandled font style" ); +// #endif +} + +u32 IUIContext::GetFontHeight() const +{ + // return CDrawText::GetFontHeight( mCurrentFont ); +} + +u32 IUIContext::GetTextWidth( const char * text ) const +{ + // return CDrawText::GetTextWidth( mCurrentFont, text ); +} + +s32 IUIContext::AlignText( s32 min_x, s32 max_x, const char * p_str, u32 length, EAlignType align_type ) +{ + s32 x = 0; + + // switch( align_type ) + // { + // case AT_LEFT: + // x = min_x; + // break; + + // case AT_CENTRE: + // x = min_x + ((max_x - min_x) - CDrawText::GetTextWidth( mCurrentFont, p_str, length )) / 2; + // break; + + // case AT_RIGHT: + // x = max_x - CDrawText::GetTextWidth( mCurrentFont, p_str, length ); + // break; + + // default: + // #ifdef DAEDALUS_DEBUG_CONSOLE + // DAEDALUS_ERROR( "Unhandled alignment type" ); + // #endif + // x = min_x; + // break; + // } + + return x; +} + +u32 IUIContext::DrawText( s32 x, s32 y, const char * text, u32 length, c32 colour ) +{ + // return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour ); +} + + +u32 IUIContext::DrawText( s32 x, s32 y, const char * text, u32 length, c32 colour, c32 drop_colour ) +{ + // return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour, drop_colour ); +} + +u32 IUIContext::DrawTextScale( s32 x, s32 y, float scale, const char * text, u32 length, c32 colour ) +{ + // return CDrawText::Render( mCurrentFont, x, y, scale, text, length, colour ); +} + +u32 IUIContext::DrawTextScale( s32 x, s32 y, float scale, const char * text, u32 length, c32 colour, c32 drop_colour ) +{ + // return CDrawText::Render( mCurrentFont, x, y, scale, text, length, colour, drop_colour ); +} + +u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour ) +{ + // s32 x( AlignText( min_x, max_x, text, length, align_type ) ); + + // return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour ); +} + +u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour, c32 drop_colour ) +{ + // s32 x( AlignText( min_x, max_x, text, length, align_type ) ); + + // return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour, drop_colour ); +} + + +namespace +{ + s32 VerticalAlign( EVerticalAlign vertical_align, s32 top, u32 height, u32 text_height ) + { + switch( vertical_align ) + { + case VA_TOP: return top; + case VA_BOTTOM: return top + height - text_height; + } + #ifdef DAEDALUS_DEBUG_CONSOLE + DAEDALUS_ERROR( "Unhandled vertical align" ); + #endif + return top; + } +} + + +s32 IUIContext::DrawTextArea( s32 left, s32 top, u32 width, u32 height, const char * text, c32 colour, EVerticalAlign vertical_align ) +{ + // const u32 font_height( CDrawText::GetFontHeight( mCurrentFont ) ); + // u32 length = strlen( text ); + // std::vector lengths; + // bool match = false; + // DrawTextUtilities::WrapText( mCurrentFont, width, Translate_Strings( text, length ), length, lengths, match ); + + // s32 x( left ); + // s32 y( VerticalAlign( vertical_align, top, height, lengths.size() * font_height ) ); + + // // Our built-in auto-linebreaking can't handle unicodes. + // // Fall back to use intrafont's manual linebreaking feature + // if( match ) + // { + // y += font_height; + // DrawTextScale( x, y, 0.8f, text, length, colour ); + // y += 2; + // return y - top; + // } + + // for( u32 i = 0; i < lengths.size(); ++i ) + // { + // y += font_height; + // DrawTextScale( x, y, 0.8f, text, lengths[ i ], colour ); + // y += 2; + // text += lengths[ i ]; + // } + + // return y - top; +} + +// + +void IUIContext::BeginRender() +{ + CGraphicsContext::Get()->BeginFrame(); +} + + +void IUIContext::EndRender() +{ + CGraphicsContext::Get()->EndFrame(); + CGraphicsContext::Get()->UpdateFrame( true ); +} diff --git a/Source/SysGL/HLEGraphics/GraphicsPluginGL.cpp b/Source/SysGL/HLEGraphics/GraphicsPluginGL.cpp index a694ea06e..76bb6e5f4 100644 --- a/Source/SysGL/HLEGraphics/GraphicsPluginGL.cpp +++ b/Source/SysGL/HLEGraphics/GraphicsPluginGL.cpp @@ -30,6 +30,7 @@ extern SDL_Window * gWindow; EFrameskipValue gFrameskipValue = FV_DISABLED; u32 gVISyncRate = 1500; bool gTakeScreenshot = false; +bool gTakeScreenshotSS = false; namespace { diff --git a/Source/SysGL/Input/InputManagerGL.cpp b/Source/SysGL/Input/InputManagerGL.cpp index c79643fa5..ac10c299d 100644 --- a/Source/SysGL/Input/InputManagerGL.cpp +++ b/Source/SysGL/Input/InputManagerGL.cpp @@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/CPU.h" #include "SysGL/GL.h" +#include "UI/UIContext.h" // for Input structures + //Windows Xinput support #ifdef DAEDALUS_WIN32 #include @@ -364,3 +366,16 @@ u32 IInputManager::GetConfigurationFromName( const char * name ) const // Return the default controller config return 0; } + +void sceCtrlPeekBufferPositive(SceCtrlData *data, int count){ + +} + +v2 ApplyDeadzone( const v2 & in, f32 min_deadzone, f32 max_deadzone ) +{ + return in; +} + +void sceKernelExitGame() { + // todo +} \ No newline at end of file diff --git a/Source/SysPSP/CMakeLists.txt b/Source/SysPSP/CMakeLists.txt index 56dae7ca7..c650c9fa3 100644 --- a/Source/SysPSP/CMakeLists.txt +++ b/Source/SysPSP/CMakeLists.txt @@ -23,4 +23,4 @@ set(daed_libs ${daed_libs} PARENT_SCOPE) list(APPEND sys_libraries intrafont pspkubridge pspfpu pspdebug) set(sys_libraries ${sys_libraries} PARENT_SCOPE) -set(plat_main SysPSP/main.cpp PARENT_SCOPE) +set(plat_main SysPSP/main.cpp SysPSP/UIContext.cpp PARENT_SCOPE) diff --git a/Source/SysPSP/Graphics/DrawText.cpp b/Source/SysPSP/Graphics/DrawText.cpp index 205100eb8..b1d5b66fe 100644 --- a/Source/SysPSP/Graphics/DrawText.cpp +++ b/Source/SysPSP/Graphics/DrawText.cpp @@ -72,14 +72,6 @@ void CDrawText::Destroy() intraFontShutdown(); } -//************************************************************************************* -// -//************************************************************************************* -const char *CDrawText::Translate(const char *dest, u32 &length) -{ - return Translate_Strings(dest, length); -} - //************************************************************************************* // //************************************************************************************* diff --git a/Source/SysPSP/Graphics/DrawText.h b/Source/SysPSP/Graphics/DrawText.h index 4cfbae4cc..1632f52ca 100644 --- a/Source/SysPSP/Graphics/DrawText.h +++ b/Source/SysPSP/Graphics/DrawText.h @@ -42,7 +42,6 @@ class CDrawText static u32 Render( EFont font, s32 x, s32 y, float scale, const char * p_str, u32 length, c32 colour ); static u32 Render( EFont font, s32 x, s32 y, float scale, const char * p_str, u32 length, c32 colour, c32 drop_colour ); static s32 GetTextWidth( EFont font, const char * p_str, u32 length ); - static const char * Translate( const char * dest, u32 & length ); // Versions of above functions which implicitly calc string length static u32 Render( EFont font, s32 x, s32 y, float scale, const char * p_str, c32 colour ) { return Render( font, x, y, scale, p_str, strlen( p_str ), colour ); } diff --git a/Source/SysPSP/UIContext.cpp b/Source/SysPSP/UIContext.cpp index 47e52b503..3fda7e4ee 100644 --- a/Source/SysPSP/UIContext.cpp +++ b/Source/SysPSP/UIContext.cpp @@ -26,14 +26,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include "ColourPulser.h" +#include "UI/ColourPulser.h" #include "Math/Vector2.h" #include "Math/Vector3.h" #include "Math/Matrix4x4.h" #include "Graphics/GraphicsContext.h" #include "Graphics/NativeTexture.h" #include "SysPSP/Graphics/DrawText.h" -#include "UIContext.h" +#include "UI/UIContext.h" +#include "UI/DrawTextUtilities.h" #define GL_TRUE 1 @@ -387,7 +388,7 @@ s32 IUIContext::DrawTextArea( s32 left, s32 top, u32 width, u32 height, const c u32 length = strlen( text ); std::vector lengths; bool match = false; - DrawTextUtilities::WrapText( mCurrentFont, width, CDrawText::Translate( text, length ), length, lengths, match ); + DrawTextUtilities::WrapText( mCurrentFont, width, Translate_Strings( text, length ), length, lengths, match ); s32 x( left ); s32 y( VerticalAlign( vertical_align, top, height, lengths.size() * font_height ) ); diff --git a/Source/UI/GlobalSettingsComponent.cpp b/Source/UI/GlobalSettingsComponent.cpp index 4bc42cec5..95b684711 100644 --- a/Source/UI/GlobalSettingsComponent.cpp +++ b/Source/UI/GlobalSettingsComponent.cpp @@ -330,6 +330,7 @@ IGlobalSettingsComponent::IGlobalSettingsComponent( CUIContext * p_context ) mElements.Add( new CInfoSetting( "Display Info", "Whether to show additional info while the rom is running. Some modes are only available in DEBUG mode") ); mElements.Add( new CViewPortSetting( "Viewport Size", "The size of the viewport on the PSP." ) ); +#if DEADALUS_PSP if (HAVE_DVE && PSP_TV_CABLE > 0) { mElements.Add( new CBoolSetting( &gGlobalPreferences.TVEnable, "TV Output", "Whether to direct the video to the TV out.", "Yes", "No" ) ); @@ -340,10 +341,16 @@ IGlobalSettingsComponent::IGlobalSettingsComponent( CUIContext * p_context ) { gGlobalPreferences.TVEnable = false; } +#endif mElements.Add( new CBoolSetting( &gGlobalPreferences.ForceLinearFilter,"Force Linear Filter", "Enable to force linear filter, this can improve the look of textures", "Yes", "No" ) ); mElements.Add( new CBoolSetting( &gGlobalPreferences.RumblePak,"Controller add-on", "Enable either MemPak or RumblePak.", "RumblePak", "MemPak" ) ); mElements.Add( new CAdjustDeadzoneSetting( mpContext, "Stick Deadzone", "Adjust the size of the deadzone applied to the PSP stick while playing. Press Start/X to edit." ) ); - if (PSP_IS_SLIM) mElements.Add( new CBoolSetting( &gGlobalPreferences.LargeROMBuffer, "ROM Buffering Mode", "File Cache, faster ROM boot but can stutter due to MS reads. ROM Buffer, no stutter but long boot time loading whole ROM into memory. Takes effect only @ ROM boot.", "File Cache", "ROM Buffer" ) ); + +#if DEADALUS_PSP + if (PSP_IS_SLIM) + mElements.Add( new CBoolSetting( &gGlobalPreferences.LargeROMBuffer, "ROM Buffering Mode", "File Cache, faster ROM boot but can stutter due to MS reads. ROM Buffer, no stutter but long boot time loading whole ROM into memory. Takes effect only @ ROM boot.", "File Cache", "ROM Buffer" ) ); +#endif + #ifdef DAEDALUS_DEBUG_DISPLAYLIST mElements.Add( new CBoolSetting( &gGlobalPreferences.HighlightInexactBlendModes, "Highlight Inexact Blend Modes", "Replace inexact blend modes with a placeholder texture.", "Yes", "No" ) ); mElements.Add( new CBoolSetting( &gGlobalPreferences.CustomBlendModes, "Use Custom Blend Modes", "Debugging tool to disable custom blendmodes.", "Yes", "No" ) ); From 7b02681143a7ec42f77fa6ec6ec155973e42c55f Mon Sep 17 00:00:00 2001 From: Howard Su Date: Tue, 5 Dec 2023 22:54:07 +0800 Subject: [PATCH 04/54] Start working on UIContext implementation --- Source/CMakeLists.txt | 6 - Source/SysGL/Graphics/CMakeLists.txt | 2 - Source/SysGL/Graphics/UIContext.cpp | 138 ++++++++---------- Source/SysGL/HLEGraphics/GraphicsPluginGL.cpp | 97 +----------- Source/SysGL/Input/InputManagerGL.cpp | 2 +- Source/SysGL/Interface/UI.cpp | 4 - Source/SysPosix/CMakeLists.txt | 2 +- Source/SysPosix/main.cpp | 21 ++- Source/UI/MainMenuScreen.cpp | 1 + 9 files changed, 85 insertions(+), 188 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index d6d2491b7..9e5795c9a 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -119,11 +119,6 @@ endif() find_package(SDL2 CONFIG REQUIRED) list(APPEND default_libraries "${SDL2_LIBRARIES}") list(APPEND include_dirs "${SDL2_INCLUDE_DIRS}") - - if(DAEDALUS_GL) - list(APPEND include_dirs "${PROJECT_SOURCE_DIR}/Source/third_party/imgui/" ) #This doesn't like being called from another file - endif(DAEDALUS_GL) - endif(DAEDALUS_SDL) # Needed below the options to post process @@ -209,7 +204,6 @@ if(WIN32) if(UNIX) add_subdirectory(SysPosix) add_subdirectory(SysGL) - add_subdirectory(third_party/imgui) elseif(WIN32) ## Probably keep this generic as we'll build this on Linux too? add_subdirectory(SysGL) add_subdirectory(SysW32) diff --git a/Source/SysGL/Graphics/CMakeLists.txt b/Source/SysGL/Graphics/CMakeLists.txt index bc0dec4f2..8b2d5c359 100644 --- a/Source/SysGL/Graphics/CMakeLists.txt +++ b/Source/SysGL/Graphics/CMakeLists.txt @@ -1,7 +1,5 @@ add_library(Graphics_GL OBJECT GraphicsContextGL.cpp NativeTextureGL.cpp UIContext.cpp) - -list(APPEND include_dirs ${PROJECT_SOURCE_DIR}/Source/third_party/imgui) set(include_dirs ${include_dirs} PARENT_SCOPE) list(APPEND daed_libs Graphics_GL) diff --git a/Source/SysGL/Graphics/UIContext.cpp b/Source/SysGL/Graphics/UIContext.cpp index c1153f85a..a8f1da711 100644 --- a/Source/SysGL/Graphics/UIContext.cpp +++ b/Source/SysGL/Graphics/UIContext.cpp @@ -146,41 +146,44 @@ void IUIContext::RenderTexture( const std::shared_ptr texture, c if(texture == NULL) return; - // u32 num_verts( 2 ); - // BackgroundTextureVtx* p_verts = (BackgroundTextureVtx*)sceGuGetMemory(num_verts*sizeof(BackgroundTextureVtx)); - - // sceGuDisable(GU_DEPTH_TEST); - // sceGuDepthMask( GL_TRUE ); // GL_TRUE to disable z-writes - // sceGuShadeModel( GU_FLAT ); - - // sceGuTexFilter(GU_LINEAR,GU_LINEAR); - // sceGuTexScale(1.0f,1.0f); - // sceGuTexOffset(0.0f,0.0f); - - // u32 width( texture->GetWidth() ); - // u32 height( texture->GetHeight() ); - - // texture->InstallTexture(); - - // sceGuDisable(GU_ALPHA_TEST); - // sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); - // sceGuEnable(GU_BLEND); - // sceGuTexFunc(GU_TFX_MODULATE,GU_TCC_RGBA); - - // sceGuSetMatrix( GU_PROJECTION, reinterpret_cast< const ScePspFMatrix4 * >( &gMatrixIdentity ) ); - - // v2 tex_uv0( (float)0, (float)0 ); - // v2 tex_uv1( (float)width, (float)height ); - - // p_verts[0].pos = v3( tl.x, tl.y, 0.0f ); - // p_verts[0].t0 = v2( 0.0f, 0.0f ); - // p_verts[0].colour = colour; - - // p_verts[1].pos = v3( tl.x + wh.x, tl.y + wh.y, 0.0f ); - // p_verts[1].t0 = v2( (float)width, (float)height ); - // p_verts[1].colour = colour; - - // sceGuDrawArray(GU_SPRITES,BackgroundTextureVtx::Flags|GU_TRANSFORM_2D,num_verts,NULL,p_verts); + texture->InstallTexture(); + + // Set up the color for the texture + glColor4b(colour.GetR(), colour.GetG(), colour.GetB(), colour.GetA()); + + // Enable texture mapping + glEnable(GL_TEXTURE_2D); + + // Set texture parameters + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + // Define texture coordinates + float texCoords[] = { + 0.0f, 0.0f, + 1.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f + }; + + // Define vertex coordinates + float vertices[] = { + tl.x, tl.y, + tl.x + wh.x, tl.y, + tl.x + wh.x, tl.y + wh.y, + tl.x, tl.y + wh.y + }; + + // Render the texture + glBegin(GL_QUADS); + for (int i = 0; i < 4; ++i) { + glTexCoord2f(texCoords[i * 2], texCoords[i * 2 + 1]); + glVertex2f(vertices[i * 2], vertices[i * 2 + 1]); + } + glEnd(); + + // Disable texture mapping after rendering + glDisable(GL_TEXTURE_2D); } @@ -192,54 +195,27 @@ void IUIContext::ClearBackground( c32 colour ) void IUIContext::DrawRect( s32 x, s32 y, u32 w, u32 h, c32 colour ) { - // u32 num_verts( 2 ); - // BackgroundColourVtx* p_verts = (BackgroundColourVtx*)sceGuGetMemory(num_verts*sizeof(BackgroundColourVtx)); - - // sceGuDisable(GU_DEPTH_TEST); - // sceGuDepthMask( GL_TRUE ); // GL_TRUE to disable z-writes - // sceGuShadeModel( GU_FLAT ); - - // sceGuDisable(GU_TEXTURE_2D); - - // sceGuDisable(GU_ALPHA_TEST); - // sceGuDisable(GU_BLEND); - - // sceGuSetMatrix( GU_PROJECTION, reinterpret_cast< const ScePspFMatrix4 * >( &gMatrixIdentity ) ); - - // p_verts[0].pos = v3( float( x ), float( y ), 0.0f ); - // p_verts[0].colour = colour; - - // p_verts[1].pos = v3( float( x + w ), float( y + h ), 0.0f ); - // p_verts[1].colour = colour; - - // sceGuDrawArray(GU_SPRITES,BackgroundColourVtx::Flags|GU_TRANSFORM_2D,num_verts,NULL,p_verts); - + // Set up the color for the rectangle + glColor4b(colour.GetR(), colour.GetG(), colour.GetB(), colour.GetA()); + + // Draw the rectangle using OpenGL + glBegin(GL_QUADS); + glVertex2i(x, y); + glVertex2i(x + w, y); + glVertex2i(x + w, y + h); + glVertex2i(x, y + h); + glEnd(); } void IUIContext::DrawLine( s32 x0, s32 y0, s32 x1, s32 y1, c32 colour ) { - // u32 num_verts( 2 ); - // BackgroundColourVtx* p_verts = (BackgroundColourVtx*)sceGuGetMemory(num_verts*sizeof(BackgroundColourVtx)); - - // sceGuDisable(GU_DEPTH_TEST); - // sceGuDepthMask( GL_TRUE ); // GL_TRUE to disable z-writes - // sceGuShadeModel( GU_FLAT ); - - // sceGuDisable(GU_TEXTURE_2D); - - // sceGuDisable(GU_ALPHA_TEST); - // sceGuDisable(GU_BLEND); - - // sceGuSetMatrix( GU_PROJECTION, reinterpret_cast< const ScePspFMatrix4 * >( &gMatrixIdentity ) ); - - // p_verts[0].pos = v3( float( x0 ), float( y0 ), 0.0f ); - // p_verts[0].colour = colour; - - // p_verts[1].pos = v3( float( x1 ), float( y1 ), 0.0f ); - // p_verts[1].colour = colour; - - // sceGuDrawArray(GU_LINES,BackgroundColourVtx::Flags|GU_TRANSFORM_2D,num_verts,NULL,p_verts); + glColor4b(colour.GetR(), colour.GetG(), colour.GetB(), colour.GetA()); + // Draw the line using OpenGL + glBegin(GL_LINES); + glVertex2i(x0, y0); + glVertex2i(x1, y1); + glEnd(); } @@ -297,22 +273,26 @@ s32 IUIContext::AlignText( s32 min_x, s32 max_x, const char * p_str, u32 length u32 IUIContext::DrawText( s32 x, s32 y, const char * text, u32 length, c32 colour ) { // return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour ); + printf("%s\n", text); } u32 IUIContext::DrawText( s32 x, s32 y, const char * text, u32 length, c32 colour, c32 drop_colour ) { // return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour, drop_colour ); + printf("%s\n", text); } u32 IUIContext::DrawTextScale( s32 x, s32 y, float scale, const char * text, u32 length, c32 colour ) { // return CDrawText::Render( mCurrentFont, x, y, scale, text, length, colour ); + printf("%s\n", text); } u32 IUIContext::DrawTextScale( s32 x, s32 y, float scale, const char * text, u32 length, c32 colour, c32 drop_colour ) { // return CDrawText::Render( mCurrentFont, x, y, scale, text, length, colour, drop_colour ); + printf("%s\n", text); } u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour ) @@ -320,6 +300,7 @@ u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 // s32 x( AlignText( min_x, max_x, text, length, align_type ) ); // return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour ); + printf("%s\n", text); } u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour, c32 drop_colour ) @@ -327,6 +308,7 @@ u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 // s32 x( AlignText( min_x, max_x, text, length, align_type ) ); // return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour, drop_colour ); + printf("%s\n", text); } diff --git a/Source/SysGL/HLEGraphics/GraphicsPluginGL.cpp b/Source/SysGL/HLEGraphics/GraphicsPluginGL.cpp index 76bb6e5f4..984891473 100644 --- a/Source/SysGL/HLEGraphics/GraphicsPluginGL.cpp +++ b/Source/SysGL/HLEGraphics/GraphicsPluginGL.cpp @@ -19,11 +19,6 @@ #include "System/Timing.h" #include "SysGL/GL.h" -#include "third_party/imgui/imgui.h" -#include "third_party/imgui/backends/imgui_impl_sdl.h" -#include "third_party/imgui/backends/imgui_impl_opengl3.h" - - extern SDL_Window * gWindow; @@ -166,78 +161,8 @@ void CGraphicsPluginImpl::ProcessDList() #endif } - bool ShowFPSonmenu = false; - bool toggle_fullscreen = false; - -void MainMenu(){ - - ImGui::NewFrame(); - extern EAudioPluginMode gAudioPluginEnabled; - if (ImGui::BeginMainMenuBar()) - { - if (ImGui::BeginMenu("Menu")) - { - if (ImGui::MenuItem("Settings")) { - } - - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Debug")) - { - if (ImGui::MenuItem("Show FPS")) { - if(ShowFPSonmenu == false) {ShowFPSonmenu = true;} - else if(ShowFPSonmenu == true) {ShowFPSonmenu = false;} - } - - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Video Mode")) - { - if (ImGui::MenuItem("Fullscreen")) { - if (toggle_fullscreen == false) { - SDL_SetWindowFullscreen(gWindow, SDL_TRUE); - toggle_fullscreen = true; - } - else if (toggle_fullscreen == true) { - SDL_SetWindowFullscreen(gWindow, SDL_FALSE); - toggle_fullscreen = false; - } - } - - ImGui::EndMenu(); - } - - - if (ImGui::BeginMenu("Audio mode")) { - - if (ImGui::MenuItem("Disabled")) { - gAudioPluginEnabled = APM_DISABLED; - } - - if (ImGui::MenuItem("Enabled Async")) { - gAudioPluginEnabled = APM_ENABLED_ASYNC; - } - - if (ImGui::MenuItem("Enabled Sync")) { - gAudioPluginEnabled = APM_ENABLED_SYNC; - } - - ImGui::EndMenu(); - - } - - if(ShowFPSonmenu == true){ - ImGui::Text("Current FPS %#.1f", gCurrentFramerate); - } - - ImGui::EndMainMenuBar(); - } - - -} - +bool ShowFPSonmenu = false; +bool toggle_fullscreen = false; void CGraphicsPluginImpl::UpdateScreen() { @@ -247,20 +172,6 @@ void CGraphicsPluginImpl::UpdateScreen() { UpdateFramerate(); - // FIXME: safe printf - std::string string = "DaedalusX64"; - // strcpy(string, "DaedalusX64"); - - SDL_SetWindowTitle(gWindow, string.c_str()); - -//Start ImGui and Render MainMenu -ImGui_ImplOpenGL3_NewFrame(); -ImGui_ImplSDL2_NewFrame(); -MainMenu(); -ImGui::Render(); -ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); -ImGui::EndFrame(); - if (gTakeScreenshot) { CGraphicsContext::Get()->DumpNextScreen(); @@ -276,9 +187,7 @@ ImGui::EndFrame(); void CGraphicsPluginImpl::RomClosed() { DBGConsole_Msg(0, "Finalising GLGraphics"); - ImGui_ImplOpenGL3_Shutdown(); - ImGui_ImplSDL2_Shutdown(); - ImGui::DestroyContext(); + DLParser_Finalise(); CTextureCache::Destroy(); DestroyRenderer(); diff --git a/Source/SysGL/Input/InputManagerGL.cpp b/Source/SysGL/Input/InputManagerGL.cpp index ac10c299d..d78712de2 100644 --- a/Source/SysGL/Input/InputManagerGL.cpp +++ b/Source/SysGL/Input/InputManagerGL.cpp @@ -368,7 +368,7 @@ u32 IInputManager::GetConfigurationFromName( const char * name ) const } void sceCtrlPeekBufferPositive(SceCtrlData *data, int count){ - + memset(data, 0, sizeof(*data)); } v2 ApplyDeadzone( const v2 & in, f32 min_deadzone, f32 max_deadzone ) diff --git a/Source/SysGL/Interface/UI.cpp b/Source/SysGL/Interface/UI.cpp index 14a54ce10..68ffc8ae6 100644 --- a/Source/SysGL/Interface/UI.cpp +++ b/Source/SysGL/Interface/UI.cpp @@ -15,9 +15,6 @@ #include "System/IO.h" #include "System/Thread.h" - -#include "third_party/imgui/backends/imgui_impl_sdl.h" - // TODO: Implemenent fullscreen toggle and window resize static bool toggle_fullscreen = false; @@ -55,7 +52,6 @@ static void PollKeyboard(void * arg) SDL_Event event; while (SDL_PollEvent( &event) != 0) { - ImGui_ImplSDL2_ProcessEvent(&event); if (event.type == SDL_QUIT) { CPU_Halt("Window Closed"); // SDL window was closed diff --git a/Source/SysPosix/CMakeLists.txt b/Source/SysPosix/CMakeLists.txt index 0bd949428..86993e71b 100644 --- a/Source/SysPosix/CMakeLists.txt +++ b/Source/SysPosix/CMakeLists.txt @@ -4,7 +4,7 @@ add_subdirectory(HLEGraphics) add_subdirectory(Utility) -list(APPEND sys_libraries "dl" "imgui") +list(APPEND sys_libraries "dl") set(sys_libraries ${sys_libraries} PARENT_SCOPE) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/../daedalus DESTINATION DaedalusX64 diff --git a/Source/SysPosix/main.cpp b/Source/SysPosix/main.cpp index 3f7f4ba8e..c74d042f6 100644 --- a/Source/SysPosix/main.cpp +++ b/Source/SysPosix/main.cpp @@ -27,7 +27,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Test/BatchTest.h" #include "System/IO.h" #include "Config/ConfigOptions.h" - +#include "Interface/Preferences.h" +#include "Utility/Translate.h" +#include "UI/MainMenuScreen.h" #include #include @@ -103,12 +105,27 @@ int main(int argc, char **argv) // Commit the preferences and roms databases before starting to run // CRomDB::Get()->Commit(); - //CPreferences::Get()->Commit(); + CPreferences::Get()->Commit(); CPU_Run(); System_Close(); } } + + Translate_Init(); + bool show_splash = true; + for(;;) + { + DisplayRomsAndChoose( show_splash ); + show_splash = false; + + CRomDB::Get()->Commit(); + CPreferences::Get()->Commit(); + + CPU_Run(); + System_Close(); + } + System_Finalize(); return result; } diff --git a/Source/UI/MainMenuScreen.cpp b/Source/UI/MainMenuScreen.cpp index d88931ff1..85a9bf7d6 100644 --- a/Source/UI/MainMenuScreen.cpp +++ b/Source/UI/MainMenuScreen.cpp @@ -382,6 +382,7 @@ void DisplayRomsAndChoose(bool show_splash) if(p_context != NULL) { + p_context->ClearBackground(c32::Red); if( show_splash ) { From 2681ec5c1b9ebb2a92da97bfdf6ff4fb1bdcaf57 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Wed, 6 Dec 2023 07:42:00 +0800 Subject: [PATCH 05/54] Always Install resources for UI --- Source/CMakeLists.txt | 2 +- Source/SysPSP/CMakeLists.txt | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 9e5795c9a..caaa58fb2 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -275,7 +275,7 @@ if(WIN32) endif(CTR) ## Install and setup basic directories - install(DIRECTORY DESTINATION DaedalusX64) + install(DIRECTORY ${PROJECT_BINARY_DIR}/../Data/ DESTINATION DaedalusX64) install(DIRECTORY DESTINATION DaedalusX64/Roms) install(DIRECTORY DESTINATION DaedalusX64/SaveGames) install(DIRECTORY DESTINATION DaedalusX64/SaveStates) diff --git a/Source/SysPSP/CMakeLists.txt b/Source/SysPSP/CMakeLists.txt index c650c9fa3..b41a36f54 100644 --- a/Source/SysPSP/CMakeLists.txt +++ b/Source/SysPSP/CMakeLists.txt @@ -14,9 +14,6 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/PRX/DveMgr/dvemgr.prx DESTINATION Daed install(FILES ${CMAKE_CURRENT_SOURCE_DIR}//PRX/ExceptionHandler/exception.prx DESTINATION DaedalusX64/Plugins) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/../EBOOT.PBP DESTINATION DaedalusX64) -#PSP Resources -install(DIRECTORY ${PROJECT_BINARY_DIR}/../Data/ DESTINATION DaedalusX64) - list(APPEND daed_libs) set(daed_libs ${daed_libs} PARENT_SCOPE) From c090e9a49f898b55599b95c6e658363c722676eb Mon Sep 17 00:00:00 2001 From: Howard Su Date: Wed, 6 Dec 2023 07:46:43 +0800 Subject: [PATCH 06/54] rename to avoid conflict --- Source/SysGL/Graphics/CMakeLists.txt | 2 +- .../{UIContext.cpp => UIContextGL.cpp} | 37 +------------------ 2 files changed, 2 insertions(+), 37 deletions(-) rename Source/SysGL/Graphics/{UIContext.cpp => UIContextGL.cpp} (91%) diff --git a/Source/SysGL/Graphics/CMakeLists.txt b/Source/SysGL/Graphics/CMakeLists.txt index 8b2d5c359..e0f209565 100644 --- a/Source/SysGL/Graphics/CMakeLists.txt +++ b/Source/SysGL/Graphics/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(Graphics_GL OBJECT GraphicsContextGL.cpp NativeTextureGL.cpp UIContext.cpp) +add_library(Graphics_GL OBJECT GraphicsContextGL.cpp NativeTextureGL.cpp UIContextGL.cpp) set(include_dirs ${include_dirs} PARENT_SCOPE) diff --git a/Source/SysGL/Graphics/UIContext.cpp b/Source/SysGL/Graphics/UIContextGL.cpp similarity index 91% rename from Source/SysGL/Graphics/UIContext.cpp rename to Source/SysGL/Graphics/UIContextGL.cpp index a8f1da711..3b95c4e97 100644 --- a/Source/SysGL/Graphics/UIContext.cpp +++ b/Source/SysGL/Graphics/UIContextGL.cpp @@ -148,42 +148,7 @@ void IUIContext::RenderTexture( const std::shared_ptr texture, c texture->InstallTexture(); - // Set up the color for the texture - glColor4b(colour.GetR(), colour.GetG(), colour.GetB(), colour.GetA()); - - // Enable texture mapping - glEnable(GL_TEXTURE_2D); - - // Set texture parameters - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - // Define texture coordinates - float texCoords[] = { - 0.0f, 0.0f, - 1.0f, 0.0f, - 1.0f, 1.0f, - 0.0f, 1.0f - }; - - // Define vertex coordinates - float vertices[] = { - tl.x, tl.y, - tl.x + wh.x, tl.y, - tl.x + wh.x, tl.y + wh.y, - tl.x, tl.y + wh.y - }; - - // Render the texture - glBegin(GL_QUADS); - for (int i = 0; i < 4; ++i) { - glTexCoord2f(texCoords[i * 2], texCoords[i * 2 + 1]); - glVertex2f(vertices[i * 2], vertices[i * 2 + 1]); - } - glEnd(); - - // Disable texture mapping after rendering - glDisable(GL_TEXTURE_2D); + } From 9837fe169ff76b2825fcb3ebad224d1346e4492f Mon Sep 17 00:00:00 2001 From: Howard Su Date: Wed, 6 Dec 2023 07:53:26 +0800 Subject: [PATCH 07/54] Add back PSP output about color mode --- Source/UI/SplashScreen.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/UI/SplashScreen.cpp b/Source/UI/SplashScreen.cpp index 04393e9ab..743ee0dde 100644 --- a/Source/UI/SplashScreen.cpp +++ b/Source/UI/SplashScreen.cpp @@ -32,10 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Interface/Preferences.h" - - -//extern bool g32bitColorMode; - +extern bool g32bitColorMode; class ISplashScreen : public CSplashScreen, public CUIScreen { @@ -105,10 +102,12 @@ void ISplashScreen::Render() c32 colour( 255, 255, 255, a ); mpContext->ClearBackground(); - mpContext->RenderTexture( mpTexture, (480 - 328)/2, (272-90)/2, colour ); + mpContext->RenderTexture( mpTexture, (SCREEN_WIDTH - mpTexture->GetWidth()) / 2, (SCREEN_HEIGHT - mpTexture->GetHeight()) / 2, colour); +#if DAEDALUS_PSP mpContext->SetFontStyle( CUIContext::FS_HEADING ); -// mpContext->DrawTextAlign(0,SCREEN_WIDTH,AT_CENTRE,SCREEN_HEIGHT-50,g32bitColorMode? "32Bit Color Selected" : "16Bit Color Selected",DrawTextUtilities::TextWhite); + mpContext->DrawTextAlign(0,SCREEN_WIDTH,AT_CENTRE,SCREEN_HEIGHT-50,g32bitColorMode? "32Bit Color Selected" : "16Bit Color Selected",DrawTextUtilities::TextWhite); +#endif } void ISplashScreen::Run() From 1c6edff0d63bf62804c87aee06a89ae71a33ad05 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Wed, 6 Dec 2023 10:16:27 +0800 Subject: [PATCH 08/54] Move DrawText.h to UI --- Source/SysPSP/Graphics/DrawText.cpp | 2 +- Source/{SysPSP/Graphics => UI}/DrawText.h | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename Source/{SysPSP/Graphics => UI}/DrawText.h (100%) diff --git a/Source/SysPSP/Graphics/DrawText.cpp b/Source/SysPSP/Graphics/DrawText.cpp index b1d5b66fe..c88dcf4e0 100644 --- a/Source/SysPSP/Graphics/DrawText.cpp +++ b/Source/SysPSP/Graphics/DrawText.cpp @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "SysPSP/Graphics/DrawText.h" +#include "UI/DrawText.h" #include #include diff --git a/Source/SysPSP/Graphics/DrawText.h b/Source/UI/DrawText.h similarity index 100% rename from Source/SysPSP/Graphics/DrawText.h rename to Source/UI/DrawText.h From 8fe4602f7d151947ed7787cdc1411c066f8948d6 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Wed, 6 Dec 2023 11:46:27 +0800 Subject: [PATCH 09/54] UI is showing --- Source/CMakeLists.txt | 3 + Source/SysGL/GL.h | 3 +- Source/SysGL/Graphics/CMakeLists.txt | 2 +- Source/SysGL/Graphics/DrawTextSDL.cpp | 111 ++++++++++ Source/SysGL/Graphics/GraphicsContextGL.cpp | 12 ++ Source/SysGL/Graphics/UIContextGL.cpp | 196 ++++++++++-------- Source/SysGL/Input/InputManagerGL.cpp | 10 +- Source/SysPSP/Graphics/CMakeLists.txt | 2 +- .../{DrawText.cpp => DrawTextPSP.cpp} | 106 +--------- Source/UI/AboutComponent.cpp | 2 +- Source/UI/DrawText.h | 6 - Source/UI/DrawTextUtilities.cpp | 98 +++++++++ Source/UI/DrawTextUtilities.h | 3 + Source/UI/UIContext.h | 27 +-- 14 files changed, 365 insertions(+), 216 deletions(-) create mode 100644 Source/SysGL/Graphics/DrawTextSDL.cpp rename Source/SysPSP/Graphics/{DrawText.cpp => DrawTextPSP.cpp} (65%) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index caaa58fb2..4bf6f0ce8 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -119,6 +119,9 @@ endif() find_package(SDL2 CONFIG REQUIRED) list(APPEND default_libraries "${SDL2_LIBRARIES}") list(APPEND include_dirs "${SDL2_INCLUDE_DIRS}") + + find_package(SDL2_ttf CONFIG REQUIRED) + list(APPEND default_libraries "SDL2_ttf-2.0") endif(DAEDALUS_SDL) # Needed below the options to post process diff --git a/Source/SysGL/GL.h b/Source/SysGL/GL.h index 0db92612d..e46ed50ca 100644 --- a/Source/SysGL/GL.h +++ b/Source/SysGL/GL.h @@ -4,11 +4,12 @@ #include #include #include +#include #include "Base/Types.h" extern SDL_Window * gWindow; - +extern SDL_Renderer * gSdlRenderer; // FIXME: burn all of this with fire. void sceGuFog(float mn, float mx, u32 col); diff --git a/Source/SysGL/Graphics/CMakeLists.txt b/Source/SysGL/Graphics/CMakeLists.txt index e0f209565..b9d5f39dc 100644 --- a/Source/SysGL/Graphics/CMakeLists.txt +++ b/Source/SysGL/Graphics/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(Graphics_GL OBJECT GraphicsContextGL.cpp NativeTextureGL.cpp UIContextGL.cpp) +add_library(Graphics_GL OBJECT DrawTextSDL.cpp GraphicsContextGL.cpp NativeTextureGL.cpp UIContextGL.cpp) set(include_dirs ${include_dirs} PARENT_SCOPE) diff --git a/Source/SysGL/Graphics/DrawTextSDL.cpp b/Source/SysGL/Graphics/DrawTextSDL.cpp new file mode 100644 index 000000000..120db77bc --- /dev/null +++ b/Source/SysGL/Graphics/DrawTextSDL.cpp @@ -0,0 +1,111 @@ +#include "SysGL/GL.h" +#include "UI/DrawText.h" + +TTF_Font *gFonts[] = +{ + nullptr, + nullptr, +}; +DAEDALUS_STATIC_ASSERT(ARRAYSIZE(gFonts) == CDrawText::NUM_FONTS); + +void CDrawText::Initialise() +{ + gFonts[CDrawText::F_REGULAR] = TTF_OpenFont("Resources/OpenSans-Regular.ttf", 16); + gFonts[CDrawText::F_LARGE_BOLD] = TTF_OpenFont("Resources/OpenSans-Regular.ttf", 24); + + if (gFonts[0] == 0) + { + printf( "SDL could not open TTF Font! SDL Error: %s\n", SDL_GetError() ); + } + +} + +void CDrawText::Destroy() +{ + TTF_CloseFont(gFonts[CDrawText::F_REGULAR]); + TTF_CloseFont(gFonts[CDrawText::F_LARGE_BOLD]); +} + +//************************************************************************************* +// +//************************************************************************************* +u32 CDrawText::Render(EFont font, s32 x, s32 y, float scale, const char *p_str, u32 length, c32 colour) +{ + return Render(font, x, y, scale, p_str, length, colour, c32(0, 0, 0, 160)); +} + +//************************************************************************************* +// +//************************************************************************************* +u32 CDrawText::Render(EFont font_type, s32 x, s32 y, float scale, const char *p_str, u32 length, c32 colour, c32 drop_colour) +{ + DAEDALUS_ASSERT(font_type >= 0 && font_type < (s32)NUM_FONTS, "Invalid font"); + + TTF_Font *font(gFonts[font_type]); + if (font) + { + SDL_Color c {colour.GetR(), colour.GetG(), colour.GetB()}; + SDL_Color dc {drop_colour.GetR(), drop_colour.GetG(), drop_colour.GetB()}; + SDL_Surface *surface = TTF_RenderText_Shaded(font, p_str, c, dc); + SDL_Texture* Message = SDL_CreateTextureFromSurface(gSdlRenderer, surface); + + SDL_Rect Message_rect; //create a rect + Message_rect.x = x; //controls the rect's x coordinate + Message_rect.y = y; // controls the rect's y coordinte + Message_rect.w = surface->w; // controls the width of the rect + Message_rect.h = surface->h; // controls the height of the rect + + SDL_RenderCopy(gSdlRenderer, Message, NULL, &Message_rect); + + SDL_FreeSurface(surface); + + return Message_rect.w; + } + + return strlen(p_str) * 16; // Guess. Better off just returning 0? +} + +//************************************************************************************* +// +//************************************************************************************* +s32 CDrawText::GetTextWidth(EFont font_type, const char *p_str, u32 length) +{ +#ifdef DAEDALUS_ENABLE_ASSERTS + DAEDALUS_ASSERT(font_type >= 0 && font_type < (s32)NUM_FONTS, "Invalid font"); +#endif + TTF_Font *font(gFonts[font_type]); + if (font) + { + int w, h; + if (p_str[length] == '\0') + TTF_SizeText(font, p_str, &w, &h); + else + { + char buf[128]; + memcpy(buf, p_str, length); + buf[length] = '\0'; + TTF_SizeText(font, buf, &w, &h); + } + return w; + } + + return strlen(p_str) * 16; // Return a reasonable value. Better off just returning 0? +} + + +//************************************************************************************* +// +//************************************************************************************* +s32 CDrawText::GetFontHeight(EFont font_type) +{ +#ifdef DAEDALUS_ENABLE_ASSERTS + DAEDALUS_ASSERT(font_type >= 0 && font_type < (s32)NUM_FONTS, "Invalid font"); +#endif + TTF_Font *font(gFonts[font_type]); + if (font) + { + return TTF_FontHeight(font); + } + + return 0; // Return a reasonable value. Better off just returning 0? +} diff --git a/Source/SysGL/Graphics/GraphicsContextGL.cpp b/Source/SysGL/Graphics/GraphicsContextGL.cpp index 6a52bd69e..9d26e107a 100644 --- a/Source/SysGL/Graphics/GraphicsContextGL.cpp +++ b/Source/SysGL/Graphics/GraphicsContextGL.cpp @@ -9,11 +9,13 @@ #include "Graphics/GraphicsContext.h" #include "Graphics/ColourValue.h" +#include "UI/DrawText.h" static u32 SCR_WIDTH = 640; static u32 SCR_HEIGHT = 480; SDL_Window * gWindow = nullptr; +SDL_Renderer * gSdlRenderer = nullptr; class GraphicsContextGL : public CGraphicsContext { @@ -73,6 +75,12 @@ bool GraphicsContextGL::Initialise() return false; } + if (TTF_Init() < 0) + { + printf( "SDL could not initialize TTF Font! SDL Error: %s\n", SDL_GetError() ); + return false; + } + // Decide GL+GLSL versions #if defined(IMGUI_IMPL_OPENGL_ES2) // GL ES 2.0 + GLSL 100 @@ -105,6 +113,8 @@ bool GraphicsContextGL::Initialise() //Create window gWindow = SDL_CreateWindow( "Daedalus", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCR_WIDTH, SCR_HEIGHT, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI); + gSdlRenderer = SDL_CreateRenderer(gWindow, 0, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC) ; + //Create context SDL_GLContext gContext = SDL_GL_CreateContext( gWindow ); @@ -121,6 +131,8 @@ bool GraphicsContextGL::Initialise() return false; } + CDrawText::Initialise(); + //ClearColBufferAndDepth(0,0,0,0); UpdateFrame(false); return initgl(); diff --git a/Source/SysGL/Graphics/UIContextGL.cpp b/Source/SysGL/Graphics/UIContextGL.cpp index 3b95c4e97..19d00cd2e 100644 --- a/Source/SysGL/Graphics/UIContextGL.cpp +++ b/Source/SysGL/Graphics/UIContextGL.cpp @@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Math/Matrix4x4.h" #include "Graphics/GraphicsContext.h" #include "Graphics/NativeTexture.h" -#include "SysPSP/Graphics/DrawText.h" +#include "UI/DrawText.h" #include "UI/UIContext.h" #include "UI/DrawTextUtilities.h" #include "Utility/Translate.h" @@ -145,8 +145,49 @@ void IUIContext::RenderTexture( const std::shared_ptr texture, c { if(texture == NULL) return; + int depth; + Uint32 format; - texture->InstallTexture(); + switch(texture->GetFormat()) + { + case TexFmt_5650: + depth=16; + format = SDL_PIXELFORMAT_BGR565; + break; + case TexFmt_5551: + depth = 16; + format = SDL_PIXELFORMAT_BGRA5551; + break; + case TexFmt_4444: + depth = 16; + format = SDL_PIXELFORMAT_ABGR4444; + break; + case TexFmt_8888: + depth = 32; + format = SDL_PIXELFORMAT_ABGR8888; + break; + default: + return; + } + + SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom( + texture->GetData(), + texture->GetWidth(), + texture->GetHeight(), + depth, + texture->GetStride(), + format + ); + + SDL_Rect Message_rect; //create a rect + Message_rect.x = tl.x; //controls the rect's x coordinate + Message_rect.y = tl.y; // controls the rect's y coordinte + Message_rect.w = surface->w; // controls the width of the rect + Message_rect.h = surface->h; // controls the height of the rect + + SDL_Texture* Message = SDL_CreateTextureFromSurface(gSdlRenderer, surface); + SDL_RenderCopy(gSdlRenderer, Message, NULL, &Message_rect); + SDL_FreeSurface(surface); } @@ -160,120 +201,99 @@ void IUIContext::ClearBackground( c32 colour ) void IUIContext::DrawRect( s32 x, s32 y, u32 w, u32 h, c32 colour ) { - // Set up the color for the rectangle - glColor4b(colour.GetR(), colour.GetG(), colour.GetB(), colour.GetA()); - - // Draw the rectangle using OpenGL - glBegin(GL_QUADS); - glVertex2i(x, y); - glVertex2i(x + w, y); - glVertex2i(x + w, y + h); - glVertex2i(x, y + h); - glEnd(); + } void IUIContext::DrawLine( s32 x0, s32 y0, s32 x1, s32 y1, c32 colour ) { - glColor4b(colour.GetR(), colour.GetG(), colour.GetB(), colour.GetA()); - // Draw the line using OpenGL - glBegin(GL_LINES); - glVertex2i(x0, y0); - glVertex2i(x1, y1); - glEnd(); } void IUIContext::SetFontStyle( EFontStyle font_style ) { -// switch( font_style ) -// { -// case FS_REGULAR: mCurrentFont = CDrawText::F_REGULAR; return; -// case FS_HEADING: mCurrentFont = CDrawText::F_LARGE_BOLD; return; -// } -// #ifdef DAEDALUS_DEBUG_CONSOLE -// DAEDALUS_ERROR( "Unhandled font style" ); -// #endif + switch( font_style ) + { + case FS_REGULAR: mCurrentFont = CDrawText::F_REGULAR; return; + case FS_HEADING: mCurrentFont = CDrawText::F_LARGE_BOLD; return; + } +#ifdef DAEDALUS_DEBUG_CONSOLE + DAEDALUS_ERROR( "Unhandled font style" ); +#endif } u32 IUIContext::GetFontHeight() const { - // return CDrawText::GetFontHeight( mCurrentFont ); + return CDrawText::GetFontHeight( mCurrentFont ); } u32 IUIContext::GetTextWidth( const char * text ) const { - // return CDrawText::GetTextWidth( mCurrentFont, text ); + return CDrawText::GetTextWidth( mCurrentFont, text ); } s32 IUIContext::AlignText( s32 min_x, s32 max_x, const char * p_str, u32 length, EAlignType align_type ) { s32 x = 0; - // switch( align_type ) - // { - // case AT_LEFT: - // x = min_x; - // break; + switch( align_type ) + { + case AT_LEFT: + x = min_x; + break; - // case AT_CENTRE: - // x = min_x + ((max_x - min_x) - CDrawText::GetTextWidth( mCurrentFont, p_str, length )) / 2; - // break; + case AT_CENTRE: + x = min_x + ((max_x - min_x) - CDrawText::GetTextWidth( mCurrentFont, p_str, length )) / 2; + break; - // case AT_RIGHT: - // x = max_x - CDrawText::GetTextWidth( mCurrentFont, p_str, length ); - // break; + case AT_RIGHT: + x = max_x - CDrawText::GetTextWidth( mCurrentFont, p_str, length ); + break; - // default: - // #ifdef DAEDALUS_DEBUG_CONSOLE - // DAEDALUS_ERROR( "Unhandled alignment type" ); - // #endif - // x = min_x; - // break; - // } + default: + #ifdef DAEDALUS_DEBUG_CONSOLE + DAEDALUS_ERROR( "Unhandled alignment type" ); + #endif + x = min_x; + break; + } return x; } u32 IUIContext::DrawText( s32 x, s32 y, const char * text, u32 length, c32 colour ) { - // return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour ); - printf("%s\n", text); + return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour ); } u32 IUIContext::DrawText( s32 x, s32 y, const char * text, u32 length, c32 colour, c32 drop_colour ) { - // return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour, drop_colour ); - printf("%s\n", text); + return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour, drop_colour ); } u32 IUIContext::DrawTextScale( s32 x, s32 y, float scale, const char * text, u32 length, c32 colour ) { - // return CDrawText::Render( mCurrentFont, x, y, scale, text, length, colour ); - printf("%s\n", text); + return CDrawText::Render( mCurrentFont, x, y, scale, text, length, colour ); } u32 IUIContext::DrawTextScale( s32 x, s32 y, float scale, const char * text, u32 length, c32 colour, c32 drop_colour ) { - // return CDrawText::Render( mCurrentFont, x, y, scale, text, length, colour, drop_colour ); - printf("%s\n", text); + return CDrawText::Render( mCurrentFont, x, y, scale, text, length, colour, drop_colour ); } u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour ) { - // s32 x( AlignText( min_x, max_x, text, length, align_type ) ); + s32 x( AlignText( min_x, max_x, text, length, align_type ) ); - // return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour ); - printf("%s\n", text); + return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour ); } u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour, c32 drop_colour ) { - // s32 x( AlignText( min_x, max_x, text, length, align_type ) ); + s32 x( AlignText( min_x, max_x, text, length, align_type ) ); - // return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour, drop_colour ); - printf("%s\n", text); + return CDrawText::Render( mCurrentFont, x, y, 1.0f, text, length, colour, drop_colour ); } @@ -296,34 +316,34 @@ namespace s32 IUIContext::DrawTextArea( s32 left, s32 top, u32 width, u32 height, const char * text, c32 colour, EVerticalAlign vertical_align ) { - // const u32 font_height( CDrawText::GetFontHeight( mCurrentFont ) ); - // u32 length = strlen( text ); - // std::vector lengths; - // bool match = false; - // DrawTextUtilities::WrapText( mCurrentFont, width, Translate_Strings( text, length ), length, lengths, match ); - - // s32 x( left ); - // s32 y( VerticalAlign( vertical_align, top, height, lengths.size() * font_height ) ); - - // // Our built-in auto-linebreaking can't handle unicodes. - // // Fall back to use intrafont's manual linebreaking feature - // if( match ) - // { - // y += font_height; - // DrawTextScale( x, y, 0.8f, text, length, colour ); - // y += 2; - // return y - top; - // } - - // for( u32 i = 0; i < lengths.size(); ++i ) - // { - // y += font_height; - // DrawTextScale( x, y, 0.8f, text, lengths[ i ], colour ); - // y += 2; - // text += lengths[ i ]; - // } - - // return y - top; + const u32 font_height( CDrawText::GetFontHeight( mCurrentFont ) ); + u32 length = strlen( text ); + std::vector lengths; + bool match = false; + DrawTextUtilities::WrapText( mCurrentFont, width, Translate_Strings( text, length ), length, lengths, match ); + + s32 x( left ); + s32 y( VerticalAlign( vertical_align, top, height, lengths.size() * font_height ) ); + + // Our built-in auto-linebreaking can't handle unicodes. + // Fall back to use intrafont's manual linebreaking feature + if( match ) + { + y += font_height; + DrawTextScale( x, y, 0.8f, text, length, colour ); + y += 2; + return y - top; + } + + for( u32 i = 0; i < lengths.size(); ++i ) + { + y += font_height; + DrawTextScale( x, y, 0.8f, text, lengths[ i ], colour ); + y += 2; + text += lengths[ i ]; + } + + return y - top; } // diff --git a/Source/SysGL/Input/InputManagerGL.cpp b/Source/SysGL/Input/InputManagerGL.cpp index d78712de2..459079b3c 100644 --- a/Source/SysGL/Input/InputManagerGL.cpp +++ b/Source/SysGL/Input/InputManagerGL.cpp @@ -368,7 +368,15 @@ u32 IInputManager::GetConfigurationFromName( const char * name ) const } void sceCtrlPeekBufferPositive(SceCtrlData *data, int count){ - memset(data, 0, sizeof(*data)); + OSContPad mContPads[ 4 ]; + CInputManager::Get()->GetState( mContPads ); + + for (int i = 0; i < count; i++) + { + data[i].Buttons = mContPads[i].button; + data[i].Lx = mContPads[i].stick_x; + data[i].Ly = mContPads[i].stick_y; + } } v2 ApplyDeadzone( const v2 & in, f32 min_deadzone, f32 max_deadzone ) diff --git a/Source/SysPSP/Graphics/CMakeLists.txt b/Source/SysPSP/Graphics/CMakeLists.txt index 84a09f03d..9b1b505eb 100644 --- a/Source/SysPSP/Graphics/CMakeLists.txt +++ b/Source/SysPSP/Graphics/CMakeLists.txt @@ -1,5 +1,5 @@ add_library(Graphics_PSP OBJECT - DrawText.cpp + DrawTextPSP.cpp GraphicsContext.cpp NativeTexturePSP.cpp VideoMemoryManager.cpp diff --git a/Source/SysPSP/Graphics/DrawText.cpp b/Source/SysPSP/Graphics/DrawTextPSP.cpp similarity index 65% rename from Source/SysPSP/Graphics/DrawText.cpp rename to Source/SysPSP/Graphics/DrawTextPSP.cpp index c88dcf4e0..a3b03d7d5 100644 --- a/Source/SysPSP/Graphics/DrawText.cpp +++ b/Source/SysPSP/Graphics/DrawTextPSP.cpp @@ -39,9 +39,8 @@ intraFont *gFonts[] = nullptr, nullptr, }; -#ifdef DAEDALUS_ENABLE_ASSERTS DAEDALUS_STATIC_ASSERT(ARRAYSIZE(gFonts) == CDrawText::NUM_FONTS); -#endif + //************************************************************************************* // //************************************************************************************* @@ -135,106 +134,3 @@ s32 CDrawText::GetFontHeight(EFont font_type) return 0; // Return a reasonable value. Better off just returning 0? } - -//************************************************************************************* -// -//************************************************************************************* -namespace DrawTextUtilities -{ - const char *FindPreviousSpace(const char *p_str_start, const char *p_str_end) - { - while (p_str_end > p_str_start) - { - if (*p_str_end == ' ') - { - return p_str_end; - } - p_str_end--; - } - - // Not found - return nullptr; - } - - void WrapText(CDrawText::EFont font, s32 width, const char *p_str, u32 length, std::vector &lengths, bool &match) - { - lengths.clear(); - - // Manual line breaking (Used for translations) - if (gGlobalPreferences.Language != 0) - { - u32 i, j; - for (i = 0, j = 0; i < length; i++) - { - match = true; - if (p_str[i] == '\n') - { - j++; - lengths.push_back(match); - } - } - if (match) - { - lengths.push_back(match); - } - - return; - } - - // Auto-linebreaking - const char *p_line_str(p_str); - const char *p_str_end(p_str + length); - - while (p_line_str < p_str_end) - { - u32 length_remaining(p_str_end - p_line_str); - s32 chunk_width(CDrawText::GetTextWidth(font, p_line_str, length_remaining)); - - if (chunk_width <= width) - { - lengths.push_back(length_remaining); - p_line_str += length_remaining; - } - else - { - // Search backwards until we find a break - const char *p_chunk_end(p_str_end); - bool found_chunk(false); - while (p_chunk_end > p_line_str) - { - const char *p_space(FindPreviousSpace(p_line_str, p_chunk_end)); - - if (p_space != nullptr) - { - u32 chunk_length(p_space + 1 - p_line_str); - chunk_width = CDrawText::GetTextWidth(font, p_line_str, chunk_length); - if (chunk_width <= width) - { - lengths.push_back(chunk_length); - p_line_str += chunk_length; - found_chunk = true; - break; - } - else - { - // Need to try again with the previous space - p_chunk_end = p_space - 1; - } - } - else - { - // No more spaces - just render the whole chunk - lengths.push_back(p_chunk_end - p_line_str); - p_line_str = p_chunk_end; - found_chunk = true; - break; - } - } -#ifdef DAEDALUS_ENABLE_ASSERTS - DAEDALUS_ASSERT(found_chunk, "Didn't find chunk while splitting string for rendering?"); -#endif - } - } - } - -} // namespace DrawTextUtilities diff --git a/Source/UI/AboutComponent.cpp b/Source/UI/AboutComponent.cpp index 9cf7cb0b2..7e990ad20 100644 --- a/Source/UI/AboutComponent.cpp +++ b/Source/UI/AboutComponent.cpp @@ -112,7 +112,7 @@ std::string date = DATE_TEXT + __DATE__; // Spacer y += line_height; - for( s16 i = 0; i < ARRAYSIZE( INFO_TEXT ); ++i ) + for( size_t i = 0; i < ARRAYSIZE( INFO_TEXT ); ++i ) { const char * str( INFO_TEXT[ i ] ); diff --git a/Source/UI/DrawText.h b/Source/UI/DrawText.h index 1632f52ca..4d9a6fd53 100644 --- a/Source/UI/DrawText.h +++ b/Source/UI/DrawText.h @@ -53,10 +53,4 @@ class CDrawText static void Destroy(); }; -namespace DrawTextUtilities -{ - void WrapText( CDrawText::EFont font, s32 width, const char * p_str, u32 length, std::vector & lengths, bool & match ); - //inline void WrapText( CDrawText::EFont font, s32 width, const char * p_str, std::vector & lengths ) { WrapText( font, width, p_str, strlen( p_str ), lengths ); } -} - #endif // SYSPSP_GRAPHICS_DRAWTEXT_H_ diff --git a/Source/UI/DrawTextUtilities.cpp b/Source/UI/DrawTextUtilities.cpp index 2188a5bdc..4c9986c28 100644 --- a/Source/UI/DrawTextUtilities.cpp +++ b/Source/UI/DrawTextUtilities.cpp @@ -4,6 +4,7 @@ #include "Graphics/ColourValue.h" #include "DrawTextUtilities.h" +#include "DrawText.h" //************************************************************************************* // @@ -19,4 +20,101 @@ namespace DrawTextUtilities static c32 COLOUR_SHADOW_HEAVY = c32(0x80000000); static c32 COLOUR_SHADOW_LIGHT = c32(0x50000000); + + static const char *FindPreviousSpace(const char *p_str_start, const char *p_str_end) + { + while (p_str_end > p_str_start) + { + if (*p_str_end == ' ') + { + return p_str_end; + } + p_str_end--; + } + + // Not found + return nullptr; + } + + void WrapText(CDrawText::EFont font, s32 width, const char *p_str, u32 length, std::vector &lengths, bool &match) + { + lengths.clear(); + + // Manual line breaking (Used for translations) + if (gGlobalPreferences.Language != 0) + { + u32 i, j; + for (i = 0, j = 0; i < length; i++) + { + match = true; + if (p_str[i] == '\n') + { + j++; + lengths.push_back(match); + } + } + if (match) + { + lengths.push_back(match); + } + + return; + } + + // Auto-linebreaking + const char *p_line_str(p_str); + const char *p_str_end(p_str + length); + + while (p_line_str < p_str_end) + { + u32 length_remaining(p_str_end - p_line_str); + s32 chunk_width(CDrawText::GetTextWidth(font, p_line_str, length_remaining)); + + if (chunk_width <= width) + { + lengths.push_back(length_remaining); + p_line_str += length_remaining; + } + else + { + // Search backwards until we find a break + const char *p_chunk_end(p_str_end); + bool found_chunk(false); + while (p_chunk_end > p_line_str) + { + const char *p_space(FindPreviousSpace(p_line_str, p_chunk_end)); + + if (p_space != nullptr) + { + u32 chunk_length(p_space + 1 - p_line_str); + chunk_width = CDrawText::GetTextWidth(font, p_line_str, chunk_length); + if (chunk_width <= width) + { + lengths.push_back(chunk_length); + p_line_str += chunk_length; + found_chunk = true; + break; + } + else + { + // Need to try again with the previous space + p_chunk_end = p_space - 1; + } + } + else + { + // No more spaces - just render the whole chunk + lengths.push_back(p_chunk_end - p_line_str); + p_line_str = p_chunk_end; + found_chunk = true; + break; + } + } +#ifdef DAEDALUS_ENABLE_ASSERTS + DAEDALUS_ASSERT(found_chunk, "Didn't find chunk while splitting string for rendering?"); +#endif + } + } + } + } // namespace DrawTextUtilities diff --git a/Source/UI/DrawTextUtilities.h b/Source/UI/DrawTextUtilities.h index 096cc7bd5..aeee21745 100644 --- a/Source/UI/DrawTextUtilities.h +++ b/Source/UI/DrawTextUtilities.h @@ -7,6 +7,7 @@ #include "Graphics/ColourValue.h" #include "UI/UIAlignment.h" +#include "UI/DrawText.h" namespace DrawTextUtilities { @@ -16,6 +17,8 @@ namespace DrawTextUtilities extern const c32 TextBlueDisabled; extern const c32 TextRed; extern const c32 TextRedDisabled; + + void WrapText(CDrawText::EFont font, s32 width, const char *p_str, u32 length, std::vector &lengths, bool &match); } #endif \ No newline at end of file diff --git a/Source/UI/UIContext.h b/Source/UI/UIContext.h index 0c9cdcff0..cad748792 100644 --- a/Source/UI/UIContext.h +++ b/Source/UI/UIContext.h @@ -110,18 +110,21 @@ class CUIContext #include #include #else - #define PSP_CTRL_DOWN 0x01 - #define PSP_CTRL_UP 0x02 - #define PSP_CTRL_LEFT 0x04 - #define PSP_CTRL_RIGHT 0x08 - #define PSP_CTRL_TRIANGLE 0x10 - #define PSP_CTRL_CIRCLE 0x20 - #define PSP_CTRL_SELECT 0x40 - #define PSP_CTRL_CROSS 0x80 - #define PSP_CTRL_START 0x100 - #define PSP_CTRL_LTRIGGER 0x200 - #define PSP_CTRL_RTRIGGER 0x400 - #define PSP_CTRL_SQUARE 0x800 +#include "Ultra/ultra_os.h" + + #define PSP_CTRL_DOWN D_JPAD + #define PSP_CTRL_UP U_JPAD + #define PSP_CTRL_LEFT L_JPAD + #define PSP_CTRL_RIGHT R_JPAD + #define PSP_CTRL_TRIANGLE A_BUTTON + #define PSP_CTRL_CIRCLE B_BUTTON + #define PSP_CTRL_CROSS U_CBUTTONS + #define PSP_CTRL_SQUARE L_CBUTTONS + #define PSP_CTRL_SELECT Z_TRIG + #define PSP_CTRL_START START_BUTTON + #define PSP_CTRL_LTRIGGER L_TRIG + #define PSP_CTRL_RTRIGGER R_TRIG + struct SceCtrlData { u16 Lx, Ly; From abba1cdca98a8591b9a7d6c28949100cee46e45e Mon Sep 17 00:00:00 2001 From: Howard Su Date: Wed, 6 Dec 2023 12:35:02 +0800 Subject: [PATCH 10/54] Add input support Keycode mapping needs more work. --- Source/SysGL/Graphics/GraphicsContextGL.cpp | 5 +- Source/SysGL/HLEGraphics/GraphicsPluginGL.cpp | 2 +- Source/SysGL/Input/InputManagerGL.cpp | 63 +++++++++++++++-- Source/SysPSP/main.cpp | 2 +- Source/SysPosix/main.cpp | 67 +++++++++++++++++++ 5 files changed, 130 insertions(+), 9 deletions(-) diff --git a/Source/SysGL/Graphics/GraphicsContextGL.cpp b/Source/SysGL/Graphics/GraphicsContextGL.cpp index 9d26e107a..68f37c45a 100644 --- a/Source/SysGL/Graphics/GraphicsContextGL.cpp +++ b/Source/SysGL/Graphics/GraphicsContextGL.cpp @@ -17,6 +17,8 @@ static u32 SCR_HEIGHT = 480; SDL_Window * gWindow = nullptr; SDL_Renderer * gSdlRenderer = nullptr; +extern void HandleEndOfFrame(); + class GraphicsContextGL : public CGraphicsContext { public: @@ -69,7 +71,7 @@ bool GraphicsContextGL::Initialise() { //Initialize SDL - if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO ) < 0 ) + if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_EVENTS ) < 0 ) { printf( "SDL could not initialize! SDL Error: %s\n", SDL_GetError() ); return false; @@ -205,6 +207,7 @@ void GraphicsContextGL::BeginFrame() void GraphicsContextGL::EndFrame() { + HandleEndOfFrame(); } void GraphicsContextGL::UpdateFrame( bool wait_for_vbl ) diff --git a/Source/SysGL/HLEGraphics/GraphicsPluginGL.cpp b/Source/SysGL/HLEGraphics/GraphicsPluginGL.cpp index 984891473..6a9300722 100644 --- a/Source/SysGL/HLEGraphics/GraphicsPluginGL.cpp +++ b/Source/SysGL/HLEGraphics/GraphicsPluginGL.cpp @@ -162,7 +162,7 @@ void CGraphicsPluginImpl::ProcessDList() } bool ShowFPSonmenu = false; -bool toggle_fullscreen = false; + void CGraphicsPluginImpl::UpdateScreen() { diff --git a/Source/SysGL/Input/InputManagerGL.cpp b/Source/SysGL/Input/InputManagerGL.cpp index 459079b3c..26d10891a 100644 --- a/Source/SysGL/Input/InputManagerGL.cpp +++ b/Source/SysGL/Input/InputManagerGL.cpp @@ -367,15 +367,66 @@ u32 IInputManager::GetConfigurationFromName( const char * name ) const return 0; } +static bool toggle_fullscreen = false; void sceCtrlPeekBufferPositive(SceCtrlData *data, int count){ - OSContPad mContPads[ 4 ]; - CInputManager::Get()->GetState( mContPads ); - for (int i = 0; i < count; i++) + SDL_Event event; + memset(data, 0, sizeof(*data)); + SDL_PumpEvents(); + + while (SDL_PeepEvents( &event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) != 0) { - data[i].Buttons = mContPads[i].button; - data[i].Lx = mContPads[i].stick_x; - data[i].Ly = mContPads[i].stick_y; + if (event.type == SDL_QUIT) + { + CPU_Halt("Window Closed"); // SDL window was closed + // Optionally, you can also call SDL_Quit() to terminate SDL subsystems + SDL_Quit(); + // Exit the application + exit(0); + } + else if(event.type == SDL_KEYDOWN) + { + if(event.key.keysym.scancode == SDL_SCANCODE_ESCAPE) + { + CPU_Halt("Window Closed"); // User pressed escape to exit + } + + if (event.key.keysym.scancode == SDL_SCANCODE_F11) + { + if (toggle_fullscreen == false) { + SDL_SetWindowFullscreen(gWindow, SDL_TRUE); + toggle_fullscreen = true; + } + else + { + SDL_SetWindowFullscreen(gWindow, SDL_FALSE); + toggle_fullscreen = false; + } + } + + if (event.key.keysym.scancode == SDL_SCANCODE_UP) {data->Ly = +80;} + if (event.key.keysym.scancode == SDL_SCANCODE_DOWN) {data->Ly = -80;} + if (event.key.keysym.scancode == SDL_SCANCODE_LEFT) {data->Lx = -80;} + if (event.key.keysym.scancode == SDL_SCANCODE_RIGHT) {data->Lx = +80;} + + if (event.key.keysym.scancode == SDL_SCANCODE_X) {data->Buttons |= A_BUTTON;} + if (event.key.keysym.scancode == SDL_SCANCODE_C) {data->Buttons |= B_BUTTON;} + if (event.key.keysym.scancode == SDL_SCANCODE_Z) {data->Buttons |= Z_TRIG;} + if (event.key.keysym.scancode == SDL_SCANCODE_A) {data->Buttons |= L_TRIG;} + if (event.key.keysym.scancode == SDL_SCANCODE_S) {data->Buttons |= R_TRIG;} + + if (event.key.keysym.scancode == SDL_SCANCODE_RETURN) {data->Buttons |= START_BUTTON;} + + if (event.key.keysym.scancode == SDL_SCANCODE_KP_8){ data->Buttons |= U_JPAD;} + if (event.key.keysym.scancode == SDL_SCANCODE_KP_2){ data->Buttons |= D_JPAD;} + if (event.key.keysym.scancode == SDL_SCANCODE_KP_4){ data->Buttons |= L_JPAD;} + if (event.key.keysym.scancode == SDL_SCANCODE_KP_6){ data->Buttons |= R_JPAD;} + + if (event.key.keysym.scancode == SDL_SCANCODE_HOME){ data->Buttons |= U_CBUTTONS;} + if (event.key.keysym.scancode == SDL_SCANCODE_END){ data->Buttons |= D_CBUTTONS;} + if (event.key.keysym.scancode == SDL_SCANCODE_DELETE){ data->Buttons |= L_CBUTTONS;} + if (event.key.keysym.scancode == SDL_SCANCODE_PAGEDOWN){ data->Buttons |= R_CBUTTONS;} + } } } diff --git a/Source/SysPSP/main.cpp b/Source/SysPSP/main.cpp index e156d0255..0bb2901ff 100644 --- a/Source/SysPSP/main.cpp +++ b/Source/SysPSP/main.cpp @@ -174,7 +174,7 @@ void HandleEndOfFrame() //Enter debug menu as soon as select is pressed static u32 oldButtons = 0; SceCtrlData pad; - bool activate_pause_menu = false; + bool activate_pause_menu = false; sceCtrlPeekBufferPositive(&pad, 1); // If KernelButtons.prx not found. Use select for pause instead diff --git a/Source/SysPosix/main.cpp b/Source/SysPosix/main.cpp index c74d042f6..09b676bd1 100644 --- a/Source/SysPosix/main.cpp +++ b/Source/SysPosix/main.cpp @@ -41,6 +41,73 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #endif +#include "UI/UIContext.h" +#include "Graphics/GraphicsContext.h" +#include "UI/DrawText.h" +#include "UI/PauseScreen.h" + +#ifdef DAEDALUS_PROFILE_EXECUTION +static CTimer gTimer; +#endif + +void HandleEndOfFrame() +{ +#ifdef DAEDALUS_DEBUG_DISPLAYLIST + if(DLDebugger_IsDebugging()) + return; + DPF( DEBUG_FRAME, "********************************************" ); +#endif + +// How long did the last frame take? +#ifdef DAEDALUS_PROFILE_EXECUTION + DumpDynarecStats( elapsed_time ); +#endif + + //Enter debug menu as soon as select is pressed + static u32 oldButtons = 0; + SceCtrlData pad; + bool activate_pause_menu = false; + sceCtrlPeekBufferPositive(&pad, 1); + + // If KernelButtons.prx not found. Use select for pause instead + if(oldButtons != pad.Buttons) + { + // if( gCheatsEnabled && (pad.Buttons & PSP_CTRL_SELECT) ) + // { + // CheatCodes_Activate( GS_BUTTON ); + // } + + if(pad.Buttons & PSP_CTRL_SELECT) + activate_pause_menu = true; + } + + if(activate_pause_menu) + { + + CGraphicsContext::Get()->SwitchToLcdDisplay(); + CGraphicsContext::Get()->ClearAllSurfaces(); + + CUIContext * p_context( CUIContext::Create() ); + + if(p_context != NULL) + { + CPauseScreen * pause( CPauseScreen::Create( p_context ) ); + pause->Run(); + delete pause; + delete p_context; + } + + // Commit the preferences database before starting to run + // CPreferences::Get()->Commit(); + } + + // Reset the elapsed time to avoid glitches when we restart + #ifdef DAEDALUS_PROFILE_EXECUTION + gTimer.Reset(); + #endif + +} + int main(int argc, char **argv) { int result = 0; From 8d47324745c768e6545577978f3c395859a1b544 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Wed, 6 Dec 2023 13:33:11 +0800 Subject: [PATCH 11/54] Add stick support --- Source/SysGL/Input/InputManagerGL.cpp | 113 +++++++++++++++++++++----- 1 file changed, 93 insertions(+), 20 deletions(-) diff --git a/Source/SysGL/Input/InputManagerGL.cpp b/Source/SysGL/Input/InputManagerGL.cpp index 26d10891a..9c92e524b 100644 --- a/Source/SysGL/Input/InputManagerGL.cpp +++ b/Source/SysGL/Input/InputManagerGL.cpp @@ -28,6 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "UI/UIContext.h" // for Input structures +#include + //Windows Xinput support #ifdef DAEDALUS_WIN32 #include @@ -368,10 +370,10 @@ u32 IInputManager::GetConfigurationFromName( const char * name ) const } static bool toggle_fullscreen = false; +static s16 button = 0; void sceCtrlPeekBufferPositive(SceCtrlData *data, int count){ SDL_Event event; - memset(data, 0, sizeof(*data)); SDL_PumpEvents(); while (SDL_PeepEvents( &event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) != 0) @@ -404,35 +406,106 @@ void sceCtrlPeekBufferPositive(SceCtrlData *data, int count){ } } - if (event.key.keysym.scancode == SDL_SCANCODE_UP) {data->Ly = +80;} - if (event.key.keysym.scancode == SDL_SCANCODE_DOWN) {data->Ly = -80;} - if (event.key.keysym.scancode == SDL_SCANCODE_LEFT) {data->Lx = -80;} - if (event.key.keysym.scancode == SDL_SCANCODE_RIGHT) {data->Lx = +80;} + // if (event.key.keysym.scancode == SDL_SCANCODE_UP) {data->Ly = +80;} + // if (event.key.keysym.scancode == SDL_SCANCODE_DOWN) {data->Ly = -80;} + // if (event.key.keysym.scancode == SDL_SCANCODE_LEFT) {data->Lx = -80;} + // if (event.key.keysym.scancode == SDL_SCANCODE_RIGHT) {data->Lx = +80;} - if (event.key.keysym.scancode == SDL_SCANCODE_X) {data->Buttons |= A_BUTTON;} - if (event.key.keysym.scancode == SDL_SCANCODE_C) {data->Buttons |= B_BUTTON;} - if (event.key.keysym.scancode == SDL_SCANCODE_Z) {data->Buttons |= Z_TRIG;} - if (event.key.keysym.scancode == SDL_SCANCODE_A) {data->Buttons |= L_TRIG;} - if (event.key.keysym.scancode == SDL_SCANCODE_S) {data->Buttons |= R_TRIG;} + if (event.key.keysym.scancode == SDL_SCANCODE_X) {button |= A_BUTTON;} + if (event.key.keysym.scancode == SDL_SCANCODE_C) {button |= B_BUTTON;} + if (event.key.keysym.scancode == SDL_SCANCODE_Z) {button |= Z_TRIG;} + if (event.key.keysym.scancode == SDL_SCANCODE_A) {button |= L_TRIG;} + if (event.key.keysym.scancode == SDL_SCANCODE_S) {button |= R_TRIG;} - if (event.key.keysym.scancode == SDL_SCANCODE_RETURN) {data->Buttons |= START_BUTTON;} + if (event.key.keysym.scancode == SDL_SCANCODE_RETURN) {button |= START_BUTTON;} - if (event.key.keysym.scancode == SDL_SCANCODE_KP_8){ data->Buttons |= U_JPAD;} - if (event.key.keysym.scancode == SDL_SCANCODE_KP_2){ data->Buttons |= D_JPAD;} - if (event.key.keysym.scancode == SDL_SCANCODE_KP_4){ data->Buttons |= L_JPAD;} - if (event.key.keysym.scancode == SDL_SCANCODE_KP_6){ data->Buttons |= R_JPAD;} + if (event.key.keysym.scancode == SDL_SCANCODE_UP){ button |= U_JPAD;} + if (event.key.keysym.scancode == SDL_SCANCODE_DOWN){ button |= D_JPAD;} + if (event.key.keysym.scancode == SDL_SCANCODE_LEFT){ button |= L_JPAD;} + if (event.key.keysym.scancode == SDL_SCANCODE_RIGHT){ button |= R_JPAD;} - if (event.key.keysym.scancode == SDL_SCANCODE_HOME){ data->Buttons |= U_CBUTTONS;} - if (event.key.keysym.scancode == SDL_SCANCODE_END){ data->Buttons |= D_CBUTTONS;} - if (event.key.keysym.scancode == SDL_SCANCODE_DELETE){ data->Buttons |= L_CBUTTONS;} - if (event.key.keysym.scancode == SDL_SCANCODE_PAGEDOWN){ data->Buttons |= R_CBUTTONS;} + if (event.key.keysym.scancode == SDL_SCANCODE_HOME){ button |= U_CBUTTONS;} + if (event.key.keysym.scancode == SDL_SCANCODE_END){ button |= D_CBUTTONS;} + if (event.key.keysym.scancode == SDL_SCANCODE_DELETE){ button |= L_CBUTTONS;} + if (event.key.keysym.scancode == SDL_SCANCODE_PAGEDOWN){ button |= R_CBUTTONS;} + } + else if(event.type == SDL_KEYUP) + { + if (event.key.keysym.scancode == SDL_SCANCODE_X) {button &= ~A_BUTTON;} + if (event.key.keysym.scancode == SDL_SCANCODE_C) {button &= ~B_BUTTON;} + if (event.key.keysym.scancode == SDL_SCANCODE_Z) {button &= ~Z_TRIG;} + if (event.key.keysym.scancode == SDL_SCANCODE_A) {button &= ~L_TRIG;} + if (event.key.keysym.scancode == SDL_SCANCODE_S) {button &= ~R_TRIG;} + + if (event.key.keysym.scancode == SDL_SCANCODE_RETURN) {button &= ~START_BUTTON;} + + if (event.key.keysym.scancode == SDL_SCANCODE_UP){ button &= ~U_JPAD;} + if (event.key.keysym.scancode == SDL_SCANCODE_DOWN){ button &= ~D_JPAD;} + if (event.key.keysym.scancode == SDL_SCANCODE_LEFT){ button &= ~L_JPAD;} + if (event.key.keysym.scancode == SDL_SCANCODE_RIGHT){ button &= ~R_JPAD;} + + if (event.key.keysym.scancode == SDL_SCANCODE_HOME){ button &= ~U_CBUTTONS;} + if (event.key.keysym.scancode == SDL_SCANCODE_END){ button &= ~D_CBUTTONS;} + if (event.key.keysym.scancode == SDL_SCANCODE_DELETE){ button &= ~L_CBUTTONS;} + if (event.key.keysym.scancode == SDL_SCANCODE_PAGEDOWN){ button &= ~R_CBUTTONS;} } } + + data->Buttons = button; + data->Lx = 128; + data->Ly = 128; +} + + +//************************************************************************************* +// +//************************************************************************************* +v2 ProjectToUnitSquare( const v2 & in ) +{ + f32 length( in.Length() ); + float abs_x( fabsf( in.x ) ); + float abs_y( fabsf( in.y ) ); + float scale; + + // + // Select the longest axis, and + // + if( length < 0.01f ) + { + scale = 1.0f; + } + else if( abs_x > abs_y ) + { + scale = length / abs_x; + } + else + { + scale = length / abs_y; + } + + return in * scale; } +//************************************************************************************* +// +//************************************************************************************* v2 ApplyDeadzone( const v2 & in, f32 min_deadzone, f32 max_deadzone ) { - return in; +#ifdef DAEDALUS_ENABLE_ASSERTS + + DAEDALUS_ASSERT( min_deadzone >= 0.0f && min_deadzone <= 1.0f, "Invalid min deadzone" ); + DAEDALUS_ASSERT( max_deadzone >= 0.0f && max_deadzone <= 1.0f, "Invalid max deadzone" ); +#endif + float length( in.Length() ); + + if( length < min_deadzone ) + return v2( 0,0 ); + + float scale( ( length - min_deadzone ) / ( max_deadzone - min_deadzone ) ); + + scale = std::clamp( scale, 0.0f, 1.0f ); + + return ProjectToUnitSquare( in * (scale / length) ); } void sceKernelExitGame() { From 659331f611097c4a0f3c3ee5ed3670b7f7f211eb Mon Sep 17 00:00:00 2001 From: Howard Su Date: Wed, 6 Dec 2023 14:29:07 +0800 Subject: [PATCH 12/54] Fix CI --- .github/workflows/compilation.yml | 16 ++++++++-------- Source/SysPSP/Utility/CMakeLists.txt | 3 +-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index 9ab5cd53b..f00175c89 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -81,7 +81,7 @@ jobs: - name: Install dependencies run: | - sudo apt install build-essential git bash cmake libpng-dev libz-dev libminizip-dev libsdl2-dev libglew-dev + sudo apt install build-essential git bash cmake libpng-dev libz-dev libminizip-dev libsdl2-dev libsdl2-ttf-dev libglew-dev - name: Compile project run: | @@ -99,9 +99,9 @@ jobs: DaedalusX64/roms.ini \ DaedalusX64/readme.txt \ DaedalusX64/copying.txt \ -# DaedalusX64/Resources \ # Not used in Posix Buiilds -# DaedalusX64/Languages \ # Not used in Posix Builds -# DaedalusX64/ControllerConfigs \ # Not used in Posix Builds + DaedalusX64/Resources \ + DaedalusX64/Languages \ + DaedalusX64/ControllerConfigs \ - name: Upload artifacts @@ -147,7 +147,7 @@ jobs: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - name: Install dependencies run: | - brew install git bash cmake libpng minizip sdl2 glew + brew install git bash cmake libpng minizip sdl2 sdl2_ttf glew - name: Compile project run: | @@ -165,9 +165,9 @@ jobs: DaedalusX64/roms.ini \ DaedalusX64/readme.txt \ DaedalusX64/copying.txt \ -# DaedalusX64/Resources \ # Not used in Posix Buiilds -# DaedalusX64/Languages \ # Not used in Posix Builds -# DaedalusX64/ControllerConfigs \ # Not used in Posix Builds + DaedalusX64/Resources \ + DaedalusX64/Languages \ + DaedalusX64/ControllerConfigs \ - name: Upload artifacts diff --git a/Source/SysPSP/Utility/CMakeLists.txt b/Source/SysPSP/Utility/CMakeLists.txt index 5bc340044..fd2bd9671 100644 --- a/Source/SysPSP/Utility/CMakeLists.txt +++ b/Source/SysPSP/Utility/CMakeLists.txt @@ -5,8 +5,7 @@ add_library(Utility_PSP OBJECT DisableFPUExceptions.S exception.cpp FastMemcpyPSP.cpp - ModulePSP.cpp - Translate.cpp + ModulePSP.cpp VolatileMemPSP.cpp ${PROJECT_SOURCE_DIR}/Source/SysPosix/Utility/TimingPosix.cpp ${PROJECT_SOURCE_DIR}/Source/SysPosix/Utility/ThreadPosix.cpp From e2f0ffa95f94f37dabad0e6437bcfedfbb93a3ca Mon Sep 17 00:00:00 2001 From: Howard Su Date: Wed, 6 Dec 2023 14:46:22 +0800 Subject: [PATCH 13/54] More fixes on PSP --- Source/SysGL/Graphics/DrawTextSDL.cpp | 6 +++--- Source/SysPSP/Graphics/DrawTextPSP.cpp | 2 +- Source/UI/PSPMenu.h | 8 +++++--- Source/UI/UIContext.h | 4 ++++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Source/SysGL/Graphics/DrawTextSDL.cpp b/Source/SysGL/Graphics/DrawTextSDL.cpp index 120db77bc..efb54e164 100644 --- a/Source/SysGL/Graphics/DrawTextSDL.cpp +++ b/Source/SysGL/Graphics/DrawTextSDL.cpp @@ -10,7 +10,7 @@ DAEDALUS_STATIC_ASSERT(ARRAYSIZE(gFonts) == CDrawText::NUM_FONTS); void CDrawText::Initialise() { - gFonts[CDrawText::F_REGULAR] = TTF_OpenFont("Resources/OpenSans-Regular.ttf", 16); + gFonts[CDrawText::F_REGULAR] = TTF_OpenFont("Resources/OpenSans-Regular.ttf", 12); gFonts[CDrawText::F_LARGE_BOLD] = TTF_OpenFont("Resources/OpenSans-Regular.ttf", 24); if (gFonts[0] == 0) @@ -52,8 +52,8 @@ u32 CDrawText::Render(EFont font_type, s32 x, s32 y, float scale, const char *p_ SDL_Rect Message_rect; //create a rect Message_rect.x = x; //controls the rect's x coordinate Message_rect.y = y; // controls the rect's y coordinte - Message_rect.w = surface->w; // controls the width of the rect - Message_rect.h = surface->h; // controls the height of the rect + Message_rect.w = surface->w * scale; // controls the width of the rect + Message_rect.h = surface->h * scale; // controls the height of the rect SDL_RenderCopy(gSdlRenderer, Message, NULL, &Message_rect); diff --git a/Source/SysPSP/Graphics/DrawTextPSP.cpp b/Source/SysPSP/Graphics/DrawTextPSP.cpp index a3b03d7d5..32c7700ca 100644 --- a/Source/SysPSP/Graphics/DrawTextPSP.cpp +++ b/Source/SysPSP/Graphics/DrawTextPSP.cpp @@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Macros.h" #include "Interface/Preferences.h" -#include "SysPSP/Utility/Translate.h" +#include "Utility/Translate.h" intraFont *gFonts[] = { diff --git a/Source/UI/PSPMenu.h b/Source/UI/PSPMenu.h index 83b14a53b..53be38f8c 100644 --- a/Source/UI/PSPMenu.h +++ b/Source/UI/PSPMenu.h @@ -110,8 +110,8 @@ const char * const TITLE_TEXT = "Adjust Stick Deadzone"; // Make more sane const u32 TITLE_Y = 10; -const u32 HALF_WIDTH( 480 / 2 ); -const u32 CENTRE_X( 480 / 2 ); +const u32 HALF_WIDTH( SCREEN_WIDTH / 2 ); +const u32 CENTRE_X( SCREEN_WIDTH / 2 ); const u32 DISPLAY_WIDTH( 128 ); const u32 DISPLAY_RADIUS( DISPLAY_WIDTH / 2 ); @@ -134,11 +134,13 @@ const f32 DEFAULT_MAX_DEADZONE = 1.0f; const char * const gRomsDirectories[] = { - "ms0:/n64/", "Roms/" , +#ifdef DAEDALUS_PSP #ifndef DAEDALUS_SILENT // For ease of developing with multiple source trees, common folder for roms can be placed at host1: in usbhostfs "host1:/", +#endif + "ms0:/n64/", #endif }; diff --git a/Source/UI/UIContext.h b/Source/UI/UIContext.h index cad748792..857c425d8 100644 --- a/Source/UI/UIContext.h +++ b/Source/UI/UIContext.h @@ -107,7 +107,11 @@ class CUIContext //############################################### Emulate PSP API for now ################################ #ifdef DAEDALUS_PSP + #include + #include #include + #include + #include #include #else #include "Ultra/ultra_os.h" From d6c79f13e15a55a26c96d5f872c48f8fc2dad2f4 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Wed, 6 Dec 2023 15:40:14 +0800 Subject: [PATCH 14/54] Fix build --- Source/CMakeLists.txt | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 4bf6f0ce8..6d940098e 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -115,15 +115,6 @@ endif() option(DAEDALUS_ENABLE_OS_HOOKS " High Level Emulation Hooks" ON) endif() - if(DAEDALUS_SDL) - find_package(SDL2 CONFIG REQUIRED) - list(APPEND default_libraries "${SDL2_LIBRARIES}") - list(APPEND include_dirs "${SDL2_INCLUDE_DIRS}") - - find_package(SDL2_ttf CONFIG REQUIRED) - list(APPEND default_libraries "SDL2_ttf-2.0") - endif(DAEDALUS_SDL) - # Needed below the options to post process include(${PROJECT_SOURCE_DIR}/Options.cmake) @@ -219,9 +210,22 @@ if(WIN32) # --- Build ---- add_executable(daedalus ${plat_main}) - list(APPEND default_libraries png z) ## Required Libraries - - message(" ${daed_libs} ${default_libraries} ${sys_libraries} " ) + +if(DAEDALUS_SDL) + find_package(SDL2 CONFIG REQUIRED) + target_link_libraries(daedalus PRIVATE SDL2::SDL2) + + find_package(SDL2_ttf REQUIRED) + target_link_libraries(daedalus PRIVATE SDL2_ttf::SDL2_ttf) +endif(DAEDALUS_SDL) + + + find_package(ZLIB REQUIRED) + target_link_libraries(daedalus PRIVATE ZLIB::ZLIB) + + find_package(PNG REQUIRED) + target_link_libraries(daedalus PRIVATE PNG::PNG) + target_include_directories(daedalus BEFORE PUBLIC ${include_dirs}) target_link_libraries(daedalus PRIVATE ${daed_libs} ${default_libraries} ${sys_libraries}) From ae1b89b1ae3cc5be5956796c31dce6a60e70974f Mon Sep 17 00:00:00 2001 From: Howard Su Date: Wed, 6 Dec 2023 15:48:53 +0800 Subject: [PATCH 15/54] Add cmake modeul for sdl2 ttf --- CMakeLists.txt | 2 + cmake/sdl2_ttf-config.cmake | 94 +++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 cmake/sdl2_ttf-config.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b77233448..1501a468d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.16) project (DaedalusX64 LANGUAGES C CXX ASM) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") + message(${CMAKE_SYSTEM_PROCESSOR} " Detected") add_subdirectory(Source) \ No newline at end of file diff --git a/cmake/sdl2_ttf-config.cmake b/cmake/sdl2_ttf-config.cmake new file mode 100644 index 000000000..814203e22 --- /dev/null +++ b/cmake/sdl2_ttf-config.cmake @@ -0,0 +1,94 @@ +# sdl2_ttf cmake project-config input for ./configure scripts + +include(FeatureSummary) +set_package_properties(SDL2_ttf PROPERTIES + URL "https://www.libsdl.org/projects/SDL_ttf/" + DESCRIPTION "Support for TrueType (.ttf) font files with Simple Directmedia Layer" +) + +set(SDL2_ttf_FOUND TRUE) + +set(SDL2TTF_HARFBUZZ 1) +set(SDL2TTF_FREETYPE TRUE) + +set(SDL2TTF_VENDORED 0) + +set(SDL2TTF_SDL2_REQUIRED_VERSION 2.0.10) + +get_filename_component(prefix "${CMAKE_CURRENT_LIST_DIR}/../../../.." ABSOLUTE) +set(exec_prefix "${prefix}") +set(bindir "${exec_prefix}/bin") +set(includedir "${prefix}/include") +set(libdir "${prefix}/lib/x86_64-linux-gnu") +set(_sdl2ttf_extra_static_libraries " -lfreetype -lharfbuzz ") +string(STRIP "${_sdl2ttf_extra_static_libraries}" _sdl2ttf_extra_static_libraries) + +set(_sdl2ttf_bindir "${bindir}") +set(_sdl2ttf_libdir "${libdir}") +set(_sdl2ttf_incdir "${includedir}/SDL2") + +# Convert _sdl2ttf_extra_static_libraries to list and keep only libraries +string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)" _sdl2ttf_extra_static_libraries "${_sdl2ttf_extra_static_libraries}") +string(REGEX REPLACE "^-l" "" _sdl2ttf_extra_static_libraries "${_sdl2ttf_extra_static_libraries}") +string(REGEX REPLACE ";-l" ";" _sdl2ttf_extra_static_libraries "${_sdl2ttf_extra_static_libraries}") + +unset(prefix) +unset(exec_prefix) +unset(bindir) +unset(includedir) +unset(libdir) + +include(CMakeFindDependencyMacro) + +if(NOT TARGET SDL2_ttf::SDL2_ttf) + if(WIN32) + set(_sdl2ttf_dll "${_sdl2ttf_bindir}/SDL2_ttf.dll") + set(_sdl2ttf_imp "${_sdl2ttf_libdir}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2_ttf.dll${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(EXISTS "${_sdl2ttf_dll}" AND EXISTS "${_sdl2ttf_imp}") + add_library(SDL2_ttf::SDL2_ttf SHARED IMPORTED) + set_target_properties(SDL2_ttf::SDL2_ttf + PROPERTIES + IMPORTED_LOCATION "${_sdl2ttf_dll}" + IMPORTED_IMPLIB "${_sdl2ttf_imp}" + ) + endif() + unset(_sdl2ttf_dll) + unset(_sdl2ttf_imp) + else() + set(_sdl2ttf_shl "${_sdl2ttf_libdir}/${CMAKE_SHARED_LIBRARY_PREFIX}SDL2_ttf${CMAKE_SHARED_LIBRARY_SUFFIX}") + if(EXISTS "${_sdl2ttf_shl}") + add_library(SDL2_ttf::SDL2_ttf SHARED IMPORTED) + set_target_properties(SDL2_ttf::SDL2_ttf + PROPERTIES + IMPORTED_LOCATION "${_sdl2ttf_shl}" + ) + endif() + endif() + if(TARGET SDL2_ttf::SDL2_ttf) + set_target_properties(SDL2_ttf::SDL2_ttf + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_sdl2ttf_incdir}" + COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED" + INTERFACE_SDL2_SHARED "ON" + ) + endif() +endif() + +if(NOT TARGET SDL2_ttf::SDL2_ttf-static) + set(_sdl2ttf_stl "${_sdl2ttf_libdir}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2_ttf${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(EXISTS "${_sdl2ttf_stl}") + add_library(SDL2_ttf::SDL2_ttf-static STATIC IMPORTED) + set_target_properties(SDL2_ttf::SDL2_ttf-static + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_sdl2ttf_incdir}" + IMPORTED_LOCATION "${_sdl2ttf_stl}" + INTERFACE_LINK_LIBRARIES "${_sdl2ttf_extra_static_libraries}" + ) + endif() + unset(_sdl2ttf_stl) +endif() + +unset(_sdl2ttf_extra_static_libraries) +unset(_sdl2ttf_bindir) +unset(_sdl2ttf_libdir) +unset(_sdl2ttf_incdir) From f6b4b7d6b76109a4fce7d99b1c9b2f796ceaf891 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Wed, 6 Dec 2023 15:53:50 +0800 Subject: [PATCH 16/54] fix psp build --- Source/SysPSP/Graphics/DrawTextPSP.cpp | 4 ++-- Source/SysPSP/Graphics/GraphicsContext.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/SysPSP/Graphics/DrawTextPSP.cpp b/Source/SysPSP/Graphics/DrawTextPSP.cpp index 32c7700ca..32d4d50c1 100644 --- a/Source/SysPSP/Graphics/DrawTextPSP.cpp +++ b/Source/SysPSP/Graphics/DrawTextPSP.cpp @@ -93,7 +93,7 @@ u32 CDrawText::Render(EFont font_type, s32 x, s32 y, float scale, const char *p_ sceGuEnable(GU_BLEND); sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); intraFontSetStyle(font, scale, colour.GetColour(), drop_colour.GetColour(), 0, INTRAFONT_ALIGN_LEFT); - return s32(intraFontPrintEx(font, x, y, Translate(p_str, length), length)) - x; + return s32(intraFontPrintEx(font, x, y, Translate_Strings(p_str, length), length)) - x; } return strlen(p_str) * 16; // Guess. Better off just returning 0? @@ -111,7 +111,7 @@ s32 CDrawText::GetTextWidth(EFont font_type, const char *p_str, u32 length) if (font) { intraFontSetStyle(font, 1.0f, 0xffffffff, 0xffffffff, 0, INTRAFONT_ALIGN_LEFT); - return s32(intraFontMeasureTextEx(font, Translate(p_str, length), length)); + return s32(intraFontMeasureTextEx(font, Translate_Strings(p_str, length), length)); } return strlen(p_str) * 16; // Return a reasonable value. Better off just returning 0? diff --git a/Source/SysPSP/Graphics/GraphicsContext.cpp b/Source/SysPSP/Graphics/GraphicsContext.cpp index 1bfaea7de..10b758c35 100644 --- a/Source/SysPSP/Graphics/GraphicsContext.cpp +++ b/Source/SysPSP/Graphics/GraphicsContext.cpp @@ -35,6 +35,7 @@ #include "Graphics/PngUtil.h" #include "SysPSP/Graphics/VideoMemoryManager.h" #include "System/IO.h" +#include "UI/DrawText.h" #include "Interface/Preferences.h" #include "Utility/Profiler.h" #include "Utility/VolatileMem.h" From 1b5472be45d6719d6a27ec5e34fd4bece40a131c Mon Sep 17 00:00:00 2001 From: Howard Su Date: Wed, 6 Dec 2023 18:24:33 +0800 Subject: [PATCH 17/54] Add more UI elements --- Source/SysGL/Graphics/DrawTextSDL.cpp | 5 +++-- Source/SysGL/Graphics/UIContextGL.cpp | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Source/SysGL/Graphics/DrawTextSDL.cpp b/Source/SysGL/Graphics/DrawTextSDL.cpp index efb54e164..d63af2621 100644 --- a/Source/SysGL/Graphics/DrawTextSDL.cpp +++ b/Source/SysGL/Graphics/DrawTextSDL.cpp @@ -10,8 +10,9 @@ DAEDALUS_STATIC_ASSERT(ARRAYSIZE(gFonts) == CDrawText::NUM_FONTS); void CDrawText::Initialise() { - gFonts[CDrawText::F_REGULAR] = TTF_OpenFont("Resources/OpenSans-Regular.ttf", 12); - gFonts[CDrawText::F_LARGE_BOLD] = TTF_OpenFont("Resources/OpenSans-Regular.ttf", 24); + gFonts[CDrawText::F_REGULAR] = TTF_OpenFont("Resources/OpenSans.ttf", 12); + gFonts[CDrawText::F_LARGE_BOLD] = TTF_OpenFont("Resources/OpenSans.ttf", 24); + TTF_SetFontStyle(gFonts[CDrawText::F_LARGE_BOLD], TTF_STYLE_BOLD); if (gFonts[0] == 0) { diff --git a/Source/SysGL/Graphics/UIContextGL.cpp b/Source/SysGL/Graphics/UIContextGL.cpp index 19d00cd2e..dd6f90388 100644 --- a/Source/SysGL/Graphics/UIContextGL.cpp +++ b/Source/SysGL/Graphics/UIContextGL.cpp @@ -198,15 +198,29 @@ void IUIContext::ClearBackground( c32 colour ) CGraphicsContext::Get()->ClearColBufferAndDepth( colour ); } - void IUIContext::DrawRect( s32 x, s32 y, u32 w, u32 h, c32 colour ) { - + SDL_Rect rect; + rect.x = x; + rect.y = y; + rect.w = w; + rect.h = h; + SDL_SetRenderDrawColor(gSdlRenderer, + colour.GetR(), + colour.GetG(), + colour.GetG(), + colour.GetA()); + SDL_RenderDrawRect(gSdlRenderer, &rect); } void IUIContext::DrawLine( s32 x0, s32 y0, s32 x1, s32 y1, c32 colour ) { - + SDL_SetRenderDrawColor(gSdlRenderer, + colour.GetR(), + colour.GetG(), + colour.GetG(), + colour.GetA()); + SDL_RenderDrawLine(gSdlRenderer, x0, y0, x1, y1); } From 860980ce8791d15255924dc1fee39825c1cd5b0e Mon Sep 17 00:00:00 2001 From: Howard Su Date: Thu, 7 Dec 2023 00:39:34 +0800 Subject: [PATCH 18/54] Fix PSP build --- Source/UI/UIContext.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/UI/UIContext.h b/Source/UI/UIContext.h index 857c425d8..b4abd18ff 100644 --- a/Source/UI/UIContext.h +++ b/Source/UI/UIContext.h @@ -113,6 +113,8 @@ class CUIContext #include #include #include + #include + #include #else #include "Ultra/ultra_os.h" From 7ee50483035514dc5dcf31860a146965c3566317 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Thu, 7 Dec 2023 00:41:09 +0800 Subject: [PATCH 19/54] Rename sdl2_ttf-config.cmake to FindSDL2_ttf.cmake Try to fix Linux build --- cmake/{sdl2_ttf-config.cmake => FindSDL2_ttf.cmake} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cmake/{sdl2_ttf-config.cmake => FindSDL2_ttf.cmake} (100%) diff --git a/cmake/sdl2_ttf-config.cmake b/cmake/FindSDL2_ttf.cmake similarity index 100% rename from cmake/sdl2_ttf-config.cmake rename to cmake/FindSDL2_ttf.cmake From 15bc0f56394ae3f4781b3a515dc1f91c770e33f2 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Thu, 7 Dec 2023 00:44:43 +0800 Subject: [PATCH 20/54] Fix PSP Build --- Source/SysPSP/UIContext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/SysPSP/UIContext.cpp b/Source/SysPSP/UIContext.cpp index 3fda7e4ee..7f1584fc9 100644 --- a/Source/SysPSP/UIContext.cpp +++ b/Source/SysPSP/UIContext.cpp @@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Math/Matrix4x4.h" #include "Graphics/GraphicsContext.h" #include "Graphics/NativeTexture.h" -#include "SysPSP/Graphics/DrawText.h" +#include "UI/DrawText.h" #include "UI/UIContext.h" #include "UI/DrawTextUtilities.h" From f1ebb4629a9b162c0b845513c8fa77e3bf5df5d7 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Thu, 7 Dec 2023 00:45:24 +0800 Subject: [PATCH 21/54] Fix PSP build --- Source/SysPSP/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/SysPSP/main.cpp b/Source/SysPSP/main.cpp index 0bb2901ff..92cb2c284 100644 --- a/Source/SysPSP/main.cpp +++ b/Source/SysPSP/main.cpp @@ -52,7 +52,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "HLEGraphics/TextureCache.h" #include "Input/InputManager.h" #include "Interface/RomDB.h" -#include "SysPSP/Graphics/DrawText.h" +#include "UI/DrawText.h" #include "UI/MainMenuScreen.h" #include "UI/PauseScreen.h" #include "UI/SplashScreen.h" From 62a5ac5c5622a75d9c602d142dc6cea78ecf75dd Mon Sep 17 00:00:00 2001 From: Howard Su Date: Thu, 7 Dec 2023 00:50:05 +0800 Subject: [PATCH 22/54] Fix PSP build --- Source/SysPSP/UIContext.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/SysPSP/UIContext.cpp b/Source/SysPSP/UIContext.cpp index 7f1584fc9..6841bc064 100644 --- a/Source/SysPSP/UIContext.cpp +++ b/Source/SysPSP/UIContext.cpp @@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Graphics/NativeTexture.h" #include "UI/DrawText.h" #include "UI/UIContext.h" +#include "Utility/Translate.h" #include "UI/DrawTextUtilities.h" From 97e844e8a38477a6a6fa64d44021b5dca391f524 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Thu, 7 Dec 2023 00:52:11 +0800 Subject: [PATCH 23/54] Revert the sdl2_ttf cmake module --- CMakeLists.txt | 2 - cmake/FindSDL2_ttf.cmake | 94 ---------------------------------------- 2 files changed, 96 deletions(-) delete mode 100644 cmake/FindSDL2_ttf.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 1501a468d..b77233448 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,6 @@ cmake_minimum_required(VERSION 3.16) project (DaedalusX64 LANGUAGES C CXX ASM) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") - message(${CMAKE_SYSTEM_PROCESSOR} " Detected") add_subdirectory(Source) \ No newline at end of file diff --git a/cmake/FindSDL2_ttf.cmake b/cmake/FindSDL2_ttf.cmake deleted file mode 100644 index 814203e22..000000000 --- a/cmake/FindSDL2_ttf.cmake +++ /dev/null @@ -1,94 +0,0 @@ -# sdl2_ttf cmake project-config input for ./configure scripts - -include(FeatureSummary) -set_package_properties(SDL2_ttf PROPERTIES - URL "https://www.libsdl.org/projects/SDL_ttf/" - DESCRIPTION "Support for TrueType (.ttf) font files with Simple Directmedia Layer" -) - -set(SDL2_ttf_FOUND TRUE) - -set(SDL2TTF_HARFBUZZ 1) -set(SDL2TTF_FREETYPE TRUE) - -set(SDL2TTF_VENDORED 0) - -set(SDL2TTF_SDL2_REQUIRED_VERSION 2.0.10) - -get_filename_component(prefix "${CMAKE_CURRENT_LIST_DIR}/../../../.." ABSOLUTE) -set(exec_prefix "${prefix}") -set(bindir "${exec_prefix}/bin") -set(includedir "${prefix}/include") -set(libdir "${prefix}/lib/x86_64-linux-gnu") -set(_sdl2ttf_extra_static_libraries " -lfreetype -lharfbuzz ") -string(STRIP "${_sdl2ttf_extra_static_libraries}" _sdl2ttf_extra_static_libraries) - -set(_sdl2ttf_bindir "${bindir}") -set(_sdl2ttf_libdir "${libdir}") -set(_sdl2ttf_incdir "${includedir}/SDL2") - -# Convert _sdl2ttf_extra_static_libraries to list and keep only libraries -string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)" _sdl2ttf_extra_static_libraries "${_sdl2ttf_extra_static_libraries}") -string(REGEX REPLACE "^-l" "" _sdl2ttf_extra_static_libraries "${_sdl2ttf_extra_static_libraries}") -string(REGEX REPLACE ";-l" ";" _sdl2ttf_extra_static_libraries "${_sdl2ttf_extra_static_libraries}") - -unset(prefix) -unset(exec_prefix) -unset(bindir) -unset(includedir) -unset(libdir) - -include(CMakeFindDependencyMacro) - -if(NOT TARGET SDL2_ttf::SDL2_ttf) - if(WIN32) - set(_sdl2ttf_dll "${_sdl2ttf_bindir}/SDL2_ttf.dll") - set(_sdl2ttf_imp "${_sdl2ttf_libdir}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2_ttf.dll${CMAKE_STATIC_LIBRARY_SUFFIX}") - if(EXISTS "${_sdl2ttf_dll}" AND EXISTS "${_sdl2ttf_imp}") - add_library(SDL2_ttf::SDL2_ttf SHARED IMPORTED) - set_target_properties(SDL2_ttf::SDL2_ttf - PROPERTIES - IMPORTED_LOCATION "${_sdl2ttf_dll}" - IMPORTED_IMPLIB "${_sdl2ttf_imp}" - ) - endif() - unset(_sdl2ttf_dll) - unset(_sdl2ttf_imp) - else() - set(_sdl2ttf_shl "${_sdl2ttf_libdir}/${CMAKE_SHARED_LIBRARY_PREFIX}SDL2_ttf${CMAKE_SHARED_LIBRARY_SUFFIX}") - if(EXISTS "${_sdl2ttf_shl}") - add_library(SDL2_ttf::SDL2_ttf SHARED IMPORTED) - set_target_properties(SDL2_ttf::SDL2_ttf - PROPERTIES - IMPORTED_LOCATION "${_sdl2ttf_shl}" - ) - endif() - endif() - if(TARGET SDL2_ttf::SDL2_ttf) - set_target_properties(SDL2_ttf::SDL2_ttf - PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_sdl2ttf_incdir}" - COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED" - INTERFACE_SDL2_SHARED "ON" - ) - endif() -endif() - -if(NOT TARGET SDL2_ttf::SDL2_ttf-static) - set(_sdl2ttf_stl "${_sdl2ttf_libdir}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2_ttf${CMAKE_STATIC_LIBRARY_SUFFIX}") - if(EXISTS "${_sdl2ttf_stl}") - add_library(SDL2_ttf::SDL2_ttf-static STATIC IMPORTED) - set_target_properties(SDL2_ttf::SDL2_ttf-static - PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_sdl2ttf_incdir}" - IMPORTED_LOCATION "${_sdl2ttf_stl}" - INTERFACE_LINK_LIBRARIES "${_sdl2ttf_extra_static_libraries}" - ) - endif() - unset(_sdl2ttf_stl) -endif() - -unset(_sdl2ttf_extra_static_libraries) -unset(_sdl2ttf_bindir) -unset(_sdl2ttf_libdir) -unset(_sdl2ttf_incdir) From 02b610e7c78c2c19efd643eeeb538de4210e59b1 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Thu, 7 Dec 2023 00:54:07 +0800 Subject: [PATCH 24/54] Fix PSP build --- Source/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 6d940098e..506520eeb 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -215,8 +215,11 @@ if(DAEDALUS_SDL) find_package(SDL2 CONFIG REQUIRED) target_link_libraries(daedalus PRIVATE SDL2::SDL2) +if(NOT PSP) + # PSP is not needed as it uses built-in native font find_package(SDL2_ttf REQUIRED) target_link_libraries(daedalus PRIVATE SDL2_ttf::SDL2_ttf) +endif() endif(DAEDALUS_SDL) From 734ed8788dca7cef98d4d6b81ac01a7ce0628412 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Thu, 7 Dec 2023 22:56:38 +0800 Subject: [PATCH 25/54] Make Win32 build on Release --- Source/Base/Assert.h | 2 +- Source/Base/Types.h | 4 ++ Source/CMakeLists.txt | 68 +++++++----------- Source/Core/CPU.cpp | 4 +- Source/Core/Cheats.cpp | 7 +- Source/Core/Memory.cpp | 4 ++ Source/Core/RomSettings.cpp | 6 +- Source/Core/Save.cpp | 6 +- Source/Debug/Dump.cpp | 4 +- Source/DynaRec/CMakeLists.txt | 4 +- Source/DynaRec/dummy/AssemblyUtilsDummy.cpp | 3 +- Source/DynaRec/x64/CodeBufferManagerX64.cpp | 4 +- Source/DynaRec/x64/DynarecStubX64.asm | 27 +++++++ Source/Graphics/CMakeLists.txt | 2 + Source/HLEGraphics/BaseRenderer.h | 2 +- Source/HLEGraphics/CMakeLists.txt | 5 ++ Source/Interface/Preferences.cpp | 10 ++- Source/Interface/RomDB.cpp | 22 +++--- Source/OSHLE/patch.cpp | 4 +- Source/RomFile/RomFile.cpp | 4 +- Source/RomFile/RomFileUncompressed.cpp | 2 +- Source/SysCTR/Input/InputManagerCTR.cpp | 7 +- Source/SysGL/CMakeLists.txt | 29 +++++--- Source/SysGL/Graphics/CMakeLists.txt | 7 -- Source/SysGL/Graphics/DrawTextSDL.cpp | 2 +- Source/SysGL/Graphics/NativeTextureGL.cpp | 2 +- Source/SysGL/HLEGraphics/CMakeLists.txt | 8 --- Source/SysGL/HLEGraphics/RendererGL.cpp | 5 +- Source/SysGL/Input/CMakeLists.txt | 7 -- Source/SysGL/Input/InputManagerGL.cpp | 8 +-- Source/SysGL/Interface/CMakeLists.txt | 7 -- Source/SysPosix/HLEAudio/AudioPluginOSX.cpp | 4 -- Source/SysPosix/main.cpp | 80 ++++++++++----------- Source/SysW32/CMakeLists.txt | 8 +++ Source/SysW32/Debug/CMakeLists.txt | 2 +- Source/SysW32/HLEAudio/AudioPluginW32.cpp | 28 +++----- Source/SysW32/Interface/FileNameHandler.cpp | 23 +++--- Source/SysW32/Utility/CondW32.cpp | 6 +- Source/SysW32/Utility/IOW32.cpp | 1 + Source/SysW32/Utility/ThreadW32.cpp | 1 + Source/SysW32/Utility/TimingW32.cpp | 1 + Source/SysW32/main.cpp | 43 ++++++----- Source/System/CMakeLists.txt | 1 + Source/System/CompressedStream.cpp | 4 +- Source/System/DataSink.cpp | 2 +- Source/System/IO.h | 8 +-- Source/System/Mutex.h | 41 +---------- Source/System/SystemInit.cpp | 14 +++- Source/UI/CMakeLists.txt | 9 ++- Source/UI/RomSelectorComponent.cpp | 8 +-- Source/UI/SavestateSelectorComponent.cpp | 8 +-- Source/Utility/IniFile.cpp | 2 +- Source/Utility/Profiler.cpp | 2 - 53 files changed, 281 insertions(+), 291 deletions(-) create mode 100644 Source/DynaRec/x64/DynarecStubX64.asm delete mode 100644 Source/SysGL/Graphics/CMakeLists.txt delete mode 100644 Source/SysGL/HLEGraphics/CMakeLists.txt delete mode 100644 Source/SysGL/Input/CMakeLists.txt delete mode 100644 Source/SysGL/Interface/CMakeLists.txt diff --git a/Source/Base/Assert.h b/Source/Base/Assert.h index 5e873bdb5..fdc007f48 100644 --- a/Source/Base/Assert.h +++ b/Source/Base/Assert.h @@ -48,7 +48,7 @@ EAssertResult DAEDALUS_VARARG_CALL_TYPE DaedalusAssert( const char * expression, #define DAEDALUS_HALT __asm__ __volatile__ ( "bkpt" ) #elif DAEDALUS_W32 // Ugh this needs simplifying - #include "Sys32/Include/DaedalusW32.h" // Windows is special + // #define __PRETTY_FUNCTION__ __FUNCTION__ #define _CRT_SECURE_NO_DEPRECATE #define _DO_NOT_DECLARE_INTERLOCKED_INTRINSICS_IN_MEMORY diff --git a/Source/Base/Types.h b/Source/Base/Types.h index 275570419..a7fb1da37 100644 --- a/Source/Base/Types.h +++ b/Source/Base/Types.h @@ -85,4 +85,8 @@ union REG32 #define DATA_ALIGN 16 #define CACHE_ALIGN 64 +#ifdef _MSC_VER +#define strcasecmp _stricmp +#endif + #endif // UTILITY_DAEDALUSTYPES_H_ diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 506520eeb..db2898f39 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -43,6 +43,9 @@ endif() elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") message("x86_64 Dynarec Enabled") option(DAEDALUS_ENABLE_DYNAREC "Enable Dynarec" ON) + elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64") + message("AMD64 Dynarec Enabled") + option(DAEDALUS_ENABLE_DYNAREC "Enable Dynarec" ON) else() message("Platform unknown, Dynarec disabled") option(DAEDALUS_ENABLE_DYNAREC "Enable Dynarec" OFF) @@ -104,11 +107,13 @@ endif() option(DAEDALUS_DAEDALUS_ACCURATE_CVT "Convert using the rounding mode specified in the Floating Control/Status register (FCSR)") option(DAEDALUS_GL "OpenGL Renderer" ON) elseif(WIN32) - option(DAEDALUS_WIN32 "Windows specific Options" ON) + option(DAEDALUS_SDL "SDL Build" ON) + option(DAEDALUS_W32 "Windows specific Options" ON) option(DAEDALUS_ENABLE_DYNAREC "Enable Dynamic Recompilation, Disable if system not supported" ON) option(DAEDALUS_ACCURATE_TMEM "Accurate TMEM" ON) option(DAEDALUS_BREAKPOINTS_ENABLED "Enable Breakpoints" OFF) option(DAEDALUS_GL "OpenGL Renderer" ON) + enable_language(CXX ASM_MASM) elseif(CTR) option(DAEDALUS_CTR "3DS Specific Options" ON) option(DAEDALUS_ENABLE_DYNAREC "Enable Dynamic Recompilation" ON) @@ -122,11 +127,11 @@ endif() list(APPEND include_dirs "${PROJECT_SOURCE_DIR}/Source") include_directories( BEFORE ${include_dirs}) + add_compile_definitions(DAEDALUS_THREAD_CALL_TYPE=${}) + add_compile_definitions(DAEDALUS_VARARG_CALL_TYPE=${}) ## Generic defines for certain things that Windows requires. if(NOT WIN32) - add_compile_definitions(DAEDALUS_THREAD_CALL_TYPE=${}) - add_compile_definitions(DAEDALUS_VARARG_CALL_TYPE=${}) add_compile_options("-g") add_compile_options("-ffast-math") endif() @@ -154,29 +159,30 @@ if(CTR) include_directories($ENV{DEVKITPRO}/portlibs/3ds/lib) endif(CTR) -if(WIN32) - set(CMAKE_TOOLCHAIN_FILE ${VCPKG_TOOLCHAIN}) - find_package(ZLIB) +if(DAEDALUS_SDL) find_package(SDL2 CONFIG REQUIRED) - find_package(GLEW REQUIRED) - - set(sys_libraries png z minizip pthread GLEW SDL2 dl ${OS_LIBS}) - # Pull in modules for glew / SDL2 / ZLib / LibPNG / Minizip + link_libraries(SDL2::SDL2) + + if(NOT PSP) + # PSP is not needed as it uses built-in native font + find_package(SDL2_ttf REQUIRED) + link_libraries(SDL2_ttf::SDL2_ttf) + endif() +endif(DAEDALUS_SDL) -# add_library(sysGL OBJECT ${SYSGL_BUILD}) -# target_link_libraries(sysGL OpenGL32 glfw3 glew32s SDL2 Xinput ${OS_LIBS}) +if(DAEDALUS_GL) + find_package(OpenGL REQUIRED) + link_libraries(OpenGL::GL) -# add_library(daedalus.lib OBJECT ${BUILD} ${WIN_BUILD} ${AUDIO_DRIVER} ) -# target_link_libraries(daedalus.lib dsound dxguid sysGL libpng zlib zlibwapi) + find_package(GLEW REQUIRED) + link_libraries(GLEW::GLEW) +endif(DAEDALUS_GL) - #Build and Link Executable +find_package(PNG REQUIRED) +link_libraries(PNG::PNG) - add_executable(daedalus SysW32/main.cpp) - target_link_libraries(daedalus LINK_PUBLIC - Core Config Debug Graphics HLEAudio HLEGraphics Interface Math OSHLE RomFile System Utility - Graphics_GL HLEGraphics_GL Input_GL Interface_GL imgui - Win_Debug Win_Audio Win_Utility) - endif (WIN32) +find_package(ZLIB REQUIRED) +link_libraries(ZLIB::ZLIB) ## Daedalus Core Build add_subdirectory(Config) @@ -207,29 +213,9 @@ if(WIN32) add_subdirectory(SysPSP) endif() - # --- Build ---- add_executable(daedalus ${plat_main}) -if(DAEDALUS_SDL) - find_package(SDL2 CONFIG REQUIRED) - target_link_libraries(daedalus PRIVATE SDL2::SDL2) - -if(NOT PSP) - # PSP is not needed as it uses built-in native font - find_package(SDL2_ttf REQUIRED) - target_link_libraries(daedalus PRIVATE SDL2_ttf::SDL2_ttf) -endif() -endif(DAEDALUS_SDL) - - - find_package(ZLIB REQUIRED) - target_link_libraries(daedalus PRIVATE ZLIB::ZLIB) - - find_package(PNG REQUIRED) - target_link_libraries(daedalus PRIVATE PNG::PNG) - - target_include_directories(daedalus BEFORE PUBLIC ${include_dirs}) target_link_libraries(daedalus PRIVATE ${daed_libs} ${default_libraries} ${sys_libraries}) # --- Post Build --- diff --git a/Source/Core/CPU.cpp b/Source/Core/CPU.cpp index de006f759..5ae604806 100644 --- a/Source/Core/CPU.cpp +++ b/Source/Core/CPU.cpp @@ -434,7 +434,7 @@ bool CPU_RequestSaveState( const std::filesystem::path &filename ) } gSaveStateOperation = SSO_SAVE; - gSaveStateFilename = filename; + gSaveStateFilename = filename.string(); gCPUState.AddJob(CPU_CHANGE_CORE); return true; @@ -453,7 +453,7 @@ bool CPU_RequestLoadState( const std::filesystem::path &filename ) } gSaveStateOperation = SSO_LOAD; - gSaveStateFilename = filename; + gSaveStateFilename = filename.string(); gCPUState.AddJob(CPU_CHANGE_CORE); return true; // XXXX could fail diff --git a/Source/Core/Cheats.cpp b/Source/Core/Cheats.cpp index 53c22a16e..be09b91da 100644 --- a/Source/Core/Cheats.cpp +++ b/Source/Core/Cheats.cpp @@ -290,14 +290,11 @@ bool CheatCodes_Read(const char *rom_name, const char *file, u8 countryID) // Always clear when parsing a new ROM CheatCodes_Clear(); - std::filesystem::path p("cheat_file"); - const char *cheat_file = p.c_str(); - - stream = fopen(cheat_file, "rt"); + stream = fopen("cheat_file", "rt"); if(stream == nullptr) { // File does not exist, try to create a new empty one - stream = fopen(cheat_file, "wt"); + stream = fopen("cheat_file", "wt"); if(stream == nullptr) { diff --git a/Source/Core/Memory.cpp b/Source/Core/Memory.cpp index 036b5221f..878d893cc 100644 --- a/Source/Core/Memory.cpp +++ b/Source/Core/Memory.cpp @@ -40,6 +40,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "HLEAudio/AudioPlugin.h" #include "HLEGraphics/GraphicsPlugin.h" +#ifdef DAEDALUS_W32 +#include +#endif + static const u32 kMaximumMemSize = MEMORY_8_MEG; #undef min diff --git a/Source/Core/RomSettings.cpp b/Source/Core/RomSettings.cpp index 61e848660..77fa2cf6d 100644 --- a/Source/Core/RomSettings.cpp +++ b/Source/Core/RomSettings.cpp @@ -38,8 +38,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. namespace { - - // EExpansionPakUsage ExpansionPakUsageFromString( const char * str ) @@ -155,7 +153,7 @@ template<> bool CSingleton< CRomSettingsDB >::Create() mpInstance = std::make_shared(); std::filesystem::path p = baseDir; p /= "roms.ini"; - const char *ini_filename = p.c_str(); + const char *ini_filename = p.string().c_str(); mpInstance->OpenSettingsFile( ini_filename ); @@ -339,7 +337,7 @@ void IRomSettingsDB::Commit() return; } - FILE * fh_dst = fopen(filename_tmp.c_str(), "w"); + FILE * fh_dst = fopen(filename_tmp.string().c_str(), "w"); if (fh_dst == nullptr) { fclose(fh_src); diff --git a/Source/Core/Save.cpp b/Source/Core/Save.cpp index 0bddc4821..c39430c65 100644 --- a/Source/Core/Save.cpp +++ b/Source/Core/Save.cpp @@ -71,7 +71,7 @@ bool Save_Reset() { gSaveFileName = Save_As(g_ROM.mFileName, ext, "SaveGames/"); - FILE * fp = fopen(gSaveFileName.c_str(), "rb"); + FILE * fp = fopen(gSaveFileName.string().c_str(), "rb"); if (fp != nullptr) { DBGConsole_Msg(0, "Loading save from [C%s]", gSaveFileName.c_str()); @@ -99,7 +99,7 @@ bool Save_Reset() // init mempack, we always assume the presence of the mempack for simplicity { gSaveFileName = Save_As(g_ROM.mFileName, ".mpk", "SaveGames/"); - FILE * fp = fopen(gSaveFileName.c_str(), "rb"); + FILE * fp = fopen(gSaveFileName.string().c_str(), "rb"); if (fp != nullptr) { DBGConsole_Msg(0, "Loading MemPack from [C%s]", gSaveFileName.c_str()); @@ -142,7 +142,7 @@ void Save_Flush() { DBGConsole_Msg(0, "Saving to [C%s]", gSaveFileName.c_str()); - FILE * fp = fopen(gSaveFileName.c_str(), "wb"); + FILE * fp = fopen(gSaveFileName.string().c_str(), "wb"); if (fp != nullptr) { u8 buffer[2048]; diff --git a/Source/Debug/Dump.cpp b/Source/Debug/Dump.cpp index dcbf0c0cd..5767ef06a 100644 --- a/Source/Debug/Dump.cpp +++ b/Source/Debug/Dump.cpp @@ -52,9 +52,9 @@ void Dump_GetDumpDirectory(char * rootdir, const char * subdir) { // Initialise #if defined(DAEDALUS_DEBUG_DISPLAYLIST) || !defined(DAEDALUS_SILENT) - IO::Path::Combine(gDumpDir, gDaedalusExePath.c_str(), "Dumps"); + IO::Path::Combine(gDumpDir, gDaedalusExePath.string().c_str(), "Dumps"); #else - IO::Path::Combine(gDumpDir, gDaedalusExePath.c_str(), "ms0:/PICTURE/"); + IO::Path::Combine(gDumpDir, gDaedalusExePath.string().c_str(), "ms0:/PICTURE/"); #endif } diff --git a/Source/DynaRec/CMakeLists.txt b/Source/DynaRec/CMakeLists.txt index c919cd3ed..5c087ebfd 100644 --- a/Source/DynaRec/CMakeLists.txt +++ b/Source/DynaRec/CMakeLists.txt @@ -3,13 +3,13 @@ if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv") elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") file(GLOB SRC_FILES x64/*.cpp x64/*.S) elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64") - file(GLOB SRC_FILES x64/*.cpp x64/*.S) + file(GLOB SRC_FILES x64/*.cpp x64/*.asm) elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86") file(GLOB SRC_FILES x86/*.cpp x86/*.S) elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "mips") file(GLOB SRC_FILES mips/*.cpp mips/*.S) else() - file(GLOB SRC_FILES dummy/*.cpp dummy/*.S) + file(GLOB SRC_FILES dummy/*.cpp) endif() add_library(DynaRec OBJECT diff --git a/Source/DynaRec/dummy/AssemblyUtilsDummy.cpp b/Source/DynaRec/dummy/AssemblyUtilsDummy.cpp index 2cc0340ff..c1953d1f8 100644 --- a/Source/DynaRec/dummy/AssemblyUtilsDummy.cpp +++ b/Source/DynaRec/dummy/AssemblyUtilsDummy.cpp @@ -29,6 +29,7 @@ namespace AssemblyUtils //***************************************************************************** bool PatchJumpLong( CJumpLocation jump, CCodeLabel target ) { + return false; } //***************************************************************************** @@ -36,6 +37,6 @@ namespace AssemblyUtils //***************************************************************************** bool PatchJumpLongAndFlush( CJumpLocation jump, CCodeLabel target ) { - + return false; } } \ No newline at end of file diff --git a/Source/DynaRec/x64/CodeBufferManagerX64.cpp b/Source/DynaRec/x64/CodeBufferManagerX64.cpp index fdd4192d3..31bcfed77 100644 --- a/Source/DynaRec/x64/CodeBufferManagerX64.cpp +++ b/Source/DynaRec/x64/CodeBufferManagerX64.cpp @@ -24,7 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "DynaRec/CodeBufferManager.h" #include "CodeGeneratorX64.h" -#ifndef DAEDALUS_W32 +#ifdef DAEDALUS_W32 +#include +#else #include #endif diff --git a/Source/DynaRec/x64/DynarecStubX64.asm b/Source/DynaRec/x64/DynarecStubX64.asm new file mode 100644 index 000000000..062c5475e --- /dev/null +++ b/Source/DynaRec/x64/DynarecStubX64.asm @@ -0,0 +1,27 @@ +.code + +PUBLIC _EnterDynaRec + +_EnterDynaRec PROC + push rbp + push rbx + push r15 + push r14 + + + mov rax, rcx + mov rcx, rdx + mov r15, r8 + mov r14, r9 + + call qword ptr [rax] + + pop r14 + pop r15 + pop rbx + pop rbp + + ret +_EnterDynaRec ENDP + +END \ No newline at end of file diff --git a/Source/Graphics/CMakeLists.txt b/Source/Graphics/CMakeLists.txt index 1188b81fe..5a8e42dff 100644 --- a/Source/Graphics/CMakeLists.txt +++ b/Source/Graphics/CMakeLists.txt @@ -4,5 +4,7 @@ add_library(Graphics OBJECT TextureTransform.cpp ) +target_include_directories(Graphics PUBLIC ${PNG_INCLUDE_DIRS}) + list(APPEND daed_libs "Graphics") set(daed_libs ${daed_libs} PARENT_SCOPE) diff --git a/Source/HLEGraphics/BaseRenderer.h b/Source/HLEGraphics/BaseRenderer.h index 5042f28a3..7fbb9974b 100644 --- a/Source/HLEGraphics/BaseRenderer.h +++ b/Source/HLEGraphics/BaseRenderer.h @@ -270,7 +270,7 @@ class BaseRenderer #ifdef DAEDALUS_PSP inline void SetFogMinMax(f32 fog_near, f32 fog_far) { sceGuFog(fog_near, fog_far, mFogColour.GetColour()); } inline void SetFogColour( c32 colour ) { mFogColour = colour; } -#elif defined(DAEDALUS_VITA) || defined (DAEDALUS_CTR) || defined (DAEDALUS_POSIX) +#elif defined(DAEDALUS_VITA) || defined (DAEDALUS_CTR) || defined (DAEDALUS_GL) inline void SetFogMinMax(f32 fog_near, f32 fog_far) { glFogf(GL_FOG_START, fog_near); glFogf(GL_FOG_END, fog_far); } inline void SetFogColour( c32 colour ) { float fog_clr[4] = {colour.GetRf(), colour.GetGf(), colour.GetBf(), colour.GetAf()}; glFogfv(GL_FOG_COLOR, &fog_clr[0]); } #endif diff --git a/Source/HLEGraphics/CMakeLists.txt b/Source/HLEGraphics/CMakeLists.txt index 373c1aa56..4149a158d 100644 --- a/Source/HLEGraphics/CMakeLists.txt +++ b/Source/HLEGraphics/CMakeLists.txt @@ -15,5 +15,10 @@ add_library(HLEGraphics OBJECT uCodes/Ucode.cpp ) +if(DAEDALUS_GL) + message(STATUS "Building HLEGraphics with OpenGL support: ${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_DIRS}") + target_include_directories(HLEGraphics PUBLIC ${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_DIRS}) +endif(DAEDALUS_GL) + list(APPEND daed_libs "HLEGraphics") set(daed_libs ${daed_libs} PARENT_SCOPE) diff --git a/Source/Interface/Preferences.cpp b/Source/Interface/Preferences.cpp index d309509b3..dddf14622 100644 --- a/Source/Interface/Preferences.cpp +++ b/Source/Interface/Preferences.cpp @@ -85,7 +85,7 @@ class IPreferences : public CPreferences PreferencesMap mPreferences; bool mDirty; // (STRMNNRMN - Changed since read from disk?) - std::string mFilename; + std::filesystem::path mFilename; }; template<> bool CSingleton< CPreferences >::Create() @@ -105,10 +105,8 @@ CPreferences::~CPreferences() IPreferences::IPreferences() : mDirty( false ) { - - std::filesystem::path p = baseDir; - p /= "preferences.ini"; - const char *ini_filename = p.c_str(); + char ini_filename[128]; + IO::Path::Combine(ini_filename, baseDir.string().c_str(), "preferences.ini"); OpenPreferencesFile( ini_filename ); } @@ -329,7 +327,7 @@ void IPreferences::OutputSectionDetails( const RomID & id, const SRomPreferences // Write out the .ini file, keeping the original comments intact void IPreferences::Commit() { - FILE * fh( fopen(mFilename.c_str(), "w") ); + FILE * fh( fopen(mFilename.string().c_str(), "w") ); if (fh != NULL) { const SGlobalPreferences defaults; diff --git a/Source/Interface/RomDB.cpp b/Source/Interface/RomDB.cpp index df54979fb..525d6bd64 100644 --- a/Source/Interface/RomDB.cpp +++ b/Source/Interface/RomDB.cpp @@ -95,7 +95,7 @@ class IRomDB : public CRomDB RomFilesKeyValue( const std::filesystem::path filename, const RomID & id ) { memset( FileName, 0, sizeof( FileName ) ); - strcpy( FileName, filename.c_str() ); + strcpy( FileName, filename.string().c_str() ); ID = id; } @@ -172,7 +172,7 @@ template<> bool CSingleton< CRomDB >::Create() mpInstance = std::make_shared(); std::filesystem::path p = baseDir; p /= "rom.db"; - const char *romdb_filename = p.c_str(); + const char *romdb_filename = p.string().c_str(); /*ret = */mpInstance->OpenDB( romdb_filename ); @@ -204,9 +204,9 @@ bool IRomDB::OpenDB( const std::filesystem::path filename ) // // Remember the filename // - IO::Path::Assign( mRomDBFileName, filename.c_str() ); + IO::Path::Assign( mRomDBFileName, filename.string().c_str() ); - FILE * fh = fopen( filename.c_str(), "rb" ); + FILE * fh = fopen( filename.string().c_str(), "rb" ); if ( !fh ) { DBGConsole_Msg( 0, "Failed to open RomDB from %s\n", mRomDBFileName ); @@ -332,8 +332,8 @@ bool IRomDB::Commit() void IRomDB::AddRomEntry( const std::filesystem::path filename, const RomID & id, u32 rom_size, ECicType cic_type ) { // Update filename/id map - FilenameVec::iterator fit( std::lower_bound( mRomFiles.begin(), mRomFiles.end(), filename.c_str(), SSortByFilename() ) ); - if( fit != mRomFiles.end() && strcmp( fit->FileName, filename.c_str() ) == 0 ) + FilenameVec::iterator fit( std::lower_bound( mRomFiles.begin(), mRomFiles.end(), filename.string().c_str(), SSortByFilename() ) ); + if( fit != mRomFiles.end() && strcmp( fit->FileName, filename.string().c_str() ) == 0 ) { fit->ID = id; } @@ -367,15 +367,15 @@ void IRomDB::AddRomDirectory(const std::filesystem::path directory) IO::FindHandleT find_handle; IO::FindDataT find_data; - if(IO::FindFileOpen( directory.c_str(), &find_handle, find_data )) + if(IO::FindFileOpen( directory.string().c_str(), &find_handle, find_data )) { do { const std::filesystem::path rom_filename = find_data.Name; - if(IsRomfilename( rom_filename.c_str() )) + if(IsRomfilename( rom_filename.string().c_str() )) { IO::Filename full_path; - IO::Path::Combine(full_path, directory.c_str(), rom_filename.c_str()); + IO::Path::Combine(full_path, directory.string().c_str(), rom_filename.string().c_str()); AddRomFile(full_path); } @@ -460,8 +460,8 @@ bool IRomDB::QueryByFilename( const std::filesystem::path filename, RomID * id, // // First of all, check if we have these details cached in the rom database // - FilenameVec::const_iterator fit( std::lower_bound( mRomFiles.begin(), mRomFiles.end(), filename.c_str(), SSortByFilename() ) ); - if( fit != mRomFiles.end() && strcmp( fit->FileName, filename.c_str() ) == 0 ) + FilenameVec::const_iterator fit( std::lower_bound( mRomFiles.begin(), mRomFiles.end(), filename.string().c_str(), SSortByFilename() ) ); + if( fit != mRomFiles.end() && strcmp( fit->FileName, filename.string().c_str() ) == 0 ) { if( QueryByID( fit->ID, rom_size, cic_type ) ) { diff --git a/Source/OSHLE/patch.cpp b/Source/OSHLE/patch.cpp index 0175d1fd3..57688f9a6 100644 --- a/Source/OSHLE/patch.cpp +++ b/Source/OSHLE/patch.cpp @@ -950,7 +950,7 @@ static void Patch_FlushCache() std::filesystem::path name = Save_As(g_ROM.mFileName, ".hle", "SaveGames/Cache"); - FILE *fp = fopen(name.c_str(), "wb"); + FILE *fp = fopen(name.string().c_str(), "wb"); if (fp != nullptr) { @@ -1003,7 +1003,7 @@ static bool Patch_GetCache() { std::filesystem::path name = Save_As(g_ROM.mFileName, ".hle", "SaveGames/Cache"); - FILE *fp = fopen(name.c_str(), "rb"); + FILE *fp = fopen(name.string().c_str(), "rb"); if (fp != nullptr) { diff --git a/Source/RomFile/RomFile.cpp b/Source/RomFile/RomFile.cpp index e25c96891..438714f7f 100644 --- a/Source/RomFile/RomFile.cpp +++ b/Source/RomFile/RomFile.cpp @@ -52,7 +52,7 @@ bool IsRomfilename( const char * rom_filename ) std::shared_ptr ROMFile::Create( const std::filesystem::path filename ) { - const char * ext = IO::Path::FindExtension( filename.c_str() ); + const char * ext = IO::Path::FindExtension( filename.string().c_str() ); if (ext && strcasecmp(ext, ".zip") == 0) { #ifdef DAEDALUS_COMPRESSED_ROM_SUPPORT @@ -82,7 +82,7 @@ bool ROMFile::LoadData( u32 bytes_to_read, u8 *p_bytes, COutputStream & messages { if( !LoadRawData( bytes_to_read, p_bytes, messages ) ) { - messages << "Unable to get rom info from '" << mFilename.c_str() << "'"; + messages << "Unable to get rom info from '" << mFilename.string().c_str() << "'"; return false; } diff --git a/Source/RomFile/RomFileUncompressed.cpp b/Source/RomFile/RomFileUncompressed.cpp index a5cfc0a90..c20941853 100644 --- a/Source/RomFile/RomFileUncompressed.cpp +++ b/Source/RomFile/RomFileUncompressed.cpp @@ -52,7 +52,7 @@ bool ROMFileUncompressed::Open( COutputStream & messages ) DAEDALUS_ASSERT( mFH == NULL, "Opening the file twice?" ); #endif // Open the file and read in the data - mFH = fopen( mFilename.c_str(), "rb" ); + mFH = fopen( mFilename.string().c_str(), "rb" ); if(mFH == NULL) { return false; diff --git a/Source/SysCTR/Input/InputManagerCTR.cpp b/Source/SysCTR/Input/InputManagerCTR.cpp index 72fdd922c..ed241d3c7 100644 --- a/Source/SysCTR/Input/InputManagerCTR.cpp +++ b/Source/SysCTR/Input/InputManagerCTR.cpp @@ -315,10 +315,9 @@ bool IInputManager::Initialise() mControllerConfigs.push_back( p_default_z_config ); } - std::filesystem::path ControllerConfigs = baseDir; - ControllerConfigs /= "CoontrollerConfigs"; - // LoadControllerConfigs( DAEDALUS_CTR_PATH( "ControllerConfigs/" ) ); - LoadControllerConfigs(ControllerConfigs.c_str()); + char ControllerConfigs[128]; + IO::Path::Combine(ControllerConfigs, baseDir, "CoontrollerConfigs"); + LoadControllerConfigs(ControllerConfigs); SetConfiguration(0); diff --git a/Source/SysGL/CMakeLists.txt b/Source/SysGL/CMakeLists.txt index f49a2afe6..29ad5a674 100644 --- a/Source/SysGL/CMakeLists.txt +++ b/Source/SysGL/CMakeLists.txt @@ -1,19 +1,26 @@ -add_subdirectory(Graphics) -add_subdirectory(HLEGraphics) +file(GLOB SRC_FILES Graphics/*.cpp HLEGraphics/*.cpp Input/*.cpp Interface/*.cpp) -## These two should probably be in SysSDL2 -add_subdirectory(Input) -add_subdirectory(Interface) +add_library(SysGL OBJECT ${SRC_FILES}) +find_package(OpenGL REQUIRED) +target_include_directories(SysGL PUBLIC ${OPENGL_INCLUDE_DIR}) +link_libraries(OpenGL::GL) - if (UNIX AND NOT APPLE) - list(APPEND sys_libraries "GL") -endif() - list(APPEND sys_libraries "GLEW") +find_package(GLEW REQUIRED) +target_include_directories(SysGL PUBLIC ${GLEW_INCLUDE_DIRS}) +link_libraries(GLEW::GLEW) +find_package(SDL2 CONFIG REQUIRED) +target_include_directories(SysGL PUBLIC ${SDL2_INCLUDE_DIRS}) +link_libraries(SDL2::SDL2) -set(sys_libraries ${sys_libraries} PARENT_SCOPE) +# PSP is not needed as it uses built-in native font +find_package(SDL2_ttf REQUIRED) +target_include_directories(SysGL PUBLIC ${SDL2_TTF_INCLUDE_DIRS}) +link_libraries(SDL2_ttf::SDL2_ttf) -list(APPEND daed_libs) +install(FILES ${PROJECT_SOURCE_DIR}/Source/SysGL/HLEGraphics/n64.psh DESTINATION DaedalusX64) + +list(APPEND daed_libs "SysGL") set(daed_libs ${daed_libs} PARENT_SCOPE) diff --git a/Source/SysGL/Graphics/CMakeLists.txt b/Source/SysGL/Graphics/CMakeLists.txt deleted file mode 100644 index b9d5f39dc..000000000 --- a/Source/SysGL/Graphics/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_library(Graphics_GL OBJECT DrawTextSDL.cpp GraphicsContextGL.cpp NativeTextureGL.cpp UIContextGL.cpp) - -set(include_dirs ${include_dirs} PARENT_SCOPE) - -list(APPEND daed_libs Graphics_GL) -set(daed_libs ${daed_libs} PARENT_SCOPE) - diff --git a/Source/SysGL/Graphics/DrawTextSDL.cpp b/Source/SysGL/Graphics/DrawTextSDL.cpp index d63af2621..90673d1b2 100644 --- a/Source/SysGL/Graphics/DrawTextSDL.cpp +++ b/Source/SysGL/Graphics/DrawTextSDL.cpp @@ -43,7 +43,7 @@ u32 CDrawText::Render(EFont font_type, s32 x, s32 y, float scale, const char *p_ DAEDALUS_ASSERT(font_type >= 0 && font_type < (s32)NUM_FONTS, "Invalid font"); TTF_Font *font(gFonts[font_type]); - if (font) + if (font && p_str[0] != '\0') { SDL_Color c {colour.GetR(), colour.GetG(), colour.GetB()}; SDL_Color dc {drop_colour.GetR(), drop_colour.GetG(), drop_colour.GetB()}; diff --git a/Source/SysGL/Graphics/NativeTextureGL.cpp b/Source/SysGL/Graphics/NativeTextureGL.cpp index bbb6c1a0d..f8069acb8 100644 --- a/Source/SysGL/Graphics/NativeTextureGL.cpp +++ b/Source/SysGL/Graphics/NativeTextureGL.cpp @@ -165,7 +165,7 @@ namespace const size_t SIGNATURE_SIZE = 8; u8 signature[ SIGNATURE_SIZE ]; - FILE * fh = fopen( p_filename.c_str(),"rb" ); + FILE * fh = fopen( p_filename.string().c_str(),"rb" ); if (fh == NULL) { return NULL; diff --git a/Source/SysGL/HLEGraphics/CMakeLists.txt b/Source/SysGL/HLEGraphics/CMakeLists.txt deleted file mode 100644 index d8b8875cb..000000000 --- a/Source/SysGL/HLEGraphics/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -add_library(HLEGraphics_GL OBJECT - GraphicsPluginGL.cpp - RendererGL.cpp - ) - -list(APPEND daed_libs HLEGraphics_GL) -set(daed_libs ${daed_libs} PARENT_SCOPE) - diff --git a/Source/SysGL/HLEGraphics/RendererGL.cpp b/Source/SysGL/HLEGraphics/RendererGL.cpp index b8987fc11..96462c66d 100644 --- a/Source/SysGL/HLEGraphics/RendererGL.cpp +++ b/Source/SysGL/HLEGraphics/RendererGL.cpp @@ -111,8 +111,9 @@ bool initgl() size_t l = ftell(fh); fseek(fh, 0, SEEK_SET); char * p = (char *)malloc(l+1); - fread(p, l, 1, fh); - p[l] = 0; + fread(p, 1, l, fh); + while (p[l] != 0x0A) + p[l--] = 0; fclose(fh); gN64FramentLibrary = p; diff --git a/Source/SysGL/Input/CMakeLists.txt b/Source/SysGL/Input/CMakeLists.txt deleted file mode 100644 index e362e4362..000000000 --- a/Source/SysGL/Input/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_library(Input_GL OBJECT - InputManagerGL.cpp - ) - -list(APPEND daed_libs Input_GL) -set(daed_libs ${daed_libs} PARENT_SCOPE) - diff --git a/Source/SysGL/Input/InputManagerGL.cpp b/Source/SysGL/Input/InputManagerGL.cpp index 9c92e524b..15adfde1c 100644 --- a/Source/SysGL/Input/InputManagerGL.cpp +++ b/Source/SysGL/Input/InputManagerGL.cpp @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include //Windows Xinput support -#ifdef DAEDALUS_WIN32 +#ifdef DAEDALUS_W32 #include #include #include @@ -128,7 +128,7 @@ class IInputManager : public CInputManager void GetJoyPad(OSContPad *pPad); bool mGamePadAvailable; #endif -#ifdef DAEDALUS_WIN32 +#ifdef DAEDALUS_W32 CXBOXController* Player1; CXBOXController* Player2; @@ -167,7 +167,7 @@ static void CheckPadStatusVblHandler( void * arg ) bool IInputManager::Initialise() { -#ifdef DAEDALUS_WIN32 +#ifdef DAEDALUS_W32 Player1 = new CXBOXController(1); if (Player1->IsConnected()){ std::cout << "Xinput device detected! "; @@ -293,7 +293,7 @@ void IInputManager::GetState( OSContPad pPad[4] ) if (keys [ SDL_SCANCODE_PAGEDOWN ] ){ pPad[0].button |= R_CBUTTONS;} } -#ifdef DAEDALUS_WIN32 +#ifdef DAEDALUS_W32 if (Player1->IsConnected()) { #define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849 diff --git a/Source/SysGL/Interface/CMakeLists.txt b/Source/SysGL/Interface/CMakeLists.txt deleted file mode 100644 index 8f63a88db..000000000 --- a/Source/SysGL/Interface/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_library(Interface_GL OBJECT UI.cpp - ) - - -list(APPEND daed_libs Interface_GL) -set(daed_libs ${daed_libs} PARENT_SCOPE) - \ No newline at end of file diff --git a/Source/SysPosix/HLEAudio/AudioPluginOSX.cpp b/Source/SysPosix/HLEAudio/AudioPluginOSX.cpp index 5dea576ad..e4ce566db 100644 --- a/Source/SysPosix/HLEAudio/AudioPluginOSX.cpp +++ b/Source/SysPosix/HLEAudio/AudioPluginOSX.cpp @@ -346,7 +346,3 @@ std::unique_ptr CreateAudioPlugin() { return std::make_unique(); } -// CAudioPlugin * CreateAudioPlugin() -// { -// return new AudioPluginOSX(); -// } diff --git a/Source/SysPosix/main.cpp b/Source/SysPosix/main.cpp index 09b676bd1..cdd07e8f3 100644 --- a/Source/SysPosix/main.cpp +++ b/Source/SysPosix/main.cpp @@ -17,7 +17,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "Base/Types.h" #include "Core/CPU.h" @@ -47,51 +46,51 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "UI/PauseScreen.h" #ifdef DAEDALUS_PROFILE_EXECUTION -static CTimer gTimer; +static CTimer gTimer; #endif void HandleEndOfFrame() { #ifdef DAEDALUS_DEBUG_DISPLAYLIST - if(DLDebugger_IsDebugging()) + if (DLDebugger_IsDebugging()) return; - DPF( DEBUG_FRAME, "********************************************" ); + DPF(DEBUG_FRAME, "********************************************"); #endif // How long did the last frame take? #ifdef DAEDALUS_PROFILE_EXECUTION - DumpDynarecStats( elapsed_time ); + DumpDynarecStats(elapsed_time); #endif - //Enter debug menu as soon as select is pressed + // Enter debug menu as soon as select is pressed static u32 oldButtons = 0; SceCtrlData pad; - bool activate_pause_menu = false; + bool activate_pause_menu = false; sceCtrlPeekBufferPositive(&pad, 1); // If KernelButtons.prx not found. Use select for pause instead - if(oldButtons != pad.Buttons) + if (oldButtons != pad.Buttons) { // if( gCheatsEnabled && (pad.Buttons & PSP_CTRL_SELECT) ) // { // CheatCodes_Activate( GS_BUTTON ); // } - if(pad.Buttons & PSP_CTRL_SELECT) - activate_pause_menu = true; + if (pad.Buttons & PSP_CTRL_SELECT) + activate_pause_menu = true; } - if(activate_pause_menu) + if (activate_pause_menu) { CGraphicsContext::Get()->SwitchToLcdDisplay(); CGraphicsContext::Get()->ClearAllSurfaces(); - CUIContext * p_context( CUIContext::Create() ); + CUIContext *p_context(CUIContext::Create()); - if(p_context != NULL) + if (p_context != NULL) { - CPauseScreen * pause( CPauseScreen::Create( p_context ) ); + CPauseScreen *pause(CPauseScreen::Create(p_context)); pause->Run(); delete pause; delete p_context; @@ -101,18 +100,17 @@ void HandleEndOfFrame() // CPreferences::Get()->Commit(); } - // Reset the elapsed time to avoid glitches when we restart - #ifdef DAEDALUS_PROFILE_EXECUTION +// Reset the elapsed time to avoid glitches when we restart +#ifdef DAEDALUS_PROFILE_EXECUTION gTimer.Reset(); - #endif - +#endif } int main(int argc, char **argv) { int result = 0; - //ReadConfiguration(); + // ReadConfiguration(); if (!System_Init()) { @@ -120,31 +118,32 @@ int main(int argc, char **argv) return 1; } + Translate_Init(); if (argc > 1) { - bool batch_test = false; - const char * filename = NULL; + bool batch_test = false; + const char *filename = NULL; for (int i = 1; i < argc; ++i) { - const char * arg = argv[i]; + const char *arg = argv[i]; if (*arg == '-') { ++arg; - if( strcmp( arg, "-batch" ) == 0 ) + if (strcmp(arg, "-batch") == 0) { batch_test = true; break; } - else if (strcmp( arg, "-roms" ) == 0 ) + else if (strcmp(arg, "-roms") == 0) { - if (i+1 < argc) + if (i + 1 < argc) { - const char *relative_path = argv[i+1]; + const char *relative_path = argv[i + 1]; ++i; - char* dir = realpath(relative_path, nullptr); + char *dir = realpath(relative_path, nullptr); CRomDB::Get()->AddRomDirectory(dir); free(dir); } @@ -159,14 +158,14 @@ int main(int argc, char **argv) if (batch_test) { #ifdef DAEDALUS_BATCH_TEST_ENABLED - BatchTestMain(argc, argv); + BatchTestMain(argc, argv); #else - fprintf(stderr, "BatchTest mode is not present in this build.\n"); + fprintf(stderr, "BatchTest mode is not present in this build.\n"); #endif } else if (filename) { - System_Open( filename ); + System_Open(filename); // // Commit the preferences and roms databases before starting to run @@ -179,19 +178,18 @@ int main(int argc, char **argv) } } - Translate_Init(); - bool show_splash = true; - for(;;) - { - DisplayRomsAndChoose( show_splash ); - show_splash = false; + bool show_splash = true; + for (;;) + { + DisplayRomsAndChoose(show_splash); + show_splash = false; - CRomDB::Get()->Commit(); - CPreferences::Get()->Commit(); + CRomDB::Get()->Commit(); + CPreferences::Get()->Commit(); - CPU_Run(); - System_Close(); - } + CPU_Run(); + System_Close(); + } System_Finalize(); return result; diff --git a/Source/SysW32/CMakeLists.txt b/Source/SysW32/CMakeLists.txt index 9f8de7593..e1d68cbb0 100644 --- a/Source/SysW32/CMakeLists.txt +++ b/Source/SysW32/CMakeLists.txt @@ -2,3 +2,11 @@ add_subdirectory(Debug) add_subdirectory(HLEAudio) add_subdirectory(Interface) add_subdirectory(Utility) + +install(FILES ${PROJECT_BINARY_DIR}/../Data/roms.ini DESTINATION DaedalusX64) +install(FILES ${PROJECT_BINARY_DIR}/../Data/readme.txt DESTINATION DaedalusX64) +install(FILES ${PROJECT_BINARY_DIR}/../Data/copying.txt DESTINATION DaedalusX64) + +list(APPEND daed_libs) +set(daed_libs ${daed_libs} Shlwapi.lib Dsound.lib Xinput.lib uuid.lib PARENT_SCOPE) +set(plat_main SysW32/main.cpp PARENT_SCOPE) \ No newline at end of file diff --git a/Source/SysW32/Debug/CMakeLists.txt b/Source/SysW32/Debug/CMakeLists.txt index 6f2798827..47b81b0c5 100644 --- a/Source/SysW32/Debug/CMakeLists.txt +++ b/Source/SysW32/Debug/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(Debug_Windows DaedalusAssertW32.cpp) +add_library(Debug_Win DaedalusAssertW32.cpp) list(APPEND daed_libs Debug_Win) set(daed_libs ${daed_libs} PARENT_SCOPE) diff --git a/Source/SysW32/HLEAudio/AudioPluginW32.cpp b/Source/SysW32/HLEAudio/AudioPluginW32.cpp index c314dc25f..ca0f814aa 100644 --- a/Source/SysW32/HLEAudio/AudioPluginW32.cpp +++ b/Source/SysW32/HLEAudio/AudioPluginW32.cpp @@ -22,9 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" #include "HLEAudio/AudioPlugin.h" -#include -#include - #include "Config/ConfigOptions.h" #include "Core/CPU.h" #include "Core/Interrupt.h" @@ -35,6 +32,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Utility/FastMemcpy.h" #include "System/Thread.h" +#define INITGUID + +#include +#include +#include + //This is disabled, it doesn't work well, causes random deadlocks/Lock failures :( //Would be nice to get it working correctly, since running audio in the main thread is abit jerky #define AUDIO_THREADED @@ -55,11 +58,8 @@ inline void Soundmemcpy(void * dest, const void * src, size_t count) class CAudioPluginW32 : public CAudioPlugin { -private: - CAudioPluginW32(); public: - static CAudioPluginW32 * Create(); - + CAudioPluginW32(); virtual ~CAudioPluginW32(); virtual bool StartEmulation(); @@ -84,7 +84,7 @@ class CAudioPluginW32 : public CAudioPlugin DSBPOSITIONNOTIFY rgdscbpn[NUMCAPTUREEVENTS+1]; void SetupDSoundBuffers(); - bool CAudioPluginW32::FillBufferWithSilence( LPDIRECTSOUNDBUFFER lpDsb ); + bool FillBufferWithSilence( LPDIRECTSOUNDBUFFER lpDsb ); void FillSectionWithSilence( int buffer ); void FillBuffer ( int buffer ); @@ -113,14 +113,6 @@ CAudioPluginW32::~CAudioPluginW32() { } -//***************************************************************************** -// -//***************************************************************************** -CAudioPluginW32 * CAudioPluginW32::Create() -{ - return new CAudioPluginW32(); -} - //***************************************************************************** // //***************************************************************************** @@ -369,9 +361,9 @@ EProcessResult CAudioPluginW32::ProcessAList() //***************************************************************************** // //***************************************************************************** -CAudioPlugin * CreateAudioPlugin() +std::unique_ptr CreateAudioPlugin() { - return CAudioPluginW32::Create(); + return std::make_unique(); } void CAudioPluginW32::SetupDSoundBuffers(void) { diff --git a/Source/SysW32/Interface/FileNameHandler.cpp b/Source/SysW32/Interface/FileNameHandler.cpp index b172a6dc2..54dd24ca0 100644 --- a/Source/SysW32/Interface/FileNameHandler.cpp +++ b/Source/SysW32/Interface/FileNameHandler.cpp @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - +#include #include "Base/Types.h" #include "FileNameHandler.h" @@ -36,9 +36,12 @@ FileNameHandler::FileNameHandler(LPCTSTR szSectionName, lstrcpy(m_szSectionName, szSectionName); if(pszDefaultDir) - strcpy(m_szCurrentDirectory, pszDefaultDir); - else - GetDefaultDirectory(m_szCurrentDirectory); + m_szCurrentDirectory = pszDefaultDir; + else { + char current[128]; + GetDefaultDirectory(current); + m_szCurrentDirectory = current; + } ZeroMemory(&m_OFN, sizeof(OPENFILENAME)); m_OFN.lStructSize = sizeof(OPENFILENAME); @@ -48,7 +51,7 @@ FileNameHandler::FileNameHandler(LPCTSTR szSectionName, m_OFN.nMaxFile = 300; m_OFN.lpstrFileTitle = m_szFileTitle; m_OFN.nMaxFileTitle = 300; - m_OFN.lpstrInitialDir = m_szCurrentDirectory; + m_OFN.lpstrInitialDir = m_szCurrentDirectory.string().c_str(); m_OFN.lpstrFilter = szFilter; m_OFN.lpstrDefExt = szDefExt; m_OFN.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; @@ -57,7 +60,7 @@ FileNameHandler::FileNameHandler(LPCTSTR szSectionName, FileNameHandler::~FileNameHandler() { - SetDefaultDirectory(m_szCurrentDirectory); + SetDefaultDirectory(m_szCurrentDirectory.string().c_str()); } // Get the default directory from the system @@ -205,7 +208,9 @@ BOOL FileNameHandler::GetOpenName(HWND hwnd, LPTSTR szOutBuffer) lstrcpyn(szOutBuffer, m_szFile, IO::Path::kMaxPathLen); // Copy the current directory - GetCurrentDirectory(m_szCurrentDirectory); + char current[128]; + GetCurrentDirectory(current); + m_szCurrentDirectory = current; return TRUE; } else { return FALSE; @@ -227,7 +232,9 @@ BOOL FileNameHandler::GetSaveName(HWND hwnd, LPTSTR szOutBuffer) lstrcpyn(szOutBuffer, m_szFile, IO::Path::kMaxPathLen); // Copy the current directory - GetCurrentDirectory(m_szCurrentDirectory); + char current[256]; + GetCurrentDirectory(current); + m_szCurrentDirectory = current; return TRUE; } else { return FALSE; diff --git a/Source/SysW32/Utility/CondW32.cpp b/Source/SysW32/Utility/CondW32.cpp index 92607d7f5..6eeeb7061 100644 --- a/Source/SysW32/Utility/CondW32.cpp +++ b/Source/SysW32/Utility/CondW32.cpp @@ -1,3 +1,4 @@ +#include "windows.h" #include "Base/Types.h" #include "System/Condition.h" @@ -55,7 +56,8 @@ void CondWait(Cond * cond, Mutex * mutex, double timeout) EnterCriticalSection( &cv->waiters_count_lock ); cv->waiters_count ++; LeaveCriticalSection( &cv->waiters_count_lock ); - LeaveCriticalSection( &mutex->cs ); + + mutex->Unlock(); if (timeout <= 0) { @@ -78,7 +80,7 @@ void CondWait(Cond * cond, Mutex * mutex, double timeout) ResetEvent( cv->events[ COND_BROADCAST ] ); } - EnterCriticalSection( &mutex->cs ); + mutex->Lock(); } void CondSignal(Cond * cond) diff --git a/Source/SysW32/Utility/IOW32.cpp b/Source/SysW32/Utility/IOW32.cpp index 80eee4a89..9ff979a9b 100644 --- a/Source/SysW32/Utility/IOW32.cpp +++ b/Source/SysW32/Utility/IOW32.cpp @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include +const std::filesystem::path baseDir = std::filesystem::current_path(); namespace IO { diff --git a/Source/SysW32/Utility/ThreadW32.cpp b/Source/SysW32/Utility/ThreadW32.cpp index ac6474db9..ff06d79e8 100644 --- a/Source/SysW32/Utility/ThreadW32.cpp +++ b/Source/SysW32/Utility/ThreadW32.cpp @@ -17,6 +17,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include "Base/Types.h" #include "System/Thread.h" diff --git a/Source/SysW32/Utility/TimingW32.cpp b/Source/SysW32/Utility/TimingW32.cpp index e604e0b8b..ec7a9776d 100644 --- a/Source/SysW32/Utility/TimingW32.cpp +++ b/Source/SysW32/Utility/TimingW32.cpp @@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" #include "System/Timing.h" +#include namespace NTiming { bool GetPreciseFrequency( u64 * p_freq ) diff --git a/Source/SysW32/main.cpp b/Source/SysW32/main.cpp index 273f2363e..5cca3868c 100644 --- a/Source/SysW32/main.cpp +++ b/Source/SysW32/main.cpp @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - +#include #include "Base/Types.h" @@ -33,20 +33,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Interface/Preferences.h" #include "Utility/Profiler.h" // CProfiler::Create/Destroy -int __cdecl main(int argc, char **argv) +#include "UI/UIContext.h" +#include "Graphics/GraphicsContext.h" +#include "UI/DrawText.h" +#include "UI/PauseScreen.h" +#include "UI/MainMenuScreen.h" + +void HandleEndOfFrame() { - HMODULE hModule = GetModuleHandle(NULL); - if (hModule != NULL) - { - GetModuleFileName(hModule, gDaedalusExePath, ARRAYSIZE(gDaedalusExePath)); - IO::Path::RemoveFileSpec(gDaedalusExePath); - } - else - { - fprintf(stderr, "Couldn't determine executable path\n"); - return 1; - } +} + +int __cdecl main(int argc, char **argv) +{ //ReadConfiguration(); int result = 0; @@ -90,16 +89,24 @@ int __cdecl main(int argc, char **argv) { //Need absolute path when loading from Visual Studio //This is ok when loading from console too, since arg0 will be empty, it'll just load file name (arg1) - IO::Path::Combine(rom_path, gDaedalusExePath, argv[1]); - fprintf(stderr, "Loading %s\n",rom_path); - System_Open(rom_path); + fprintf(stderr, "Loading %s\n",filename); + System_Open(filename); CPU_Run(); System_Close(); } } - else + + bool show_splash = true; + for (;;) { -// result = RunMain(); + DisplayRomsAndChoose(show_splash); + show_splash = false; + + CRomDB::Get()->Commit(); + CPreferences::Get()->Commit(); + + CPU_Run(); + System_Close(); } // diff --git a/Source/System/CMakeLists.txt b/Source/System/CMakeLists.txt index 088bec4a8..debba9012 100644 --- a/Source/System/CMakeLists.txt +++ b/Source/System/CMakeLists.txt @@ -1,5 +1,6 @@ add_library(System OBJECT CompressedStream.cpp DataSink.cpp SystemInit.cpp) +target_include_directories(System PUBLIC ${ZLIB_INCLUDE_DIRS}) list(APPEND daed_libs "System") set(daed_libs ${daed_libs} PARENT_SCOPE) diff --git a/Source/System/CompressedStream.cpp b/Source/System/CompressedStream.cpp index 4b6535b56..f7d9b6581 100644 --- a/Source/System/CompressedStream.cpp +++ b/Source/System/CompressedStream.cpp @@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. COutStream::COutStream( const std::filesystem::path filename ) : mBufferCount( 0 ) -, mFile( gzopen( filename.c_str(), "wb" ) ) +, mFile( gzopen( filename.string().c_str(), "wb" ) ) { } @@ -121,7 +121,7 @@ void COutStream::Reset() CInStream::CInStream( const std::filesystem::path filename ) : mBufferOffset( 0 ) , mBytesAvailable( 0 ) -, mFile( gzopen( filename.c_str(), "rb" ) ) +, mFile( gzopen( filename.string().c_str(), "rb" ) ) { } diff --git a/Source/System/DataSink.cpp b/Source/System/DataSink.cpp index 01b2b86ef..b33add092 100644 --- a/Source/System/DataSink.cpp +++ b/Source/System/DataSink.cpp @@ -24,7 +24,7 @@ bool FileSink::Open(const std::filesystem::path &filename, const char * mode) #ifdef DAEDALUS_ENABLE_ASSERTS DAEDALUS_ASSERT(Handle == NULL, "Already have an open file"); #endif - Handle = fopen(filename.c_str(), mode); + Handle = fopen(filename.string().c_str(), mode); return Handle != NULL; } diff --git a/Source/System/IO.h b/Source/System/IO.h index 4b59bf12e..8dac9c76d 100644 --- a/Source/System/IO.h +++ b/Source/System/IO.h @@ -84,11 +84,11 @@ namespace IO }; // This is also pretty redundant, as the IO file is pretty much deprecated -// #if defined( DAEDALUS_W32) || defined(DAEDALUS_CTR) || defined(DAEDALUS_POSIX) +#if defined( DAEDALUS_W32) + using FindHandleT = intptr_t; +#else using FindHandleT = void *; -// #else -// using FindHandleT = intptr_t; -// #endif +#endif bool FindFileOpen( const char * path, FindHandleT * handle, FindDataT & data ); bool FindFileNext( FindHandleT handle, FindDataT & data ); diff --git a/Source/System/Mutex.h b/Source/System/Mutex.h index f70d5e393..34863c861 100644 --- a/Source/System/Mutex.h +++ b/Source/System/Mutex.h @@ -24,45 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #if defined(DAEDALUS_POSIX) || defined(DAEDALUS_PSP) || defined(DAEDALUS_CTR) #include -#include #endif -#if defined(DAEDALUS_W32) - -class Mutex -{ -public: - - Mutex() - { - InitializeCriticalSection(&cs); - } - - explicit Mutex( const char * name ) - { - InitializeCriticalSection(&cs); - }; - - ~Mutex() - { - DeleteCriticalSection(&cs); - } - - void Lock() - { - EnterCriticalSection(&cs); - } - - void Unlock() - { - LeaveCriticalSection(&cs); - } - -public: - CRITICAL_SECTION cs; - }; - -#else +#include class Mutex { public: @@ -101,9 +65,6 @@ class Mutex }; -#endif - - class MutexLock { public: diff --git a/Source/System/SystemInit.cpp b/Source/System/SystemInit.cpp index dced2ba63..ac2f0593d 100644 --- a/Source/System/SystemInit.cpp +++ b/Source/System/SystemInit.cpp @@ -76,9 +76,20 @@ static bool InitAudioPlugin() { gAudioPlugin = std::move(audio_plugin); } + gAudioPlugin->StartEmulation(); return true; } +static void DisposeAudioPlugin() +{ + if ( gAudioPlugin != NULL ) + { + gAudioPlugin->StopEmulation(); + gAudioPlugin.release(); + gAudioPlugin = NULL; + } +} + static bool InitGraphicsPlugin() { #ifdef DAEDALUS_ENABLE_ASSERTS @@ -97,11 +108,12 @@ static void DisposeGraphicsPlugin() if ( gGraphicsPlugin != NULL ) { gGraphicsPlugin->RomClosed(); - // delete gGraphicsPlugin; + gGraphicsPlugin.release(); gGraphicsPlugin = NULL; } } + struct SysEntityEntry { const char *name; diff --git a/Source/UI/CMakeLists.txt b/Source/UI/CMakeLists.txt index 4e082f0f3..8cd3a448b 100644 --- a/Source/UI/CMakeLists.txt +++ b/Source/UI/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(UI_PSP OBJECT +add_library(UI OBJECT AboutComponent.cpp AdjustDeadzoneScreen.cpp AdvancedOptionsScreen.cpp @@ -22,6 +22,9 @@ add_library(UI_PSP OBJECT DrawTextUtilities.cpp ) - -list(APPEND daed_libs "UI_PSP") +if(DAEDALUS_GL) +target_include_directories(UI PUBLIC ${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_DIRS}) +endif(DAEDALUS_GL) + +list(APPEND daed_libs "UI") set(daed_libs ${daed_libs} PARENT_SCOPE) diff --git a/Source/UI/RomSelectorComponent.cpp b/Source/UI/RomSelectorComponent.cpp index 82cb2b3f3..ba3bba91f 100644 --- a/Source/UI/RomSelectorComponent.cpp +++ b/Source/UI/RomSelectorComponent.cpp @@ -106,7 +106,7 @@ struct SRomInfo std::string game_name; if ( !ROM_GetRomName( filename, game_name ) ) { - game_name = IO::Path::FindFileName( filename.c_str() ); + game_name = IO::Path::FindFileName( filename.string().c_str() ); } game_name = game_name.substr(0, 63); mSettings.GameName = game_name.c_str(); @@ -446,7 +446,7 @@ void IRomSelectorComponent::RenderRomList() const char * p_gamename; if( mDisplayFilenames ) { - p_gamename = mRomsList[ i ]->mFilename.c_str(); + p_gamename = mRomsList[ i ]->mFilename.string().c_str(); } else { @@ -656,7 +656,7 @@ void IRomSelectorComponent::Update( float elapsed_time, const v2 & stick, u32 ol { if(mCurrentSelection < mRomsList.size()) { - mSelectedRom = mRomsList[ mCurrentSelection ]->mFilename; + mSelectedRom = mRomsList[ mCurrentSelection ]->mFilename.string(); if(OnRomSelected != NULL) { @@ -670,7 +670,7 @@ void IRomSelectorComponent::Update( float elapsed_time, const v2 & stick, u32 ol { if(mCurrentSelection < mRomsList.size()) { - mSelectedRom = mRomsList[ mCurrentSelection ]->mFilename; + mSelectedRom = mRomsList[ mCurrentSelection ]->mFilename.string(); mRomDelete = true; } } diff --git a/Source/UI/SavestateSelectorComponent.cpp b/Source/UI/SavestateSelectorComponent.cpp index e5ca0925b..08793a7d0 100644 --- a/Source/UI/SavestateSelectorComponent.cpp +++ b/Source/UI/SavestateSelectorComponent.cpp @@ -110,8 +110,8 @@ namespace snprintf( sub_path, sizeof(sub_path), "SaveStates/%s", slot_path); if(!std::filesystem::is_directory( "ms0:/n64/SaveStates/" )) { - IO::Path::Combine( path, gDaedalusExePath.c_str(), sub_path ); - IO::Path::Combine( png_path, gDaedalusExePath.c_str(), sub_path ); + IO::Path::Combine( path, gDaedalusExePath.string().c_str(), sub_path ); + IO::Path::Combine( png_path, gDaedalusExePath.string().c_str(), sub_path ); std::filesystem::exists(path); // Ensure this dir exists } else @@ -377,8 +377,8 @@ void ISavestateSelectorComponent::deleteSlot(u32 id_ss) std::filesystem::path gDaedalusExePath = std::filesystem::current_path(); if(!std::filesystem::is_directory( "ms0:/n64/SaveStates/" )) { - IO::Path::Combine( path, gDaedalusExePath.c_str(), sub_path ); - IO::Path::Combine( png_path, gDaedalusExePath.c_str(), sub_path ); + IO::Path::Combine( path, gDaedalusExePath.string().c_str(), sub_path ); + IO::Path::Combine( png_path, gDaedalusExePath.string().c_str(), sub_path ); } else { diff --git a/Source/Utility/IniFile.cpp b/Source/Utility/IniFile.cpp index 47a5d579b..d737967a7 100644 --- a/Source/Utility/IniFile.cpp +++ b/Source/Utility/IniFile.cpp @@ -319,7 +319,7 @@ bool IIniFile::Open( const std::filesystem::path filename ) char readinfo[BUFFER_LEN+1]; const char trim_chars[]="{}[]"; //remove first and last character - FILE * fh( fopen( filename.c_str(), "r" ) ); + FILE * fh( fopen( filename.string().c_str(), "r" ) ); if (fh == NULL) { return false; diff --git a/Source/Utility/Profiler.cpp b/Source/Utility/Profiler.cpp index 1963377a9..dee453bc0 100644 --- a/Source/Utility/Profiler.cpp +++ b/Source/Utility/Profiler.cpp @@ -9,8 +9,6 @@ #include #include #include -#include - #include "Base/Types.h" From 66c15a0a586d23ce158ffcf173d04c1ef9d24292 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Thu, 7 Dec 2023 23:00:26 +0800 Subject: [PATCH 26/54] Use release build --- Source/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index db2898f39..fe6d55673 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -21,7 +21,7 @@ if(DEBUG) option(DAEDALUS_LOG "Enable various logging" ON) add_compile_options("-Wall") else() - set(CMAKE_BUILD_TYPE RelWithDebInfo) + set(CMAKE_BUILD_TYPE Release) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) add_compile_definitions(DAEDALUS_CONFIG_VERSION="Release") ## Perhaps we can remove this. It's only used in the PSP UI and model doesn't matter as much endif() From b4575186b5dfa9605f215c11792587501d2870c1 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Thu, 7 Dec 2023 23:12:26 +0800 Subject: [PATCH 27/54] Fix 3DS --- Source/UI/GlobalSettingsComponent.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/UI/GlobalSettingsComponent.cpp b/Source/UI/GlobalSettingsComponent.cpp index 95b684711..523e310e8 100644 --- a/Source/UI/GlobalSettingsComponent.cpp +++ b/Source/UI/GlobalSettingsComponent.cpp @@ -146,8 +146,8 @@ namespace { } - virtual void OnNext() { (gGlobalPreferences.Language >= Translate_Number() ) ? 0 : gGlobalPreferences.Language++; } - virtual void OnPrevious() { (gGlobalPreferences.Language <= 0) ? 0 : gGlobalPreferences.Language--; } + virtual void OnNext() { if (gGlobalPreferences.Language < Translate_Number() ) gGlobalPreferences.Language++; } + virtual void OnPrevious() { if (gGlobalPreferences.Language > 0) gGlobalPreferences.Language--; } virtual void OnSelected() { @@ -276,8 +276,8 @@ namespace { } - virtual void OnNext() { (gGlobalPreferences.DisplayFramerate >= 3) ? 0 : gGlobalPreferences.DisplayFramerate++; } - virtual void OnPrevious() { (gGlobalPreferences.DisplayFramerate <= 0) ? 0 : gGlobalPreferences.DisplayFramerate--; } + virtual void OnNext() { if (gGlobalPreferences.DisplayFramerate < 3) gGlobalPreferences.DisplayFramerate++; } + virtual void OnPrevious() { if (gGlobalPreferences.DisplayFramerate > 0) gGlobalPreferences.DisplayFramerate--; } virtual const char * GetSettingName() const { From 75d3eb08148f49310ff87a2d62855682083c4ee1 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Thu, 7 Dec 2023 23:35:46 +0800 Subject: [PATCH 28/54] enable debug build of win32 --- Source/Base/Assert.h | 7 +- Source/CMakeLists.txt | 7 +- Source/Core/ROM.cpp | 2 +- Source/Core/ROMBuffer.cpp | 2 +- Source/Core/RomSettings.cpp | 3 +- Source/Interface/RomDB.cpp | 3 +- Source/OSHLE/patch.cpp | 2 +- Source/SysW32/Debug/CMakeLists.txt | 2 +- Source/SysW32/Debug/DaedalusAssertW32.cpp | 7 +- Source/SysW32/Debug/DebugConsoleW32.cpp | 169 ++++++++++++++++++++++ Source/SysW32/Utility/ThreadW32.cpp | 4 +- 11 files changed, 189 insertions(+), 19 deletions(-) create mode 100644 Source/SysW32/Debug/DebugConsoleW32.cpp diff --git a/Source/Base/Assert.h b/Source/Base/Assert.h index fdc007f48..f493dfb72 100644 --- a/Source/Base/Assert.h +++ b/Source/Base/Assert.h @@ -37,8 +37,6 @@ enum EAssertResult AR_BREAK, }; -EAssertResult DAEDALUS_VARARG_CALL_TYPE DaedalusAssert( const char * expression, const char * file, unsigned int line, const char * msg, ... ); - #ifdef DAEDALUS_PSP #define DAEDALUS_HALT __asm__ __volatile__ ( "break" ) #elif DAEDALUS_POSIX @@ -48,18 +46,19 @@ EAssertResult DAEDALUS_VARARG_CALL_TYPE DaedalusAssert( const char * expression, #define DAEDALUS_HALT __asm__ __volatile__ ( "bkpt" ) #elif DAEDALUS_W32 // Ugh this needs simplifying - // + #include #define __PRETTY_FUNCTION__ __FUNCTION__ #define _CRT_SECURE_NO_DEPRECATE #define _DO_NOT_DECLARE_INTERLOCKED_INTRINSICS_IN_MEMORY #define DAEDALUS_THREAD_CALL_TYPE __stdcall // Thread functions need to be __stdcall to work with the W32 api #define DAEDALUS_VARARG_CALL_TYPE __cdecl // Vararg functions need to be __cdecl - #define DAEDALUS_HALT __asm { int 3 } + #define DAEDALUS_HALT _CrtDbgBreak() #else #error Unknown Platforn DAEDALUS_HALT should be defined in Base/Assert.h #endif +EAssertResult DAEDALUS_VARARG_CALL_TYPE DaedalusAssert( const char * expression, const char * file, unsigned int line, const char * msg, ... ); // // Use this api to override the default assert handler, e.g. for logging asserts during a batch process diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index fe6d55673..ae424fb11 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -19,7 +19,9 @@ if(DEBUG) option(DAEDALUS_DEBUG_CONSOLE "Enable Debug Console" ON) option(DAEDALUS_DEBUG_DISPLAYLIST "Options for debugging the display list, useful for determining texture issues" OFF) option(DAEDALUS_LOG "Enable various logging" ON) +if(NOT WIN32) add_compile_options("-Wall") +endif() else() set(CMAKE_BUILD_TYPE Release) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) @@ -127,11 +129,10 @@ endif() list(APPEND include_dirs "${PROJECT_SOURCE_DIR}/Source") include_directories( BEFORE ${include_dirs}) - add_compile_definitions(DAEDALUS_THREAD_CALL_TYPE=${}) - add_compile_definitions(DAEDALUS_VARARG_CALL_TYPE=${}) - ## Generic defines for certain things that Windows requires. if(NOT WIN32) + add_compile_definitions(DAEDALUS_THREAD_CALL_TYPE=${}) + add_compile_definitions(DAEDALUS_VARARG_CALL_TYPE=${}) add_compile_options("-g") add_compile_options("-ffast-math") endif() diff --git a/Source/Core/ROM.cpp b/Source/Core/ROM.cpp index 13d1f1c84..201ac1e11 100644 --- a/Source/Core/ROM.cpp +++ b/Source/Core/ROM.cpp @@ -500,7 +500,7 @@ void ROM_UnloadFile() bool ROM_LoadFile(const RomID & rom_id, const RomSettings & settings, const SRomPreferences & preferences ) { - DBGConsole_Msg(0, "Reading rom image: [C%s]", g_ROM.mFileName.c_str()); + DBGConsole_Msg(0, "Reading rom image: [C%s]", g_ROM.mFileName.string().c_str()); // Get information about the rom header RomBuffer::GetRomBytesRaw( &g_ROM.rh, 0, sizeof(ROMHeader) ); diff --git a/Source/Core/ROMBuffer.cpp b/Source/Core/ROMBuffer.cpp index 92655a85d..9fdbbe211 100644 --- a/Source/Core/ROMBuffer.cpp +++ b/Source/Core/ROMBuffer.cpp @@ -311,7 +311,7 @@ bool RomBuffer::Open() sRomFixed = false; } - DBGConsole_Msg(0, "Opened [C%s]\n", filename.c_str()); + DBGConsole_Msg(0, "Opened [C%s]\n", filename.string().c_str()); sRomLoaded = true; return true; } diff --git a/Source/Core/RomSettings.cpp b/Source/Core/RomSettings.cpp index 77fa2cf6d..bade1eabc 100644 --- a/Source/Core/RomSettings.cpp +++ b/Source/Core/RomSettings.cpp @@ -153,9 +153,8 @@ template<> bool CSingleton< CRomSettingsDB >::Create() mpInstance = std::make_shared(); std::filesystem::path p = baseDir; p /= "roms.ini"; - const char *ini_filename = p.string().c_str(); - mpInstance->OpenSettingsFile( ini_filename ); + mpInstance->OpenSettingsFile( p ); return true; } diff --git a/Source/Interface/RomDB.cpp b/Source/Interface/RomDB.cpp index 525d6bd64..35be17475 100644 --- a/Source/Interface/RomDB.cpp +++ b/Source/Interface/RomDB.cpp @@ -172,9 +172,8 @@ template<> bool CSingleton< CRomDB >::Create() mpInstance = std::make_shared(); std::filesystem::path p = baseDir; p /= "rom.db"; - const char *romdb_filename = p.string().c_str(); - /*ret = */mpInstance->OpenDB( romdb_filename ); + /*ret = */mpInstance->OpenDB( p ); return true; } diff --git a/Source/OSHLE/patch.cpp b/Source/OSHLE/patch.cpp index 57688f9a6..60ab2b6c0 100644 --- a/Source/OSHLE/patch.cpp +++ b/Source/OSHLE/patch.cpp @@ -1007,7 +1007,7 @@ static bool Patch_GetCache() if (fp != nullptr) { - DBGConsole_Msg(0, "Read from OSHLE cache: %s", name.c_str()); + DBGConsole_Msg(0, "Read from OSHLE cache: %s", name.string().c_str()); u32 data; fread(&data, 1, sizeof(data), fp); diff --git a/Source/SysW32/Debug/CMakeLists.txt b/Source/SysW32/Debug/CMakeLists.txt index 47b81b0c5..2df9214af 100644 --- a/Source/SysW32/Debug/CMakeLists.txt +++ b/Source/SysW32/Debug/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(Debug_Win DaedalusAssertW32.cpp) +add_library(Debug_Win DaedalusAssertW32.cpp DebugConsoleW32.cpp) list(APPEND daed_libs Debug_Win) set(daed_libs ${daed_libs} PARENT_SCOPE) diff --git a/Source/SysW32/Debug/DaedalusAssertW32.cpp b/Source/SysW32/Debug/DaedalusAssertW32.cpp index 9bddd9242..537d088d0 100644 --- a/Source/SysW32/Debug/DaedalusAssertW32.cpp +++ b/Source/SysW32/Debug/DaedalusAssertW32.cpp @@ -24,6 +24,8 @@ #ifdef DAEDALUS_ENABLE_ASSERTS #include +#include +#include DaedalusAssertHook gAssertHook = NULL; @@ -31,9 +33,10 @@ DaedalusAssertHook gAssertHook = NULL; EAssertResult DAEDALUS_VARARG_CALL_TYPE DaedalusAssert( const char * expression, const char * file, unsigned int line, const char * msg, ... ) { - char buffer[ 1024 ]; va_list va; - va_start(va, msg); + va_start(va); + + char buffer[ 1024 ]; vsnprintf( buffer, 1024, msg, va ); buffer[1023] = 0; va_end(va); diff --git a/Source/SysW32/Debug/DebugConsoleW32.cpp b/Source/SysW32/Debug/DebugConsoleW32.cpp new file mode 100644 index 000000000..45bb46868 --- /dev/null +++ b/Source/SysW32/Debug/DebugConsoleW32.cpp @@ -0,0 +1,169 @@ +/* +Copyright (C) 2012 StrmnNrmn + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + + +#include "Base/Types.h" + +#ifdef DAEDALUS_DEBUG_CONSOLE + +#include +#include +#include + +#include "Debug/DBGConsole.h" +#include "Debug/DebugConsoleImpl.h" + +class IDebugConsole : public CDebugConsole +{ + public: + IDebugConsole(); + virtual ~IDebugConsole() { } + + void Msg(u32 type, const char * format, ...); + + void MsgOverwriteStart() {} + void MsgOverwrite(u32 type, const char * format, ...) + { + va_list marker; + va_start( marker, format ); + vprintf( format, marker ); + va_end( marker ); + printf("\n"); + } + void MsgOverwriteEnd() {} +}; + +template<> bool CSingleton< CDebugConsole >::Create() +{ + DAEDALUS_ASSERT(mpInstance == NULL, "Already initialised"); + + mpInstance = std::make_shared(); + + return mpInstance ? true : false; +} + +CDebugConsole::~CDebugConsole() +{ + +} + +IDebugConsole::IDebugConsole() +{ +} + + +static size_t ParseFormatString(const char * format, char * out, size_t out_len) +{ + ETerminalColour tc = TC_DEFAULT; + + const char * p = format; + char * o = out; + + size_t len = 0; + while (*p) + { + if (*p == '[') + { + ++p; + + tc = GetTerminalColour( *p ); + const char * str = GetTerminalColourString(tc); + size_t str_len = strlen(str); + + len += str_len; + if (o) + { + strcpy(o, str); + o += str_len; + } + } + else if (*p == ']') + { + tc = TC_DEFAULT; + const char * str = GetTerminalColourString(tc); + size_t str_len = strlen(str); + len += str_len; + if (o) + { + strcpy(o, str); + o += str_len; + } + } + else + { + ++len; + if (o) + { + *o = *p; + ++o; + } + } + + ++p; + } + + if (tc != TC_DEFAULT) + { + tc = TC_DEFAULT; + const char * str = GetTerminalColourString(tc); + size_t str_len = strlen(str); + len += str_len; + if (o) + { + strcpy(o, str); + o += str_len; + } + } + + if (o) + { + *o = '\0'; + ++o; + DAEDALUS_ASSERT( o == out+len+1, "Oops" ); + } + + return len; +} + +void IDebugConsole::Msg(u32 type, const char * format, ...) +{ + char * temp = NULL; + + if (strchr(format, '[') != NULL) + { + size_t len = ParseFormatString(format, NULL, 0); + + temp = (char *)malloc(len+1); + + ParseFormatString(format, temp, len); + + format = temp; + } + + + va_list marker; + va_start( marker, format ); + vprintf( format, marker ); + va_end( marker ); + printf("\n"); + + if (temp) + free(temp); +} +#endif diff --git a/Source/SysW32/Utility/ThreadW32.cpp b/Source/SysW32/Utility/ThreadW32.cpp index ff06d79e8..550605136 100644 --- a/Source/SysW32/Utility/ThreadW32.cpp +++ b/Source/SysW32/Utility/ThreadW32.cpp @@ -65,7 +65,7 @@ ThreadHandle CreateThread( const char * name, DaedThread function, void * argume if(h != NULL) { ResumeThread( h ); - return reinterpret_cast< s32 >( h ); + return reinterpret_cast< ThreadHandle >( h ); } return 0; @@ -137,7 +137,7 @@ void ThreadYield() ::Sleep( 0 ); } -void TerminateThread(long handle) +void TerminateThread(HANDLE handle) { ::TerminateThread((HANDLE)handle, 0); } From 644d080109e8f4d0fb9a4d7d7feffa263fb36ed0 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Thu, 7 Dec 2023 23:50:19 +0800 Subject: [PATCH 29/54] Handle special character --- Source/UI/RomSelectorComponent.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/UI/RomSelectorComponent.cpp b/Source/UI/RomSelectorComponent.cpp index ba3bba91f..41f3dd90f 100644 --- a/Source/UI/RomSelectorComponent.cpp +++ b/Source/UI/RomSelectorComponent.cpp @@ -50,6 +50,9 @@ namespace #endif ECategory GetCategory( char c ) { + if (c < 0) + return C_UNK; + if( isalpha( c ) ) { c = tolower( c ); From a47d61a75d13871ebd59eb4c12e7142c4fbcb7f1 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Fri, 8 Dec 2023 14:37:50 +0800 Subject: [PATCH 30/54] Fix Windows build --- Source/SysPosix/main.cpp | 6 +++++- Source/SysW32/Debug/DaedalusAssertW32.cpp | 11 ++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Source/SysPosix/main.cpp b/Source/SysPosix/main.cpp index cdd07e8f3..2702426d5 100644 --- a/Source/SysPosix/main.cpp +++ b/Source/SysPosix/main.cpp @@ -68,6 +68,7 @@ void HandleEndOfFrame() bool activate_pause_menu = false; sceCtrlPeekBufferPositive(&pad, 1); +#ifdef DAEDALUS_LINUX // If KernelButtons.prx not found. Use select for pause instead if (oldButtons != pad.Buttons) { @@ -100,6 +101,8 @@ void HandleEndOfFrame() // CPreferences::Get()->Commit(); } +#endif + // Reset the elapsed time to avoid glitches when we restart #ifdef DAEDALUS_PROFILE_EXECUTION gTimer.Reset(); @@ -177,7 +180,7 @@ int main(int argc, char **argv) System_Close(); } } - +#ifdef DAEDALUS_LINUX bool show_splash = true; for (;;) { @@ -190,6 +193,7 @@ int main(int argc, char **argv) CPU_Run(); System_Close(); } +#endif System_Finalize(); return result; diff --git a/Source/SysW32/Debug/DaedalusAssertW32.cpp b/Source/SysW32/Debug/DaedalusAssertW32.cpp index 537d088d0..82888f577 100644 --- a/Source/SysW32/Debug/DaedalusAssertW32.cpp +++ b/Source/SysW32/Debug/DaedalusAssertW32.cpp @@ -18,7 +18,7 @@ */ - +#include #include "Base/Types.h" #include "Base/Assert.h" @@ -59,16 +59,17 @@ EAssertResult DAEDALUS_VARARG_CALL_TYPE DaedalusAssert( const char * expression, EAssertResult DAEDALUS_VARARG_CALL_TYPE DaedalusAssert( const char * expression, const char * file, unsigned int line, const char * msg, ... ) { - char buffer[ 1024 ]; va_list va; va_start(va, msg); + + char buffer[ 1024 ]; vsnprintf( buffer, 1024, msg, va ); buffer[1023] = 0; va_end(va); - CHAR text[1024]; + char text[1024]; - wsprintf( text, "Debug Assertion Failed!\n" + sprintf( text, "Debug Assertion Failed!\n" "\n" "File: %s\n" "Line: %d\n" @@ -82,7 +83,7 @@ EAssertResult DAEDALUS_VARARG_CALL_TYPE DaedalusAssert( const char * expression, expression, buffer ); - int ret = ::MessageBox( NULL, text, "Assert", MB_ABORTRETRYIGNORE | MB_ICONERROR ); + int ret = ::MessageBoxA( NULL, text, "Assert", MB_ABORTRETRYIGNORE | MB_ICONERROR ); if ( ret == IDIGNORE ) return AR_IGNORE; From 8a6f1e63f0d4a76485749d283c75408b7547d0fa Mon Sep 17 00:00:00 2001 From: Howard Su Date: Fri, 8 Dec 2023 14:38:07 +0800 Subject: [PATCH 31/54] different approach to handle x64 dynarec --- Source/Core/CPU.cpp | 15 +++++++-------- Source/DynaRec/x64/AssemblyWriterX64.cpp | 4 ++++ Source/DynaRec/x64/DynarecStubX64.S | 8 +------- Source/DynaRec/x64/DynarecStubX64.asm | 12 +++--------- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/Source/Core/CPU.cpp b/Source/Core/CPU.cpp index b149c4d10..029df8f5a 100644 --- a/Source/Core/CPU.cpp +++ b/Source/Core/CPU.cpp @@ -672,16 +672,15 @@ void CPU_HANDLE_COUNT_INTERRUPT() // N cycles, but that would have a small impact on framerate (it would // interrupt the dynamo tracer for instance) // TODO(strmnnrmn): should register this with CPU_RegisterVblCallback. - if ((gVerticalInterrupts & 0x3F) == 0) // once every 60 VBLs - // Save_Flush(); + if ((gVerticalInterrupts & 0x3F) == 0) { // once every 60 VBLs + // Save_Flush(); + for (size_t i = 0; i < gVblCallbacks.size(); ++i) + { + VblCallback & callback = gVblCallbacks[i]; + callback.Fn(callback.Arg); + } - //TESTING - for (size_t i = 0; i < gVblCallbacks.size(); ++i) - { - VblCallback & callback = gVblCallbacks[i]; - callback.Fn(callback.Arg); } - HandleSaveStateOperationOnVerticalBlank(); } break; diff --git a/Source/DynaRec/x64/AssemblyWriterX64.cpp b/Source/DynaRec/x64/AssemblyWriterX64.cpp index e6c555952..184f5fa45 100644 --- a/Source/DynaRec/x64/AssemblyWriterX64.cpp +++ b/Source/DynaRec/x64/AssemblyWriterX64.cpp @@ -684,6 +684,10 @@ void CAssemblyWriterX64::CALL_MEM_PLUS_REGx4( void * mem, EIntelReg reg ) //***************************************************************************** void CAssemblyWriterX64::RET() { + EmitWORD(0x5e41); //0: 41 5e pop r14 + EmitWORD(0x5f41); // 2: 41 5f pop r15 + EmitBYTE(0x5b); // 4: 5b pop rbx + EmitBYTE(0x5d); // 5: 5d pop rbp EmitBYTE(0xC3); } diff --git a/Source/DynaRec/x64/DynarecStubX64.S b/Source/DynaRec/x64/DynarecStubX64.S index 2826e8b54..ff6bf6ccd 100644 --- a/Source/DynaRec/x64/DynarecStubX64.S +++ b/Source/DynaRec/x64/DynarecStubX64.S @@ -13,11 +13,5 @@ __EnterDynaRec: movq %rdx, %r15 movq %rcx, %r14 - call *%rax + jmp *%rax - popq %r14 - popq %r15 - popq %rbx - popq %rbp - - ret diff --git a/Source/DynaRec/x64/DynarecStubX64.asm b/Source/DynaRec/x64/DynarecStubX64.asm index 062c5475e..bf3488d67 100644 --- a/Source/DynaRec/x64/DynarecStubX64.asm +++ b/Source/DynaRec/x64/DynarecStubX64.asm @@ -10,18 +10,12 @@ _EnterDynaRec PROC mov rax, rcx - mov rcx, rdx + mov rbx, rdx mov r15, r8 mov r14, r9 - call qword ptr [rax] + jmp rax - pop r14 - pop r15 - pop rbx - pop rbp - - ret _EnterDynaRec ENDP -END \ No newline at end of file +END From f3a9ee81ae476203fffe9bb8f35e60114c56ef6f Mon Sep 17 00:00:00 2001 From: Howard Su Date: Fri, 8 Dec 2023 23:57:40 +0800 Subject: [PATCH 32/54] Fix windows --- Source/Core/ROMBuffer.cpp | 4 ++-- Source/DynaRec/x64/AssemblyUtilsX64.cpp | 17 +++++++++++------ Source/DynaRec/x64/DynarecStubX64.asm | 20 ++++++++++++++++---- Source/SysW32/Debug/DaedalusAssertW32.cpp | 2 +- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/Source/Core/ROMBuffer.cpp b/Source/Core/ROMBuffer.cpp index 3a9bfa539..b25596603 100644 --- a/Source/Core/ROMBuffer.cpp +++ b/Source/Core/ROMBuffer.cpp @@ -195,14 +195,14 @@ bool RomBuffer::Open() auto p_rom_file = ROMFile::Create( filename.c_str() ); if(p_rom_file == nullptr) { - DBGConsole_Msg(0, "Failed to create [C%s]\n", filename.c_str()); + DBGConsole_Msg(0, "Failed to create [C%s]\n", filename.string().c_str()); return false; } if( !p_rom_file->Open( messages ) ) { - DBGConsole_Msg(0, "Failed to open [C%s]\n", filename.c_str()); + DBGConsole_Msg(0, "Failed to open [C%s]\n", filename.string().c_str()); return false; } diff --git a/Source/DynaRec/x64/AssemblyUtilsX64.cpp b/Source/DynaRec/x64/AssemblyUtilsX64.cpp index f67f06c52..c73994db0 100644 --- a/Source/DynaRec/x64/AssemblyUtilsX64.cpp +++ b/Source/DynaRec/x64/AssemblyUtilsX64.cpp @@ -55,12 +55,17 @@ bool PatchJumpLong( CJumpLocation jump, CCodeLabel target ) return false; } - u32 offset( jump.GetOffset( target ) - instruction_length ); - - *p_jump_instr_offset = offset; - - // All jumps are 32 bit offsets, and so always succeed. - return true; + if (jump.IsIn32BitRange(target)) + { + // All jumps are 32 bit offsets, and so always succeed. + *p_jump_instr_offset = jump.GetOffset(target) - instruction_length; + return true; + } + else + { + DAEDALUS_ERROR( "Jump out of range" ); + return false; + } } //***************************************************************************** diff --git a/Source/DynaRec/x64/DynarecStubX64.asm b/Source/DynaRec/x64/DynarecStubX64.asm index bf3488d67..92d2e57a6 100644 --- a/Source/DynaRec/x64/DynarecStubX64.asm +++ b/Source/DynaRec/x64/DynarecStubX64.asm @@ -2,20 +2,32 @@ PUBLIC _EnterDynaRec -_EnterDynaRec PROC +_EnterDynaRec PROC FRAME push rbp +.PUSHREG RBP push rbx +.PUSHREG RBX push r15 +.PUSHREG R15 push r14 - - +.PUSHREG R14 + sub rsp, 32 +.allocstack 32 +.ENDPROLOG mov rax, rcx mov rbx, rdx mov r15, r8 mov r14, r9 - jmp rax + call rax + + add rsp, 32 + pop r14 + pop r15 + pop rbx + pop rbp + ret _EnterDynaRec ENDP END diff --git a/Source/SysW32/Debug/DaedalusAssertW32.cpp b/Source/SysW32/Debug/DaedalusAssertW32.cpp index 82888f577..6f242f4cc 100644 --- a/Source/SysW32/Debug/DaedalusAssertW32.cpp +++ b/Source/SysW32/Debug/DaedalusAssertW32.cpp @@ -34,7 +34,7 @@ DaedalusAssertHook gAssertHook = NULL; EAssertResult DAEDALUS_VARARG_CALL_TYPE DaedalusAssert( const char * expression, const char * file, unsigned int line, const char * msg, ... ) { va_list va; - va_start(va); + va_start(va, msg); char buffer[ 1024 ]; vsnprintf( buffer, 1024, msg, va ); From f5771fe451b64bea3789aae3abc74e123583bcc1 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Sat, 9 Dec 2023 09:31:11 +0800 Subject: [PATCH 33/54] Disable amd64 dynarec for now --- Source/CMakeLists.txt | 4 ++-- Source/DynaRec/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index c7e469069..40a4f1439 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -47,8 +47,8 @@ endif() message("x86_64 Dynarec Enabled") option(DAEDALUS_ENABLE_DYNAREC "Enable Dynarec" ON) elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64") - message("AMD64 Dynarec Enabled") - option(DAEDALUS_ENABLE_DYNAREC "Enable Dynarec" ON) + message("AMD64 Dynarec Disabled") + option(DAEDALUS_ENABLE_DYNAREC "Enable Dynarec" OFF) else() message("Platform unknown, Dynarec disabled") option(DAEDALUS_ENABLE_DYNAREC "Enable Dynarec" OFF) diff --git a/Source/DynaRec/CMakeLists.txt b/Source/DynaRec/CMakeLists.txt index 5c087ebfd..084aecb20 100644 --- a/Source/DynaRec/CMakeLists.txt +++ b/Source/DynaRec/CMakeLists.txt @@ -2,8 +2,8 @@ if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv") file(GLOB SRC_FILES ARM/*.cpp ARM/*.S) elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") file(GLOB SRC_FILES x64/*.cpp x64/*.S) -elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64") - file(GLOB SRC_FILES x64/*.cpp x64/*.asm) +#elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64") +# file(GLOB SRC_FILES x64/*.cpp x64/*.asm) elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86") file(GLOB SRC_FILES x86/*.cpp x86/*.S) elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "mips") From 29aa05b38e2066367b429dc7fa6e0f65bc301a4f Mon Sep 17 00:00:00 2001 From: Howard Su Date: Sat, 9 Dec 2023 17:33:53 +0800 Subject: [PATCH 34/54] fix compile error --- Source/Debug/DebugLog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Debug/DebugLog.cpp b/Source/Debug/DebugLog.cpp index c918bd87e..bb2b12fd8 100644 --- a/Source/Debug/DebugLog.cpp +++ b/Source/Debug/DebugLog.cpp @@ -39,15 +39,15 @@ static FILE * g_hOutputLog = NULL; //***************************************************************************** bool Debug_InitLogging() { - std::filesystem::path log_filename = "daedalus.txt"; + const char* log_filename = "daedalus.txt"; #ifdef DAEDALUS_DEBUG_CONSOLE if ( CDebugConsole::IsAvailable() ) { - CDebugConsole::Get()->Msg( 0, "Creating Dump file '%s'", log_filename.c_str() ); + CDebugConsole::Get()->Msg( 0, "Creating Dump file '%s'", log_filename); } #endif - g_hOutputLog = fopen( log_filename.c_str(), "w" ); + g_hOutputLog = fopen( log_filename, "w" ); return g_hOutputLog != NULL; } From b6250015a831c1b23f2d55eeddd22cddd36dfab5 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Sat, 9 Dec 2023 17:43:44 +0800 Subject: [PATCH 35/54] Fix display on Windows --- Source/SysGL/Graphics/GraphicsContextGL.cpp | 4 ++-- Source/SysGL/Graphics/UIContextGL.cpp | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/SysGL/Graphics/GraphicsContextGL.cpp b/Source/SysGL/Graphics/GraphicsContextGL.cpp index 68f37c45a..3d8ed65c6 100644 --- a/Source/SysGL/Graphics/GraphicsContextGL.cpp +++ b/Source/SysGL/Graphics/GraphicsContextGL.cpp @@ -115,8 +115,6 @@ bool GraphicsContextGL::Initialise() //Create window gWindow = SDL_CreateWindow( "Daedalus", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCR_WIDTH, SCR_HEIGHT, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI); - gSdlRenderer = SDL_CreateRenderer(gWindow, 0, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC) ; - //Create context SDL_GLContext gContext = SDL_GL_CreateContext( gWindow ); @@ -124,6 +122,8 @@ bool GraphicsContextGL::Initialise() SDL_GL_SetSwapInterval(1); + gSdlRenderer = SDL_CreateRenderer(gWindow, 0, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC) ; + GLenum err = glewInit(); if (err != GLEW_OK || !GLEW_VERSION_3_2) { diff --git a/Source/SysGL/Graphics/UIContextGL.cpp b/Source/SysGL/Graphics/UIContextGL.cpp index dd6f90388..f397b3662 100644 --- a/Source/SysGL/Graphics/UIContextGL.cpp +++ b/Source/SysGL/Graphics/UIContextGL.cpp @@ -365,11 +365,16 @@ s32 IUIContext::DrawTextArea( s32 left, s32 top, u32 width, u32 height, const c void IUIContext::BeginRender() { CGraphicsContext::Get()->BeginFrame(); + + // Clear the screen + SDL_RenderClear(gSdlRenderer); } void IUIContext::EndRender() { + SDL_RenderPresent(gSdlRenderer); + CGraphicsContext::Get()->EndFrame(); CGraphicsContext::Get()->UpdateFrame( true ); } From 199835e701c812cd8efd822b310110990b2e90a1 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Sat, 9 Dec 2023 22:03:38 +0800 Subject: [PATCH 36/54] support OSX and enable screen scale --- Source/SysGL/Graphics/DrawTextSDL.cpp | 16 +++++++++--- Source/SysGL/Graphics/UIContextGL.cpp | 33 +++++++++++++++++-------- Source/SysGL/HLEGraphics/RendererGL.cpp | 19 ++------------ Source/SysPosix/main.cpp | 3 +-- 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/Source/SysGL/Graphics/DrawTextSDL.cpp b/Source/SysGL/Graphics/DrawTextSDL.cpp index 90673d1b2..3bd4cbfe6 100644 --- a/Source/SysGL/Graphics/DrawTextSDL.cpp +++ b/Source/SysGL/Graphics/DrawTextSDL.cpp @@ -1,6 +1,8 @@ #include "SysGL/GL.h" #include "UI/DrawText.h" +static float scaleX = 1.0f, scaleY = 1.0f; + TTF_Font *gFonts[] = { nullptr, @@ -51,10 +53,10 @@ u32 CDrawText::Render(EFont font_type, s32 x, s32 y, float scale, const char *p_ SDL_Texture* Message = SDL_CreateTextureFromSurface(gSdlRenderer, surface); SDL_Rect Message_rect; //create a rect - Message_rect.x = x; //controls the rect's x coordinate - Message_rect.y = y; // controls the rect's y coordinte - Message_rect.w = surface->w * scale; // controls the width of the rect - Message_rect.h = surface->h * scale; // controls the height of the rect + Message_rect.x = x * scaleX; //controls the rect's x coordinate + Message_rect.y = y * scaleY; // controls the rect's y coordinte + Message_rect.w = surface->w * scaleX * scale; // controls the width of the rect + Message_rect.h = surface->h * scaleY * scale; // controls the height of the rect SDL_RenderCopy(gSdlRenderer, Message, NULL, &Message_rect); @@ -110,3 +112,9 @@ s32 CDrawText::GetFontHeight(EFont font_type) return 0; // Return a reasonable value. Better off just returning 0? } + +void DrawText_SetScale(float X, float Y) +{ + scaleX = X; + scaleY = Y; +} \ No newline at end of file diff --git a/Source/SysGL/Graphics/UIContextGL.cpp b/Source/SysGL/Graphics/UIContextGL.cpp index f397b3662..a7aa4faad 100644 --- a/Source/SysGL/Graphics/UIContextGL.cpp +++ b/Source/SysGL/Graphics/UIContextGL.cpp @@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Math/Matrix4x4.h" #include "Graphics/GraphicsContext.h" #include "Graphics/NativeTexture.h" +#include "UI/PSPMenu.h" #include "UI/DrawText.h" #include "UI/UIContext.h" #include "UI/DrawTextUtilities.h" @@ -96,6 +97,9 @@ class IUIContext : public CUIContext CDrawText::EFont mCurrentFont; CColourPulser mColourPulser; c32 mBackgroundColour; + float scaleX; + float scaleY; + }; CUIContext::~CUIContext() {} @@ -180,10 +184,10 @@ void IUIContext::RenderTexture( const std::shared_ptr texture, c ); SDL_Rect Message_rect; //create a rect - Message_rect.x = tl.x; //controls the rect's x coordinate - Message_rect.y = tl.y; // controls the rect's y coordinte - Message_rect.w = surface->w; // controls the width of the rect - Message_rect.h = surface->h; // controls the height of the rect + Message_rect.x = tl.x * scaleX; //controls the rect's x coordinate + Message_rect.y = tl.y * scaleY; // controls the rect's y coordinte + Message_rect.w = surface->w * scaleX; // controls the width of the rect + Message_rect.h = surface->h * scaleY; // controls the height of the rect SDL_Texture* Message = SDL_CreateTextureFromSurface(gSdlRenderer, surface); SDL_RenderCopy(gSdlRenderer, Message, NULL, &Message_rect); @@ -201,10 +205,10 @@ void IUIContext::ClearBackground( c32 colour ) void IUIContext::DrawRect( s32 x, s32 y, u32 w, u32 h, c32 colour ) { SDL_Rect rect; - rect.x = x; - rect.y = y; - rect.w = w; - rect.h = h; + rect.x = x * scaleX; + rect.y = y * scaleY; + rect.w = w * scaleX; + rect.h = h * scaleY; SDL_SetRenderDrawColor(gSdlRenderer, colour.GetR(), colour.GetG(), @@ -220,7 +224,7 @@ void IUIContext::DrawLine( s32 x0, s32 y0, s32 x1, s32 y1, c32 colour ) colour.GetG(), colour.GetG(), colour.GetA()); - SDL_RenderDrawLine(gSdlRenderer, x0, y0, x1, y1); + SDL_RenderDrawLine(gSdlRenderer, x0 * scaleX, y0 * scaleY, x1 * scaleX, y1 * scaleY); } @@ -360,7 +364,8 @@ s32 IUIContext::DrawTextArea( s32 left, s32 top, u32 width, u32 height, const c return y - top; } -// +//TODO: Should be in draw text interface +extern void DrawText_SetScale(float X, float Y); void IUIContext::BeginRender() { @@ -368,6 +373,14 @@ void IUIContext::BeginRender() // Clear the screen SDL_RenderClear(gSdlRenderer); + + // Caculate the scaleX and scale Y + u32 display_width, display_height; + CGraphicsContext::Get()->ViewportType(&display_width, &display_height); + scaleX = display_width * 1.0f / SCREEN_WIDTH; + scaleY = display_height * 1.0f / SCREEN_HEIGHT; + + DrawText_SetScale(scaleX, scaleY); } diff --git a/Source/SysGL/HLEGraphics/RendererGL.cpp b/Source/SysGL/HLEGraphics/RendererGL.cpp index 96462c66d..1132ca51b 100644 --- a/Source/SysGL/HLEGraphics/RendererGL.cpp +++ b/Source/SysGL/HLEGraphics/RendererGL.cpp @@ -25,18 +25,6 @@ RendererGL * gRendererGL = NULL; static bool gAccurateUVPipe = true; -/* OpenGL 3.0 */ -using PFN_glGenVertexArrays = void (GLAPIENTRY *)(GLsizei n, GLuint *arrays); -using PFN_glBindVertexArray = void (GLAPIENTRY *)(GLuint array); -using PFN_glDeleteVertexArrays = void (GLAPIENTRY *)(GLsizei n, GLuint *arrays); -// typedef void (GLAPIENTRY * PFN_glGenVertexArrays)(GLsizei n, GLuint *arrays); -// typedef void (GLAPIENTRY * PFN_glBindVertexArray)(GLuint array); -// typedef void (GLAPIENTRY * PFN_glDeleteVertexArrays)(GLsizei n, GLuint *arrays); - -static PFN_glGenVertexArrays pglGenVertexArrays = NULL; -static PFN_glBindVertexArray pglBindVertexArray = NULL; -static PFN_glDeleteVertexArrays pglDeleteVertexArrays = NULL; - // We read n64.psh into this. static const char * gN64FramentLibrary = NULL; @@ -124,12 +112,9 @@ bool initgl() // FIXME(strmnnrmn): we shouldn't need these with GLEW, but they don't seem to resolve on OSX. GLboolean status = GL_TRUE; - RESOLVE_GL_FCN(PFN_glGenVertexArrays, pglGenVertexArrays, "glGenVertexArrays"); - RESOLVE_GL_FCN(PFN_glDeleteVertexArrays, pglDeleteVertexArrays, "glDeleteVertexArrays"); - RESOLVE_GL_FCN(PFN_glBindVertexArray, pglBindVertexArray, "glBindVertexArray"); - pglGenVertexArrays(1, &gVAO); - pglBindVertexArray(gVAO); + glGenVertexArrays(1, &gVAO); + glBindVertexArray(gVAO); glGenBuffers(kNumBuffers, gVBOs); diff --git a/Source/SysPosix/main.cpp b/Source/SysPosix/main.cpp index 2702426d5..806185c46 100644 --- a/Source/SysPosix/main.cpp +++ b/Source/SysPosix/main.cpp @@ -180,7 +180,7 @@ int main(int argc, char **argv) System_Close(); } } -#ifdef DAEDALUS_LINUX + bool show_splash = true; for (;;) { @@ -193,7 +193,6 @@ int main(int argc, char **argv) CPU_Run(); System_Close(); } -#endif System_Finalize(); return result; From 43f6f8141194d9b69e3e1560a64367a89823e5d9 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Sat, 9 Dec 2023 22:25:15 +0800 Subject: [PATCH 37/54] Fix font height API on TTF --- Source/SysGL/Graphics/DrawTextSDL.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/SysGL/Graphics/DrawTextSDL.cpp b/Source/SysGL/Graphics/DrawTextSDL.cpp index 3bd4cbfe6..d0a586223 100644 --- a/Source/SysGL/Graphics/DrawTextSDL.cpp +++ b/Source/SysGL/Graphics/DrawTextSDL.cpp @@ -13,7 +13,7 @@ DAEDALUS_STATIC_ASSERT(ARRAYSIZE(gFonts) == CDrawText::NUM_FONTS); void CDrawText::Initialise() { gFonts[CDrawText::F_REGULAR] = TTF_OpenFont("Resources/OpenSans.ttf", 12); - gFonts[CDrawText::F_LARGE_BOLD] = TTF_OpenFont("Resources/OpenSans.ttf", 24); + gFonts[CDrawText::F_LARGE_BOLD] = TTF_OpenFont("Resources/OpenSans.ttf", 22); TTF_SetFontStyle(gFonts[CDrawText::F_LARGE_BOLD], TTF_STYLE_BOLD); if (gFonts[0] == 0) @@ -107,7 +107,7 @@ s32 CDrawText::GetFontHeight(EFont font_type) TTF_Font *font(gFonts[font_type]); if (font) { - return TTF_FontHeight(font); + return TTF_FontAscent(font); } return 0; // Return a reasonable value. Better off just returning 0? @@ -115,6 +115,7 @@ s32 CDrawText::GetFontHeight(EFont font_type) void DrawText_SetScale(float X, float Y) { + //TODO: we can scale the font size? scaleX = X; scaleY = Y; } \ No newline at end of file From 22e7d34dbc9a99081ac698e39a6b2b5522ad3575 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Sat, 9 Dec 2023 22:32:39 +0800 Subject: [PATCH 38/54] try to render utf8 --- Source/SysGL/Graphics/DrawTextSDL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/SysGL/Graphics/DrawTextSDL.cpp b/Source/SysGL/Graphics/DrawTextSDL.cpp index d0a586223..4b337c8e7 100644 --- a/Source/SysGL/Graphics/DrawTextSDL.cpp +++ b/Source/SysGL/Graphics/DrawTextSDL.cpp @@ -49,7 +49,7 @@ u32 CDrawText::Render(EFont font_type, s32 x, s32 y, float scale, const char *p_ { SDL_Color c {colour.GetR(), colour.GetG(), colour.GetB()}; SDL_Color dc {drop_colour.GetR(), drop_colour.GetG(), drop_colour.GetB()}; - SDL_Surface *surface = TTF_RenderText_Shaded(font, p_str, c, dc); + SDL_Surface *surface = TTF_RenderUTF8_Shaded(font, p_str, c, dc); SDL_Texture* Message = SDL_CreateTextureFromSurface(gSdlRenderer, surface); SDL_Rect Message_rect; //create a rect From 0e5a430752ac60d9b66fa1e98d11f563a5830a07 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Sat, 9 Dec 2023 22:41:20 +0800 Subject: [PATCH 39/54] Try to fix linux build --- CMakeLists.txt | 2 ++ Source/CMakeLists.txt | 9 +++++++-- Source/SysGL/CMakeLists.txt | 13 ------------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b77233448..e6e747b76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,4 +3,6 @@ project (DaedalusX64 LANGUAGES C CXX ASM) message(${CMAKE_SYSTEM_PROCESSOR} " Detected") +INCLUDE(FindPkgConfig) + add_subdirectory(Source) \ No newline at end of file diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 40a4f1439..460a8a3c0 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -168,8 +168,13 @@ if(DAEDALUS_SDL) if(NOT PSP) # PSP is not needed as it uses built-in native font - find_package(SDL2_ttf REQUIRED) - link_libraries(SDL2_ttf::SDL2_ttf) + find_package(SDL2_ttf QUIET) + if(SDL2_ttf_FOUND) + link_libraries(SDL2_ttf::SDL2_ttf) + else() + PKG_SEARCH_MODULE(SDL2_TTF REQUIRED SDL2_ttf>=2.0.0) + link_libraries(${SDL2_TTF_LIBRARIES}) + endif() endif() endif(DAEDALUS_SDL) diff --git a/Source/SysGL/CMakeLists.txt b/Source/SysGL/CMakeLists.txt index 29ad5a674..f7ea01018 100644 --- a/Source/SysGL/CMakeLists.txt +++ b/Source/SysGL/CMakeLists.txt @@ -1,24 +1,11 @@ - file(GLOB SRC_FILES Graphics/*.cpp HLEGraphics/*.cpp Input/*.cpp Interface/*.cpp) add_library(SysGL OBJECT ${SRC_FILES}) -find_package(OpenGL REQUIRED) target_include_directories(SysGL PUBLIC ${OPENGL_INCLUDE_DIR}) -link_libraries(OpenGL::GL) - -find_package(GLEW REQUIRED) target_include_directories(SysGL PUBLIC ${GLEW_INCLUDE_DIRS}) -link_libraries(GLEW::GLEW) - -find_package(SDL2 CONFIG REQUIRED) target_include_directories(SysGL PUBLIC ${SDL2_INCLUDE_DIRS}) -link_libraries(SDL2::SDL2) - -# PSP is not needed as it uses built-in native font -find_package(SDL2_ttf REQUIRED) target_include_directories(SysGL PUBLIC ${SDL2_TTF_INCLUDE_DIRS}) -link_libraries(SDL2_ttf::SDL2_ttf) install(FILES ${PROJECT_SOURCE_DIR}/Source/SysGL/HLEGraphics/n64.psh DESTINATION DaedalusX64) From 15b9a01c95c0d46820a15b24f58094bb56258543 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Sat, 9 Dec 2023 19:19:45 +0800 Subject: [PATCH 40/54] Fix debug build --- Source/Base/Assert.h | 2 -- Source/CMakeLists.txt | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Base/Assert.h b/Source/Base/Assert.h index f493dfb72..23b484a4c 100644 --- a/Source/Base/Assert.h +++ b/Source/Base/Assert.h @@ -51,8 +51,6 @@ enum EAssertResult #define _CRT_SECURE_NO_DEPRECATE #define _DO_NOT_DECLARE_INTERLOCKED_INTRINSICS_IN_MEMORY - #define DAEDALUS_THREAD_CALL_TYPE __stdcall // Thread functions need to be __stdcall to work with the W32 api - #define DAEDALUS_VARARG_CALL_TYPE __cdecl // Vararg functions need to be __cdecl #define DAEDALUS_HALT _CrtDbgBreak() #else #error Unknown Platforn DAEDALUS_HALT should be defined in Base/Assert.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 460a8a3c0..e9d8a15bd 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -134,6 +134,9 @@ endif() if(NOT WIN32) add_compile_definitions(DAEDALUS_THREAD_CALL_TYPE=${}) add_compile_definitions(DAEDALUS_VARARG_CALL_TYPE=${}) +else() + add_compile_definitions(DAEDALUS_THREAD_CALL_TYPE=__stdcall) + add_compile_definitions(DAEDALUS_VARARG_CALL_TYPE=__cdecl) endif() if(UNIX) From 9cba217b739bed3a9b3009ca19c7d4c27570c40d Mon Sep 17 00:00:00 2001 From: Howard Su Date: Sun, 10 Dec 2023 13:22:32 +0800 Subject: [PATCH 41/54] osx has this support --- Source/SysPosix/main.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/SysPosix/main.cpp b/Source/SysPosix/main.cpp index 806185c46..cdd07e8f3 100644 --- a/Source/SysPosix/main.cpp +++ b/Source/SysPosix/main.cpp @@ -68,7 +68,6 @@ void HandleEndOfFrame() bool activate_pause_menu = false; sceCtrlPeekBufferPositive(&pad, 1); -#ifdef DAEDALUS_LINUX // If KernelButtons.prx not found. Use select for pause instead if (oldButtons != pad.Buttons) { @@ -101,8 +100,6 @@ void HandleEndOfFrame() // CPreferences::Get()->Commit(); } -#endif - // Reset the elapsed time to avoid glitches when we restart #ifdef DAEDALUS_PROFILE_EXECUTION gTimer.Reset(); From c49122bb87ea0e489aeff9d5b0b89945f08b9d7c Mon Sep 17 00:00:00 2001 From: Howard Su Date: Sun, 10 Dec 2023 19:38:21 +0800 Subject: [PATCH 42/54] Try to fix OSX --- Source/SysGL/Graphics/GraphicsContextGL.cpp | 3 +-- Source/SysGL/Graphics/UIContextGL.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Source/SysGL/Graphics/GraphicsContextGL.cpp b/Source/SysGL/Graphics/GraphicsContextGL.cpp index 3d8ed65c6..545f76a72 100644 --- a/Source/SysGL/Graphics/GraphicsContextGL.cpp +++ b/Source/SysGL/Graphics/GraphicsContextGL.cpp @@ -122,8 +122,6 @@ bool GraphicsContextGL::Initialise() SDL_GL_SetSwapInterval(1); - gSdlRenderer = SDL_CreateRenderer(gWindow, 0, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC) ; - GLenum err = glewInit(); if (err != GLEW_OK || !GLEW_VERSION_3_2) { @@ -212,6 +210,7 @@ void GraphicsContextGL::EndFrame() void GraphicsContextGL::UpdateFrame( bool wait_for_vbl ) { + glBindFramebuffer(GL_FRAMEBUFFER, 0); SDL_GL_SwapWindow(gWindow); // if( gCleanSceneEnabled ) //TODO: This should be optional diff --git a/Source/SysGL/Graphics/UIContextGL.cpp b/Source/SysGL/Graphics/UIContextGL.cpp index a7aa4faad..3a44fdcd7 100644 --- a/Source/SysGL/Graphics/UIContextGL.cpp +++ b/Source/SysGL/Graphics/UIContextGL.cpp @@ -102,16 +102,19 @@ class IUIContext : public CUIContext }; -CUIContext::~CUIContext() {} +CUIContext::~CUIContext() { + SDL_DestroyRenderer(gSdlRenderer); + gSdlRenderer = nullptr; +} CUIContext * CUIContext::Create() { return new IUIContext; } - - IUIContext::IUIContext() : mCurrentFont( CDrawText::F_REGULAR ) , mColourPulser( COLOUR_SELECTION_DIM, COLOUR_SELECTION_BRIGHT, MS_PER_COLOUR_CYCLE ) , mBackgroundColour( 0,0,0 ) -{} +{ + gSdlRenderer = SDL_CreateRenderer(gWindow, 0, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); +} IUIContext::~IUIContext() @@ -192,8 +195,7 @@ void IUIContext::RenderTexture( const std::shared_ptr texture, c SDL_Texture* Message = SDL_CreateTextureFromSurface(gSdlRenderer, surface); SDL_RenderCopy(gSdlRenderer, Message, NULL, &Message_rect); SDL_FreeSurface(surface); - - + SDL_DestroyTexture(Message); } From 5868e252b10c838bccc6f2a4d30353197611ad86 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Sun, 10 Dec 2023 21:41:03 +0800 Subject: [PATCH 43/54] Fix Dynarec X64 bug on Windows --- Source/DynaRec/x64/CodeGeneratorX64.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/DynaRec/x64/CodeGeneratorX64.cpp b/Source/DynaRec/x64/CodeGeneratorX64.cpp index 8a0c5fa3b..a3829c54d 100644 --- a/Source/DynaRec/x64/CodeGeneratorX64.cpp +++ b/Source/DynaRec/x64/CodeGeneratorX64.cpp @@ -706,8 +706,8 @@ void CCodeGeneratorX64::GenerateCACHE( EN64Reg base, s16 offset, u32 cache_op ) if(dwCache == 0 && (dwAction == 0 || dwAction == 4)) { MOV_REG_MEM(RCX_CODE, &gCPUState.CPU[base]._u32_0); - MOVI(RDX_CODE, 0x20); - ADDI(RCX_CODE, offset); + MOVI(FIRST_PARAM_REG_CODE, 0x20); + ADDI(SECOND_PARAM_REG_CODE, offset); CALL( CCodeLabel( reinterpret_cast< const void * >( CPU_InvalidateICacheRange ) )); } else From 806baac2f6ebbf59dce9e10003e918f7cb4ce886 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Sun, 10 Dec 2023 21:41:27 +0800 Subject: [PATCH 44/54] Enable AMD64 dynarec again --- Source/CMakeLists.txt | 4 ++-- Source/DynaRec/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index e9d8a15bd..b4b8e309f 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -47,8 +47,8 @@ endif() message("x86_64 Dynarec Enabled") option(DAEDALUS_ENABLE_DYNAREC "Enable Dynarec" ON) elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64") - message("AMD64 Dynarec Disabled") - option(DAEDALUS_ENABLE_DYNAREC "Enable Dynarec" OFF) + message("AMD64 Dynarec Enabled") + option(DAEDALUS_ENABLE_DYNAREC "Enable Dynarec" ON) else() message("Platform unknown, Dynarec disabled") option(DAEDALUS_ENABLE_DYNAREC "Enable Dynarec" OFF) diff --git a/Source/DynaRec/CMakeLists.txt b/Source/DynaRec/CMakeLists.txt index 084aecb20..5c087ebfd 100644 --- a/Source/DynaRec/CMakeLists.txt +++ b/Source/DynaRec/CMakeLists.txt @@ -2,8 +2,8 @@ if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv") file(GLOB SRC_FILES ARM/*.cpp ARM/*.S) elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") file(GLOB SRC_FILES x64/*.cpp x64/*.S) -#elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64") -# file(GLOB SRC_FILES x64/*.cpp x64/*.asm) +elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64") + file(GLOB SRC_FILES x64/*.cpp x64/*.asm) elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86") file(GLOB SRC_FILES x86/*.cpp x86/*.S) elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "mips") From 8f408a62a6b1be43b1dcd8c7f711ecd21f4fa431 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Sun, 10 Dec 2023 22:25:04 +0800 Subject: [PATCH 45/54] Fix windows x64 dynarec Allocate 32bytes shadow area --- Source/DynaRec/x64/AssemblyWriterX64.cpp | 45 +++++++++++++++++++++--- Source/DynaRec/x64/AssemblyWriterX64.h | 1 + 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/Source/DynaRec/x64/AssemblyWriterX64.cpp b/Source/DynaRec/x64/AssemblyWriterX64.cpp index 184f5fa45..8c7203ef1 100644 --- a/Source/DynaRec/x64/AssemblyWriterX64.cpp +++ b/Source/DynaRec/x64/AssemblyWriterX64.cpp @@ -275,6 +275,39 @@ void CAssemblyWriterX64::ADDI(EIntelReg reg, s32 data, bool is64) } +//***************************************************************************** +// Use short form (0x83c0) if data is just one byte! +//***************************************************************************** +void CAssemblyWriterX64::SUBI(EIntelReg reg, s32 data, bool is64) +{ + if (data == 0) + return; + + if (is64) + { + u8 first_byte = 0x48; + if (reg >= R8_CODE) { + first_byte |= 0x4; + reg = EIntelReg(reg & 7); + } + EmitBYTE(first_byte); + } + + if (data <= 127 && data > -127) + { + EmitBYTE(0x83); + EmitBYTE(0xe8 | reg); + EmitBYTE((u8)data); + } + else + { + EmitBYTE(0x81); + EmitBYTE(0xe8 | reg); + EmitDWORD(data); + } +} + + //***************************************************************************** // Use short form (0x83d0) if data is just one byte! //***************************************************************************** @@ -634,6 +667,10 @@ CJumpLocation CAssemblyWriterX64::CALL( CCodeLabel target ) { const u32 CALL_LONG_LENGTH = 5; +#ifdef DAEDALUS_W32 + SUBI(RSP_CODE, 32, true); +#endif + CJumpLocation jump_location( mpAssemblyBuffer->GetJumpLocation() ); CJumpLocation rbx_location(&gCPUState); @@ -649,6 +686,10 @@ CJumpLocation CAssemblyWriterX64::CALL( CCodeLabel target ) LEA(RAX_CODE, target.GetTargetU8P()); EmitWORD(0xd0ff); } + +#ifdef DAEDALUS_W32 + ADDI(RSP_CODE, 32, true); +#endif return jump_location; } @@ -684,10 +725,6 @@ void CAssemblyWriterX64::CALL_MEM_PLUS_REGx4( void * mem, EIntelReg reg ) //***************************************************************************** void CAssemblyWriterX64::RET() { - EmitWORD(0x5e41); //0: 41 5e pop r14 - EmitWORD(0x5f41); // 2: 41 5f pop r15 - EmitBYTE(0x5b); // 4: 5b pop rbx - EmitBYTE(0x5d); // 5: 5d pop rbp EmitBYTE(0xC3); } diff --git a/Source/DynaRec/x64/AssemblyWriterX64.h b/Source/DynaRec/x64/AssemblyWriterX64.h index d120f1f63..70c02b912 100644 --- a/Source/DynaRec/x64/AssemblyWriterX64.h +++ b/Source/DynaRec/x64/AssemblyWriterX64.h @@ -78,6 +78,7 @@ class CAssemblyWriterX64 void NOT(EIntelReg reg1, bool is64 = false); void ADDI(EIntelReg reg, s32 data, bool is64 = false); + void SUBI(EIntelReg reg, s32 data, bool is64 = false); void ADCI(EIntelReg reg, s32 data); void ANDI(EIntelReg reg, u32 data, bool is64 = false); void ORI(EIntelReg reg, u32 data, bool is64 = false); From 76ca4a457af80b5f0dcdd5f1a65838aaf24cb40a Mon Sep 17 00:00:00 2001 From: Howard Su Date: Sun, 10 Dec 2023 23:05:17 +0800 Subject: [PATCH 46/54] Fix Windows x64 dynarec --- Source/DynaRec/x64/CodeGeneratorX64.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/DynaRec/x64/CodeGeneratorX64.cpp b/Source/DynaRec/x64/CodeGeneratorX64.cpp index a3829c54d..408ca0910 100644 --- a/Source/DynaRec/x64/CodeGeneratorX64.cpp +++ b/Source/DynaRec/x64/CodeGeneratorX64.cpp @@ -705,9 +705,9 @@ void CCodeGeneratorX64::GenerateCACHE( EN64Reg base, s16 offset, u32 cache_op ) // dynarec system can be invalidated if(dwCache == 0 && (dwAction == 0 || dwAction == 4)) { - MOV_REG_MEM(RCX_CODE, &gCPUState.CPU[base]._u32_0); - MOVI(FIRST_PARAM_REG_CODE, 0x20); - ADDI(SECOND_PARAM_REG_CODE, offset); + MOV_REG_MEM(FIRST_PARAM_REG_CODE, &gCPUState.CPU[base]._u32_0); + MOVI(SECOND_PARAM_REG_CODE, 0x20); + ADDI(FIRST_PARAM_REG_CODE, offset); CALL( CCodeLabel( reinterpret_cast< const void * >( CPU_InvalidateICacheRange ) )); } else @@ -728,8 +728,8 @@ void CCodeGeneratorX64::GenerateLoad(EN64Reg base, s16 offset, u8 twiddle, u8 bi } else { - ADDI(RCX_CODE, offset); - XORI(RCX_CODE, twiddle); + ADDI(RCX_CODE, offset, true); + XORI(RCX_CODE, twiddle, true); ADD(RCX_CODE, R15_CODE, true); switch(bits) { From b1609f80cccde6f70cc51b05cb80946b76ae06a8 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Mon, 11 Dec 2023 08:17:50 +0800 Subject: [PATCH 47/54] Add vcpkg installation script --- .github/workflows/compilation.yml | 26 ++++++++++++++++++++++++-- .gitignore | 1 + vcpkg-configuration.json | 14 ++++++++++++++ vcpkg.json | 9 +++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 vcpkg-configuration.json create mode 100644 vcpkg.json diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index f00175c89..b77be5aa1 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -136,7 +136,6 @@ jobs: # env: # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - build-macos: runs-on: macOS-latest steps: @@ -200,4 +199,27 @@ jobs: # files: daedalusX64-macos-x86.tar.gz # tag_name: ${{ steps.tag.outputs.VERSION }} # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build-windows: + runs-on: windows-latest + envs: + VCPKG_DEFAULT_TRIPLET: x64-windows + steps: + - uses: actions/checkout@v2 + + - uses: lukka/get-cmake@latest + + - name: Setup a new (or from cache) vcpkg + uses: lukka/run-vcpkg@v11 + with: + vcpkgGitCommitId: aa628ceb5f15f0c30d4d481f14fa5b2be2b4a658 + runVcpkgInstall: true + + - name: Run CMake config + run: | + cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=$ENV:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -G "Visual Studio 16 2019" -A x64 + + - name: Build + run: | + cmake --build build --config Release diff --git a/.gitignore b/.gitignore index 94f41a10a..339160ca1 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ Source/tmp *.cia *.3dsx /debug/ +/vcpkg_installed/ diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json new file mode 100644 index 000000000..e5267885c --- /dev/null +++ b/vcpkg-configuration.json @@ -0,0 +1,14 @@ +{ + "default-registry": { + "kind": "git", + "baseline": "aa628ceb5f15f0c30d4d481f14fa5b2be2b4a658", + "repository": "https://github.com/microsoft/vcpkg" + }, + "registries": [ + { + "kind": "artifact", + "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", + "name": "microsoft" + } + ] +} diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 000000000..244bace41 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,9 @@ +{ + "dependencies": [ + "zlib", + "glew", + "libpng", + "sdl2", + "sdl2-ttf" + ] +} From 9adbe815a28fb0b90d029ab1e1964902a1a4b63d Mon Sep 17 00:00:00 2001 From: Howard Su Date: Mon, 11 Dec 2023 20:18:05 +0800 Subject: [PATCH 48/54] Fix env in workflow yml --- .github/workflows/compilation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index a9fab0265..fdae7c74d 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -252,7 +252,7 @@ jobs: build-windows: runs-on: windows-latest - envs: + env: VCPKG_DEFAULT_TRIPLET: x64-windows steps: - uses: actions/checkout@v2 From 6f4bd8824f2a89982fbe004011a0d6dde8c24dc9 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Mon, 11 Dec 2023 20:32:29 +0800 Subject: [PATCH 49/54] Fix 3ds build --- Source/Interface/GlobalPreferences.h | 6 +----- Source/Interface/Preferences.cpp | 6 +++--- Source/SysCTR/Input/InputManagerCTR.cpp | 2 +- Source/SysPSP/HLEGraphics/GraphicsPluginPSP.cpp | 15 ++------------- Source/UI/GlobalSettingsComponent.cpp | 16 ++++++---------- 5 files changed, 13 insertions(+), 32 deletions(-) diff --git a/Source/Interface/GlobalPreferences.h b/Source/Interface/GlobalPreferences.h index d7401708a..6280e4eac 100644 --- a/Source/Interface/GlobalPreferences.h +++ b/Source/Interface/GlobalPreferences.h @@ -54,12 +54,8 @@ enum ETVType struct SGlobalPreferences { - // This will need to be changed globally as it makes a lot more sense - #if defined(DAEDALUS_CTR) bool DisplayFramerate; - #else - u32 DisplayFramerate; - #endif + #ifdef DAEDALUS_DEBUG_DISPLAYLIST bool HighlightInexactBlendModes; bool CustomBlendModes; diff --git a/Source/Interface/Preferences.cpp b/Source/Interface/Preferences.cpp index dddf14622..46161d9f5 100644 --- a/Source/Interface/Preferences.cpp +++ b/Source/Interface/Preferences.cpp @@ -147,7 +147,7 @@ bool IPreferences::OpenPreferencesFile( const std::filesystem::path &filename ) const SGlobalPreferences defaults; - INT_SETTING( gGlobalPreferences, DisplayFramerate, defaults ); + BOOL_SETTING( gGlobalPreferences, DisplayFramerate, defaults ); BOOL_SETTING( gGlobalPreferences, ForceLinearFilter, defaults ); BOOL_SETTING( gGlobalPreferences, RumblePak, defaults ); #ifdef DAEDALUS_DEBUG_DISPLAYLIST @@ -338,7 +338,7 @@ void IPreferences::Commit() #ifdef DAEDALUS_PSP #define OUTPUT_LANGUAGE( b, nm, def ) fprintf( fh, "%s=%s\n", #nm, Translate_NameFromIndex( b.nm ) ); #endif - OUTPUT_INT( gGlobalPreferences, DisplayFramerate, defaults ); + OUTPUT_BOOL( gGlobalPreferences, DisplayFramerate, defaults ); OUTPUT_BOOL( gGlobalPreferences, ForceLinearFilter, defaults ); OUTPUT_BOOL( gGlobalPreferences, RumblePak, defaults ); #ifdef DAEDALUS_DEBUG_DISPLAYLIST @@ -403,7 +403,7 @@ void IPreferences::SetRomPreferences( const RomID & id, const SRomPreferences & SGlobalPreferences::SGlobalPreferences() -: DisplayFramerate( 0 ) +: DisplayFramerate( false ) #ifdef DAEDALUS_DEBUG_DISPLAYLIST , HighlightInexactBlendModes( false ) , CustomBlendModes( true ) diff --git a/Source/SysCTR/Input/InputManagerCTR.cpp b/Source/SysCTR/Input/InputManagerCTR.cpp index ed241d3c7..d6a6847c6 100644 --- a/Source/SysCTR/Input/InputManagerCTR.cpp +++ b/Source/SysCTR/Input/InputManagerCTR.cpp @@ -316,7 +316,7 @@ bool IInputManager::Initialise() } char ControllerConfigs[128]; - IO::Path::Combine(ControllerConfigs, baseDir, "CoontrollerConfigs"); + IO::Path::Combine(ControllerConfigs, baseDir.string().c_str(), "CoontrollerConfigs"); LoadControllerConfigs(ControllerConfigs); SetConfiguration(0); diff --git a/Source/SysPSP/HLEGraphics/GraphicsPluginPSP.cpp b/Source/SysPSP/HLEGraphics/GraphicsPluginPSP.cpp index 9a0762391..d9aa41995 100644 --- a/Source/SysPSP/HLEGraphics/GraphicsPluginPSP.cpp +++ b/Source/SysPSP/HLEGraphics/GraphicsPluginPSP.cpp @@ -214,22 +214,11 @@ void CGraphicsPluginImpl::UpdateScreen() pspDebugScreenSetBackColor(0); pspDebugScreenSetXY(0, 0); - switch(gGlobalPreferences.DisplayFramerate) - { - case 1: - pspDebugScreenPrintf( "%#.1f ", gCurrentFramerate ); - break; - case 2: - pspDebugScreenPrintf( "FPS[%#.1f] VB[%d/%d] Sync[%#.1f%%] ", gCurrentFramerate, u32( Fsync * f32( FramerateLimiter_GetTvFrequencyHz() ) ), FramerateLimiter_GetTvFrequencyHz(), Fsync * 100.0f ); - break; - case 3: #ifdef DAEDALUS_DEBUG_DISPLAYLIST - pspDebugScreenPrintf( "Dlist[%d] Cull[%d] | Tris[%d] Cull[%d] | Rect[%d] Clip[%d] ", gNumInstructionsExecuted, gNumDListsCulled, gRenderer->GetNumTrisRendered(), gRenderer->GetNumTrisClipped(), gRenderer->GetNumRect(), gNumRectsClipped); + pspDebugScreenPrintf( "Dlist[%d] Cull[%d] | Tris[%d] Cull[%d] | Rect[%d] Clip[%d] ", gNumInstructionsExecuted, gNumDListsCulled, gRenderer->GetNumTrisRendered(), gRenderer->GetNumTrisClipped(), gRenderer->GetNumRect(), gNumRectsClipped); #else - pspDebugScreenPrintf( "%#.1f ", gCurrentFramerate ); + pspDebugScreenPrintf( "FPS[%#.1f] VB[%d/%d] Sync[%#.1f%%] ", gCurrentFramerate, u32( Fsync * f32( FramerateLimiter_GetTvFrequencyHz() ) ), FramerateLimiter_GetTvFrequencyHz(), Fsync * 100.0f ); #endif - break; - } } if( gGlobalPreferences.BatteryWarning ) { diff --git a/Source/UI/GlobalSettingsComponent.cpp b/Source/UI/GlobalSettingsComponent.cpp index 523e310e8..7cdeb5199 100644 --- a/Source/UI/GlobalSettingsComponent.cpp +++ b/Source/UI/GlobalSettingsComponent.cpp @@ -276,19 +276,15 @@ namespace { } - virtual void OnNext() { if (gGlobalPreferences.DisplayFramerate < 3) gGlobalPreferences.DisplayFramerate++; } - virtual void OnPrevious() { if (gGlobalPreferences.DisplayFramerate > 0) gGlobalPreferences.DisplayFramerate--; } + virtual void OnNext() { gGlobalPreferences.DisplayFramerate = !gGlobalPreferences.DisplayFramerate; } + virtual void OnPrevious() { gGlobalPreferences.DisplayFramerate = !gGlobalPreferences.DisplayFramerate; } virtual const char * GetSettingName() const { - switch ( gGlobalPreferences.DisplayFramerate ) - { - case 0: return "None"; - case 1: return "FPS"; - case 2: return "FPS + VB + SYNC"; - case 3: return "Render stats"; - } - return "?"; + if ( gGlobalPreferences.DisplayFramerate ) + return "None"; + else + return "None"; } }; From 7d6d937055c3e13b16bb88293f0a66700f380705 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Mon, 11 Dec 2023 20:32:56 +0800 Subject: [PATCH 50/54] Fix CI windows build --- .github/workflows/compilation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index fdae7c74d..9b7e988ec 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -267,7 +267,7 @@ jobs: - name: Run CMake config run: | - cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=$ENV:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -G "Visual Studio 16 2019" -A x64 + cmake -S . -B build "-DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET=x64-windows" - name: Build run: | From a754796a60d0d3a6b4f18655e9bc1fe6e3f100cc Mon Sep 17 00:00:00 2001 From: Howard Su Date: Mon, 11 Dec 2023 20:44:33 +0800 Subject: [PATCH 51/54] Fix 3DS build --- Source/SysCTR/Graphics/GraphicsContextCTR.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Source/SysCTR/Graphics/GraphicsContextCTR.cpp b/Source/SysCTR/Graphics/GraphicsContextCTR.cpp index a179fdb8f..f868cc896 100644 --- a/Source/SysCTR/Graphics/GraphicsContextCTR.cpp +++ b/Source/SysCTR/Graphics/GraphicsContextCTR.cpp @@ -43,10 +43,6 @@ class IGraphicsContext : public CGraphicsContext bool Initialise(); bool IsInitialised() const { return mInitialised; } - void SwitchToChosenDisplay(); - void SwitchToLcdDisplay(); - void StoreSaveScreenData(); - void ClearAllSurfaces(); void ClearToBlack(); @@ -227,5 +223,3 @@ void IGraphicsContext::SetDebugScreenTarget(ETargetSurface buffer){} void IGraphicsContext::SaveScreenshot(const char* filename, s32 x, s32 y, u32 width, u32 height){} void IGraphicsContext::DumpScreenShot(){} - -void IGraphicsContext::StoreSaveScreenData(){} \ No newline at end of file From b903b064aa4b7c1aae5ed78c2325c555009eb048 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Mon, 11 Dec 2023 21:04:13 +0800 Subject: [PATCH 52/54] Move UIContext to Graphics --- Source/SysPSP/CMakeLists.txt | 2 +- Source/SysPSP/Graphics/CMakeLists.txt | 1 + Source/SysPSP/{ => Graphics}/UIContext.cpp | 0 3 files changed, 2 insertions(+), 1 deletion(-) rename Source/SysPSP/{ => Graphics}/UIContext.cpp (100%) diff --git a/Source/SysPSP/CMakeLists.txt b/Source/SysPSP/CMakeLists.txt index b41a36f54..ce7a45494 100644 --- a/Source/SysPSP/CMakeLists.txt +++ b/Source/SysPSP/CMakeLists.txt @@ -20,4 +20,4 @@ set(daed_libs ${daed_libs} PARENT_SCOPE) list(APPEND sys_libraries intrafont pspkubridge pspfpu pspdebug) set(sys_libraries ${sys_libraries} PARENT_SCOPE) -set(plat_main SysPSP/main.cpp SysPSP/UIContext.cpp PARENT_SCOPE) +set(plat_main SysPSP/main.cpp PARENT_SCOPE) diff --git a/Source/SysPSP/Graphics/CMakeLists.txt b/Source/SysPSP/Graphics/CMakeLists.txt index 9b1b505eb..66a10c129 100644 --- a/Source/SysPSP/Graphics/CMakeLists.txt +++ b/Source/SysPSP/Graphics/CMakeLists.txt @@ -3,6 +3,7 @@ add_library(Graphics_PSP OBJECT GraphicsContext.cpp NativeTexturePSP.cpp VideoMemoryManager.cpp + UIContext.cpp ) diff --git a/Source/SysPSP/UIContext.cpp b/Source/SysPSP/Graphics/UIContext.cpp similarity index 100% rename from Source/SysPSP/UIContext.cpp rename to Source/SysPSP/Graphics/UIContext.cpp From f9e0d9873b81321d959ccdbf00b728bd025eca4d Mon Sep 17 00:00:00 2001 From: Howard Su Date: Mon, 11 Dec 2023 07:16:01 -0800 Subject: [PATCH 53/54] Fix PSP build --- Source/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 9d141f256..edc81bf2f 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -168,6 +168,7 @@ endif(CTR) if(DAEDALUS_SDL) find_package(SDL2 CONFIG REQUIRED) link_libraries(SDL2::SDL2) + link_libraries(${SDL2_LIBRARIES}) if(NOT PSP) # PSP is not needed as it uses built-in native font From 0f48c67f3678bdbec02fa1b3bd655682576ebd86 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Tue, 12 Dec 2023 00:18:30 +0800 Subject: [PATCH 54/54] Fix a bug in x64 dynarec --- Source/DynaRec/x64/AssemblyWriterX64.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/DynaRec/x64/AssemblyWriterX64.cpp b/Source/DynaRec/x64/AssemblyWriterX64.cpp index 8c7203ef1..a904a098f 100644 --- a/Source/DynaRec/x64/AssemblyWriterX64.cpp +++ b/Source/DynaRec/x64/AssemblyWriterX64.cpp @@ -739,7 +739,7 @@ void CAssemblyWriterX64::MOV(EIntelReg reg1, EIntelReg reg2, bool is64) u8 first_byte = 0x48; if (reg2 >= R8_CODE) { first_byte |= 0x1; - reg1 = EIntelReg(reg1 & 7); + reg2 = EIntelReg(reg2 & 7); } if (reg1 >= R8_CODE) { first_byte |= 0x4;