From dd96a80e7ed8252d334cf50d23905d65be409ae5 Mon Sep 17 00:00:00 2001 From: stephena Date: Sat, 2 Apr 2016 20:46:02 +0000 Subject: [PATCH] Updated build requirement for Windows to Visual Studio 2015. This allowa to use 'constexpr', which this patch does for a few classes. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3299 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/debugger/gui/CartDASHWidget.cxx | 5 -- src/debugger/gui/CartDASHWidget.hxx | 5 +- src/emucore/Cart.hxx | 2 +- src/emucore/CartDASH.hxx | 34 ++++++------- src/emucore/Control.cxx | 6 --- src/emucore/Control.hxx | 4 +- src/emucore/M6502.hxx | 2 +- src/emucore/Paddles.cxx | 3 -- src/emucore/Paddles.hxx | 11 ++--- src/emucore/System.hxx | 8 +-- src/gui/GlobalPropsDialog.cxx | 5 -- src/gui/GlobalPropsDialog.hxx | 5 +- src/gui/LauncherFilterDialog.cxx | 6 --- src/gui/LauncherFilterDialog.hxx | 6 ++- src/windows/FSNodeWINDOWS.cxx | 1 + src/windows/HomeFinder.hxx | 77 +++++++---------------------- src/windows/Stella.vcxproj | 10 ++-- 17 files changed, 67 insertions(+), 123 deletions(-) diff --git a/src/debugger/gui/CartDASHWidget.cxx b/src/debugger/gui/CartDASHWidget.cxx index 1febf19c5..e3d3e099e 100644 --- a/src/debugger/gui/CartDASHWidget.cxx +++ b/src/debugger/gui/CartDASHWidget.cxx @@ -363,8 +363,3 @@ uInt8 CartridgeDASHWidget::internalRamGetValue(int addr) { return myCart.myRAM[addr]; } - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const CartridgeDASHWidget::BankID CartridgeDASHWidget::bankEnum[4] = { - kBank0Changed, kBank1Changed, kBank2Changed, kBank3Changed -}; diff --git a/src/debugger/gui/CartDASHWidget.hxx b/src/debugger/gui/CartDASHWidget.hxx index 67961c1c9..d9312f18d 100644 --- a/src/debugger/gui/CartDASHWidget.hxx +++ b/src/debugger/gui/CartDASHWidget.hxx @@ -57,7 +57,10 @@ class CartridgeDASHWidget : public CartDebugWidget kBank2Changed = 'b2CH', kBank3Changed = 'b3CH' }; - static const BankID bankEnum[4]; + static constexpr BankID bankEnum[4] = { + kBank0Changed, kBank1Changed, kBank2Changed, kBank3Changed + }; + private: void saveOldState() override; diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index b9b878162..b353cc6ad 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -76,7 +76,7 @@ class Cartridge : public Device /** Query some information about this cartridge. */ - static const string& about() { return myAboutString; } + static constexpr string& about() { return myAboutString; } /** Save the internal (patched) ROM image. diff --git a/src/emucore/CartDASH.hxx b/src/emucore/CartDASH.hxx index 65158074b..07546eba9 100644 --- a/src/emucore/CartDASH.hxx +++ b/src/emucore/CartDASH.hxx @@ -237,31 +237,31 @@ private: // two as well, one 512 byte for read and one for write. The RAM locations are +0x800 apart, and the ROM // are consecutive. This allows us to determine on a read/write exactly where the data is. - static const uInt16 BANK_UNDEFINED = 0x8000; // bank is undefined and inaccessible + static constexpr uInt16 BANK_UNDEFINED = 0x8000; // bank is undefined and inaccessible uInt16 bankInUse[8]; // bank being used for ROM/RAM (eight 512 byte areas) uInt16 segmentInUse[4]; // set by bank methods, to know which hotspot was accessed - static const uInt16 BANK_SWITCH_HOTSPOT_RAM = 0x3E; // writes to this address cause bankswitching - static const uInt16 BANK_SWITCH_HOTSPOT_ROM = 0x3F; // writes to this address cause bankswitching + static constexpr uInt16 BANK_SWITCH_HOTSPOT_RAM = 0x3E; // writes to this address cause bankswitching + static constexpr uInt16 BANK_SWITCH_HOTSPOT_ROM = 0x3F; // writes to this address cause bankswitching - static const uInt8 BANK_BITS = 6; // # bits for bank - static const uInt8 BIT_BANK_MASK = (1 << BANK_BITS) - 1; // mask for those bits - static const uInt16 BITMASK_LOWERUPPER = 0x100; // flags lower or upper section of bank (1==upper) - static const uInt16 BITMASK_ROMRAM = 0x200; // flags ROM or RAM bank switching (1==RAM) + static constexpr uInt8 BANK_BITS = 6; // # bits for bank + static constexpr uInt8 BIT_BANK_MASK = (1 << BANK_BITS) - 1; // mask for those bits + static constexpr uInt16 BITMASK_LOWERUPPER = 0x100; // flags lower or upper section of bank (1==upper) + static constexpr uInt16 BITMASK_ROMRAM = 0x200; // flags ROM or RAM bank switching (1==RAM) - static const uInt16 MAXIMUM_BANK_COUNT = (1< myImage; // Pointer to a dynamically allocated ROM image of the cartridge diff --git a/src/emucore/Control.cxx b/src/emucore/Control.cxx index b04783c19..226522412 100644 --- a/src/emucore/Control.cxx +++ b/src/emucore/Control.cxx @@ -168,9 +168,3 @@ bool Controller::load(Serializer& in) } return true; } - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const Int32 Controller::maximumResistance = 0x7FFFFFFF; - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const Int32 Controller::minimumResistance = 0x00000000; diff --git a/src/emucore/Control.hxx b/src/emucore/Control.hxx index 3ea6f1781..6a30544f1 100644 --- a/src/emucore/Control.hxx +++ b/src/emucore/Control.hxx @@ -235,10 +235,10 @@ class Controller : public Serializable public: /// Constant which represents maximum resistance for analog pins - static const Int32 maximumResistance; + static constexpr Int32 maximumResistance = 0x7FFFFFFF; /// Constant which represents minimum resistance for analog pins - static const Int32 minimumResistance; + static constexpr Int32 minimumResistance = 0x00000000; protected: /// Specifies which jack the controller is plugged in diff --git a/src/emucore/M6502.hxx b/src/emucore/M6502.hxx index 8f8b14b26..6bebfb1d3 100644 --- a/src/emucore/M6502.hxx +++ b/src/emucore/M6502.hxx @@ -329,7 +329,7 @@ class M6502 : public Serializable uInt16 myDataAddressForPoke; /// Indicates the number of system cycles per processor cycle - static const uInt32 SYSTEM_CYCLES_PER_CPU = 1; + static constexpr uInt32 SYSTEM_CYCLES_PER_CPU = 1; #ifdef DEBUGGER_SUPPORT Int32 evalCondBreaks() { diff --git a/src/emucore/Paddles.cxx b/src/emucore/Paddles.cxx index 4bd211e97..13efef73d 100644 --- a/src/emucore/Paddles.cxx +++ b/src/emucore/Paddles.cxx @@ -419,6 +419,3 @@ int Paddles::TRIGRANGE = Paddles::TRIGMAX; int Paddles::DIGITAL_SENSITIVITY = -1; int Paddles::DIGITAL_DISTANCE = -1; int Paddles::MOUSE_SENSITIVITY = -1; - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const Controller::DigitalPin Paddles::ourButtonPin[2] = { Four, Three }; diff --git a/src/emucore/Paddles.hxx b/src/emucore/Paddles.hxx index c2b5dfd25..25627a429 100644 --- a/src/emucore/Paddles.hxx +++ b/src/emucore/Paddles.hxx @@ -128,18 +128,17 @@ class Paddles : public Controller // Range of values over which digital and mouse movement is scaled // to paddle resistance - static const int TRIGMIN = 1; - static const int TRIGMAX = 4096; + static constexpr int TRIGMIN = 1; + static constexpr int TRIGMAX = 4096; static int TRIGRANGE; // This one is variable for the upper range - static const int MAX_DIGITAL_SENSE = 20; - static const int MAX_MOUSE_SENSE = 20; + static constexpr int MAX_DIGITAL_SENSE = 20; + static constexpr int MAX_MOUSE_SENSE = 20; static int DIGITAL_SENSITIVITY, DIGITAL_DISTANCE; static int MOUSE_SENSITIVITY; // Lookup table for associating paddle buttons with controller pins - // Yes, this is hideously complex - static const Controller::DigitalPin ourButtonPin[2]; + static constexpr Controller::DigitalPin ourButtonPin[2] = { Four, Three }; private: // Following constructors and assignment operators not supported diff --git a/src/emucore/System.hxx b/src/emucore/System.hxx index 970e08b6e..9b6cfc414 100644 --- a/src/emucore/System.hxx +++ b/src/emucore/System.hxx @@ -57,16 +57,16 @@ class System : public Serializable virtual ~System() = default; // Mask to apply to an address before accessing memory - static const uInt16 ADDRESS_MASK = (1 << 13) - 1; + static constexpr uInt16 ADDRESS_MASK = (1 << 13) - 1; // Amount to shift an address by to determine what page it's on - static const uInt16 PAGE_SHIFT = 6; + static constexpr uInt16 PAGE_SHIFT = 6; // Mask to apply to an address to obtain its page offset - static const uInt16 PAGE_MASK = (1 << PAGE_SHIFT) - 1; + static constexpr uInt16 PAGE_MASK = (1 << PAGE_SHIFT) - 1; // Number of pages in the system - static const uInt16 NUM_PAGES = 1 << (13 - PAGE_SHIFT); + static constexpr uInt16 NUM_PAGES = 1 << (13 - PAGE_SHIFT); public: /** diff --git a/src/gui/GlobalPropsDialog.cxx b/src/gui/GlobalPropsDialog.cxx index 58aaa9faf..a76687227 100644 --- a/src/gui/GlobalPropsDialog.cxx +++ b/src/gui/GlobalPropsDialog.cxx @@ -308,8 +308,3 @@ void GlobalPropsDialog::handleCommand(CommandSender* sender, int cmd, break; } } - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const char* GlobalPropsDialog::ourJoyState[10] = { - "U", "D", "L", "R", "F", "U", "D", "L", "R", "F" -}; diff --git a/src/gui/GlobalPropsDialog.hxx b/src/gui/GlobalPropsDialog.hxx index 31c1a15a1..f9d7eeace 100644 --- a/src/gui/GlobalPropsDialog.hxx +++ b/src/gui/GlobalPropsDialog.hxx @@ -60,7 +60,10 @@ class GlobalPropsDialog : public Dialog, public CommandSender CheckboxWidget* myHoldSelect; CheckboxWidget* myHoldReset; - static const char* ourJoyState[10]; + static constexpr char* ourJoyState[10] = { + "U", "D", "L", "R", "F", "U", "D", "L", "R", "F" + }; + private: // Following constructors and assignment operators not supported diff --git a/src/gui/LauncherFilterDialog.cxx b/src/gui/LauncherFilterDialog.cxx index 60b37e7e2..acd6c2701 100644 --- a/src/gui/LauncherFilterDialog.cxx +++ b/src/gui/LauncherFilterDialog.cxx @@ -249,9 +249,3 @@ void LauncherFilterDialog::handleCommand(CommandSender* sender, int cmd, break; } } - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const char* LauncherFilterDialog::ourRomTypes[2][5] = { - { ".a26", ".bin", ".rom", ".zip", ".gz" }, - { "a26", "bin", "rom", "zip", "gz" } -}; diff --git a/src/gui/LauncherFilterDialog.hxx b/src/gui/LauncherFilterDialog.hxx index 6ffec730d..a8e52a6b7 100644 --- a/src/gui/LauncherFilterDialog.hxx +++ b/src/gui/LauncherFilterDialog.hxx @@ -74,7 +74,11 @@ class LauncherFilterDialog : public Dialog, public CommandSender }; // Holds static strings representing ROM types - static const char* ourRomTypes[2][5]; + static constexpr char* ourRomTypes[2][5] = { + { ".a26", ".bin", ".rom", ".zip", ".gz" }, + { "a26", "bin", "rom", "zip", "gz" } + }; + private: // Following constructors and assignment operators not supported diff --git a/src/windows/FSNodeWINDOWS.cxx b/src/windows/FSNodeWINDOWS.cxx index 694b323a2..61b7f9cbd 100644 --- a/src/windows/FSNodeWINDOWS.cxx +++ b/src/windows/FSNodeWINDOWS.cxx @@ -18,6 +18,7 @@ //============================================================================ #include +#pragma warning( disable : 4091 ) #include #ifdef ARRAYSIZE diff --git a/src/windows/HomeFinder.hxx b/src/windows/HomeFinder.hxx index b647904ab..897f86211 100644 --- a/src/windows/HomeFinder.hxx +++ b/src/windows/HomeFinder.hxx @@ -20,99 +20,58 @@ #ifndef __HOME_FINDER_ #define __HOME_FINDER_ +#pragma warning( disable : 4091 ) #include /* * Used to determine the location of the various Win32 user/system folders. - * - * Win98 and earlier don't have SHGetFolderPath in shell32.dll. - * Microsoft recommend that we load shfolder.dll at run time and - * access the function through that. - * - * shfolder.dll is loaded dynamically in the constructor, and unloaded in - * the destructor - * - * The class makes SHGetFolderPath available through its function operator. - * It will work on all versions of Windows >= Win95. - * - * This code was borrowed from the Lyx project. */ class HomeFinder { public: - HomeFinder() : myFolderModule(0), myFolderPathFunc(0) - { - myFolderModule = LoadLibrary("shfolder.dll"); - if(myFolderModule) - myFolderPathFunc = reinterpret_cast - (::GetProcAddress(myFolderModule, "SHGetFolderPathA")); - } + HomeFinder() = default; + ~HomeFinder() = default; - ~HomeFinder() { if(myFolderModule) FreeLibrary(myFolderModule); } - - /** Wrapper for SHGetFolderPathA, returning the 'HOME/User' folder - (or an empty string if the folder couldn't be determined. */ + // Return the 'HOME/User' folder, or an empty string if the folder couldn't be determined. const string& getHomePath() const { if(ourHomePath == "") { - if(!myFolderPathFunc) - ourHomePath = ""; - else - { - char folder_path[MAX_PATH]; - HRESULT const result = (myFolderPathFunc) - (NULL, CSIDL_PROFILE | CSIDL_FLAG_CREATE, NULL, 0, folder_path); - ourHomePath = (result == 0) ? folder_path : ""; - } + char folder_path[MAX_PATH]; + HRESULT const result = SHGetFolderPathA(NULL, CSIDL_PROFILE | CSIDL_FLAG_CREATE, + NULL, 0, folder_path); + ourHomePath = (result == S_OK) ? folder_path : EmptyString; } return ourHomePath; } - /** Wrapper for SHGetFolderPathA, returning the 'APPDATA' folder - (or an empty string if the folder couldn't be determined. */ + // Return the 'APPDATA' folder, or an empty string if the folder couldn't be determined. const string& getAppDataPath() const { if(ourAppDataPath == "") { - if(!myFolderPathFunc) - ourAppDataPath = ""; - else - { - char folder_path[MAX_PATH]; - HRESULT const result = (myFolderPathFunc) - (NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, folder_path); - ourAppDataPath = (result == 0) ? folder_path : ""; - } + char folder_path[MAX_PATH]; + HRESULT const result = SHGetFolderPathA(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, + NULL, 0, folder_path); + ourAppDataPath = (result == S_OK) ? folder_path : EmptyString; } return ourAppDataPath; } - /** Wrapper for SHGetFolderPathA, returning the 'DESKTOPDIRECTORY' folder - (or an empty string if the folder couldn't be determined. */ + // Return the 'DESKTOPDIRECTORY' folder, or an empty string if the folder couldn't be determined. const string& getDesktopPath() const { if(ourDesktopPath == "") { - if(!myFolderPathFunc) - ourDesktopPath = ""; - else - { - char folder_path[MAX_PATH]; - HRESULT const result = (myFolderPathFunc) - (NULL, CSIDL_DESKTOPDIRECTORY | CSIDL_FLAG_CREATE, NULL, 0, folder_path); - ourDesktopPath = (result == 0) ? folder_path : ""; - } + char folder_path[MAX_PATH]; + HRESULT const result = SHGetFolderPathA(NULL, CSIDL_DESKTOPDIRECTORY | CSIDL_FLAG_CREATE, + NULL, 0, folder_path); + ourDesktopPath = (result == S_OK) ? folder_path : EmptyString; } return ourDesktopPath; } private: - typedef HRESULT (__stdcall * function_pointer)(HWND, int, HANDLE, DWORD, LPCSTR); - - HMODULE myFolderModule; - function_pointer myFolderPathFunc; - static string ourHomePath, ourAppDataPath, ourDesktopPath; // Following constructors and assignment operators not supported diff --git a/src/windows/Stella.vcxproj b/src/windows/Stella.vcxproj index 0bd5ad0f8..3b49d5193 100644 --- a/src/windows/Stella.vcxproj +++ b/src/windows/Stella.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,22 +27,22 @@ Application MultiByte - v120_xp + v140_xp Application MultiByte - v120_xp + v140_xp Application MultiByte - v120_xp + v140_xp Application MultiByte - v120_xp + v140_xp