From ed178d8b1cb0f727a5147a061d3208bcd91223ec Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Sat, 28 Nov 2020 15:49:19 +0000 Subject: [PATCH 1/3] Move GetAppleWindowTitle() to Utilities.cpp as it is generic and useful to other archs. --- source/Utilities.cpp | 46 ++++++++++++++++++++++++++++++++++ source/Utilities.h | 1 + source/Windows/WinFrame.cpp | 49 +------------------------------------ 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/source/Utilities.cpp b/source/Utilities.cpp index afef9264..a932a0af 100644 --- a/source/Utilities.cpp +++ b/source/Utilities.cpp @@ -453,3 +453,49 @@ void UnplugHardDiskControllerCard(void) if (!res || dwTmp) REGSAVE(TEXT(REGVALUE_HDD_ENABLED), 0); // Config: HDD Disabled } + +void GetAppleWindowTitle() +{ + switch (g_Apple2Type) + { + default: + case A2TYPE_APPLE2: g_pAppTitle = TITLE_APPLE_2; break; + case A2TYPE_APPLE2PLUS: g_pAppTitle = TITLE_APPLE_2_PLUS; break; + case A2TYPE_APPLE2JPLUS: g_pAppTitle = TITLE_APPLE_2_JPLUS; break; + case A2TYPE_APPLE2E: g_pAppTitle = TITLE_APPLE_2E; break; + case A2TYPE_APPLE2EENHANCED: g_pAppTitle = TITLE_APPLE_2E_ENHANCED; break; + case A2TYPE_PRAVETS82: g_pAppTitle = TITLE_PRAVETS_82; break; + case A2TYPE_PRAVETS8M: g_pAppTitle = TITLE_PRAVETS_8M; break; + case A2TYPE_PRAVETS8A: g_pAppTitle = TITLE_PRAVETS_8A; break; + case A2TYPE_TK30002E: g_pAppTitle = TITLE_TK3000_2E; break; + case A2TYPE_BASE64A: g_pAppTitle = TITLE_BASE64A; break; + } + +#if _DEBUG + g_pAppTitle += " *DEBUG* "; +#endif + + if (g_nAppMode == MODE_LOGO) + return; + + g_pAppTitle += " - "; + + if (IsVideoStyle(VS_HALF_SCANLINES)) + g_pAppTitle += " 50% "; + + g_pAppTitle += VideoGetAppWindowTitle(); + + if (GetCardMgr().GetDisk2CardMgr().IsAnyFirmware13Sector()) + g_pAppTitle += " (S6-13) "; + + if (g_hCustomRomF8 != INVALID_HANDLE_VALUE) + g_pAppTitle += TEXT(" (custom rom)"); + else if (sg_PropertySheet.GetTheFreezesF8Rom() && IS_APPLE2) + g_pAppTitle += TEXT(" (The Freeze's non-autostart F8 rom)"); + + switch (g_nAppMode) + { + case MODE_PAUSED: g_pAppTitle += std::string(TEXT(" [")) + TITLE_PAUSED + TEXT("]"); break; + case MODE_STEPPING: g_pAppTitle += std::string(TEXT(" [")) + TITLE_STEPPING + TEXT("]"); break; + } +} diff --git a/source/Utilities.h b/source/Utilities.h index afeb6559..ba617c44 100644 --- a/source/Utilities.h +++ b/source/Utilities.h @@ -10,3 +10,4 @@ bool DoHardDiskInsert(const int nDrive, LPCSTR szFileName); void InsertFloppyDisks(const UINT slot, LPSTR szImageName_drive[NUM_DRIVES], bool& bBoot); void InsertHardDisks(LPSTR szImageName_harddisk[NUM_HARDDISKS], bool& bBoot); void UnplugHardDiskControllerCard(void); +void GetAppleWindowTitle(); diff --git a/source/Windows/WinFrame.cpp b/source/Windows/WinFrame.cpp index de26836d..624137c9 100644 --- a/source/Windows/WinFrame.cpp +++ b/source/Windows/WinFrame.cpp @@ -50,6 +50,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "SoundCore.h" #include "Speaker.h" #include "Frame.h" +#include "Utilities.h" #ifdef USE_SPEECH_API #include "Speech.h" #endif @@ -215,54 +216,6 @@ UINT Get3DBorderHeight(void) return IsFullScreen() ? 0 : VIEWPORTY; } -// ========================================================================== - -static void GetAppleWindowTitle() -{ - switch (g_Apple2Type) - { - default: - case A2TYPE_APPLE2: g_pAppTitle = TITLE_APPLE_2 ; break; - case A2TYPE_APPLE2PLUS: g_pAppTitle = TITLE_APPLE_2_PLUS ; break; - case A2TYPE_APPLE2JPLUS: g_pAppTitle = TITLE_APPLE_2_JPLUS ; break; - case A2TYPE_APPLE2E: g_pAppTitle = TITLE_APPLE_2E ; break; - case A2TYPE_APPLE2EENHANCED: g_pAppTitle = TITLE_APPLE_2E_ENHANCED; break; - case A2TYPE_PRAVETS82: g_pAppTitle = TITLE_PRAVETS_82 ; break; - case A2TYPE_PRAVETS8M: g_pAppTitle = TITLE_PRAVETS_8M ; break; - case A2TYPE_PRAVETS8A: g_pAppTitle = TITLE_PRAVETS_8A ; break; - case A2TYPE_TK30002E: g_pAppTitle = TITLE_TK3000_2E ; break; - case A2TYPE_BASE64A: g_pAppTitle = TITLE_BASE64A ; break; - } - -#if _DEBUG - g_pAppTitle += " *DEBUG* "; -#endif - - if (g_nAppMode == MODE_LOGO) - return; - - g_pAppTitle += " - "; - - if( IsVideoStyle(VS_HALF_SCANLINES) ) - g_pAppTitle += " 50% "; - - g_pAppTitle += VideoGetAppWindowTitle(); - - if (GetCardMgr().GetDisk2CardMgr().IsAnyFirmware13Sector()) - g_pAppTitle += " (S6-13) "; - - if (g_hCustomRomF8 != INVALID_HANDLE_VALUE) - g_pAppTitle += TEXT(" (custom rom)"); - else if (sg_PropertySheet.GetTheFreezesF8Rom() && IS_APPLE2) - g_pAppTitle += TEXT(" (The Freeze's non-autostart F8 rom)"); - - switch (g_nAppMode) - { - case MODE_PAUSED : g_pAppTitle += std::string(TEXT(" [")) + TITLE_PAUSED + TEXT("]"); break; - case MODE_STEPPING: g_pAppTitle += std::string(TEXT(" [")) + TITLE_STEPPING + TEXT("]"); break; - } -} - //=========================================================================== static void FrameShowCursor(BOOL bShow) From a7353aa7f14909f803ed729a0f7037c68694a44b Mon Sep 17 00:00:00 2001 From: Kelvin Lee Date: Sun, 29 Nov 2020 09:55:45 +1100 Subject: [PATCH 2/3] Use _stat64() to support file size >2G 1. Newer VC runtime stat(), when using 32-bit file size, returns error if file size is >2G. For file existence check, using 64-bit file size is more accurate as files bigger than 2G would be reported as non-existing otherwise. 2. is required for VS2013 or before. --- source/Windows/WinFrame.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/source/Windows/WinFrame.cpp b/source/Windows/WinFrame.cpp index de26836d..6a77627f 100644 --- a/source/Windows/WinFrame.cpp +++ b/source/Windows/WinFrame.cpp @@ -58,7 +58,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "../resource/resource.h" #include "Configuration/PropertySheet.h" #include "Debugger/Debug.h" -#if _MSC_VER <= 1500 // VS2008 only (cl.exe v15.00) +#if _MSC_VER < 1900 // VS2013 or before (cl.exe v18.x or before) #include #endif @@ -2746,10 +2746,15 @@ void FrameRegisterClass () { //=========================================================================== // TODO: FIXME: Util_TestFileExists() static bool FileExists(std::string strFilename) -{ - struct stat stFileInfo; - int intStat = stat(strFilename.c_str(),&stFileInfo); - return (intStat == 0) ? true : false; +{ +#ifdef _MSC_VER + struct _stat64 stFileInfo; + int intStat = _stat64(strFilename.c_str(), &stFileInfo); +#else + struct stat stFileInfo; + int intStat = stat(strFilename.c_str(), &stFileInfo); +#endif + return (intStat == 0); } //=========================================================================== From 4c19069d8bd0264f83138db77747032819c98a39 Mon Sep 17 00:00:00 2001 From: Kelvin Lee Date: Mon, 30 Nov 2020 01:05:25 +1100 Subject: [PATCH 3/3] Remove unnecessary conditional compile for _MSC_VER --- source/Windows/WinFrame.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/source/Windows/WinFrame.cpp b/source/Windows/WinFrame.cpp index 6a77627f..720630ff 100644 --- a/source/Windows/WinFrame.cpp +++ b/source/Windows/WinFrame.cpp @@ -2747,13 +2747,8 @@ void FrameRegisterClass () { // TODO: FIXME: Util_TestFileExists() static bool FileExists(std::string strFilename) { -#ifdef _MSC_VER struct _stat64 stFileInfo; int intStat = _stat64(strFilename.c_str(), &stFileInfo); -#else - struct stat stFileInfo; - int intStat = stat(strFilename.c_str(), &stFileInfo); -#endif return (intStat == 0); }