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
This commit is contained in:
stephena 2016-04-02 20:46:02 +00:00
parent 7903c52406
commit dd96a80e7e
17 changed files with 67 additions and 123 deletions

View File

@ -363,8 +363,3 @@ uInt8 CartridgeDASHWidget::internalRamGetValue(int addr)
{ {
return myCart.myRAM[addr]; return myCart.myRAM[addr];
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const CartridgeDASHWidget::BankID CartridgeDASHWidget::bankEnum[4] = {
kBank0Changed, kBank1Changed, kBank2Changed, kBank3Changed
};

View File

@ -57,7 +57,10 @@ class CartridgeDASHWidget : public CartDebugWidget
kBank2Changed = 'b2CH', kBank2Changed = 'b2CH',
kBank3Changed = 'b3CH' kBank3Changed = 'b3CH'
}; };
static const BankID bankEnum[4]; static constexpr BankID bankEnum[4] = {
kBank0Changed, kBank1Changed, kBank2Changed, kBank3Changed
};
private: private:
void saveOldState() override; void saveOldState() override;

View File

@ -76,7 +76,7 @@ class Cartridge : public Device
/** /**
Query some information about this cartridge. Query some information about this cartridge.
*/ */
static const string& about() { return myAboutString; } static constexpr string& about() { return myAboutString; }
/** /**
Save the internal (patched) ROM image. Save the internal (patched) ROM image.

View File

@ -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 // 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. // 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 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 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 constexpr 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_ROM = 0x3F; // writes to this address cause bankswitching
static const uInt8 BANK_BITS = 6; // # bits for bank static constexpr uInt8 BANK_BITS = 6; // # bits for bank
static const uInt8 BIT_BANK_MASK = (1 << BANK_BITS) - 1; // mask for those bits static constexpr 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 constexpr 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 uInt16 BITMASK_ROMRAM = 0x200; // flags ROM or RAM bank switching (1==RAM)
static const uInt16 MAXIMUM_BANK_COUNT = (1<<BANK_BITS); static constexpr uInt16 MAXIMUM_BANK_COUNT = (1<<BANK_BITS);
static const uInt16 RAM_BANK_TO_POWER = 9; // 2^n = 512 static constexpr uInt16 RAM_BANK_TO_POWER = 9; // 2^n = 512
static const uInt16 RAM_BANK_SIZE = (1 << RAM_BANK_TO_POWER); static constexpr uInt16 RAM_BANK_SIZE = (1 << RAM_BANK_TO_POWER);
static const uInt16 BITMASK_RAM_BANK = (RAM_BANK_SIZE - 1); static constexpr uInt16 BITMASK_RAM_BANK = (RAM_BANK_SIZE - 1);
static const uInt32 RAM_TOTAL_SIZE = MAXIMUM_BANK_COUNT * RAM_BANK_SIZE; static constexpr uInt32 RAM_TOTAL_SIZE = MAXIMUM_BANK_COUNT * RAM_BANK_SIZE;
static const uInt16 ROM_BANK_TO_POWER = 10; // 2^n = 1024 static constexpr uInt16 ROM_BANK_TO_POWER = 10; // 2^n = 1024
static const uInt16 ROM_BANK_SIZE = (1 << ROM_BANK_TO_POWER); static constexpr uInt16 ROM_BANK_SIZE = (1 << ROM_BANK_TO_POWER);
static const uInt16 BITMASK_ROM_BANK = (ROM_BANK_SIZE -1); static constexpr uInt16 BITMASK_ROM_BANK = (ROM_BANK_SIZE -1);
static const uInt16 ROM_BANK_COUNT = 64; static constexpr uInt16 ROM_BANK_COUNT = 64;
static const uInt16 RAM_WRITE_OFFSET = 0x800; static constexpr uInt16 RAM_WRITE_OFFSET = 0x800;
uInt32 mySize; // Size of the ROM image uInt32 mySize; // Size of the ROM image
unique_ptr<uInt8[]> myImage; // Pointer to a dynamically allocated ROM image of the cartridge unique_ptr<uInt8[]> myImage; // Pointer to a dynamically allocated ROM image of the cartridge

View File

@ -168,9 +168,3 @@ bool Controller::load(Serializer& in)
} }
return true; return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Int32 Controller::maximumResistance = 0x7FFFFFFF;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Int32 Controller::minimumResistance = 0x00000000;

View File

@ -235,10 +235,10 @@ class Controller : public Serializable
public: public:
/// Constant which represents maximum resistance for analog pins /// 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 /// Constant which represents minimum resistance for analog pins
static const Int32 minimumResistance; static constexpr Int32 minimumResistance = 0x00000000;
protected: protected:
/// Specifies which jack the controller is plugged in /// Specifies which jack the controller is plugged in

View File

@ -329,7 +329,7 @@ class M6502 : public Serializable
uInt16 myDataAddressForPoke; uInt16 myDataAddressForPoke;
/// Indicates the number of system cycles per processor cycle /// 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 #ifdef DEBUGGER_SUPPORT
Int32 evalCondBreaks() { Int32 evalCondBreaks() {

View File

@ -419,6 +419,3 @@ int Paddles::TRIGRANGE = Paddles::TRIGMAX;
int Paddles::DIGITAL_SENSITIVITY = -1; int Paddles::DIGITAL_SENSITIVITY = -1;
int Paddles::DIGITAL_DISTANCE = -1; int Paddles::DIGITAL_DISTANCE = -1;
int Paddles::MOUSE_SENSITIVITY = -1; int Paddles::MOUSE_SENSITIVITY = -1;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Controller::DigitalPin Paddles::ourButtonPin[2] = { Four, Three };

View File

@ -128,18 +128,17 @@ class Paddles : public Controller
// Range of values over which digital and mouse movement is scaled // Range of values over which digital and mouse movement is scaled
// to paddle resistance // to paddle resistance
static const int TRIGMIN = 1; static constexpr int TRIGMIN = 1;
static const int TRIGMAX = 4096; static constexpr int TRIGMAX = 4096;
static int TRIGRANGE; // This one is variable for the upper range static int TRIGRANGE; // This one is variable for the upper range
static const int MAX_DIGITAL_SENSE = 20; static constexpr int MAX_DIGITAL_SENSE = 20;
static const int MAX_MOUSE_SENSE = 20; static constexpr int MAX_MOUSE_SENSE = 20;
static int DIGITAL_SENSITIVITY, DIGITAL_DISTANCE; static int DIGITAL_SENSITIVITY, DIGITAL_DISTANCE;
static int MOUSE_SENSITIVITY; static int MOUSE_SENSITIVITY;
// Lookup table for associating paddle buttons with controller pins // Lookup table for associating paddle buttons with controller pins
// Yes, this is hideously complex static constexpr Controller::DigitalPin ourButtonPin[2] = { Four, Three };
static const Controller::DigitalPin ourButtonPin[2];
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -57,16 +57,16 @@ class System : public Serializable
virtual ~System() = default; virtual ~System() = default;
// Mask to apply to an address before accessing memory // 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 // 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 // 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 // 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: public:
/** /**

View File

@ -308,8 +308,3 @@ void GlobalPropsDialog::handleCommand(CommandSender* sender, int cmd,
break; break;
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* GlobalPropsDialog::ourJoyState[10] = {
"U", "D", "L", "R", "F", "U", "D", "L", "R", "F"
};

View File

@ -60,7 +60,10 @@ class GlobalPropsDialog : public Dialog, public CommandSender
CheckboxWidget* myHoldSelect; CheckboxWidget* myHoldSelect;
CheckboxWidget* myHoldReset; CheckboxWidget* myHoldReset;
static const char* ourJoyState[10]; static constexpr char* ourJoyState[10] = {
"U", "D", "L", "R", "F", "U", "D", "L", "R", "F"
};
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -249,9 +249,3 @@ void LauncherFilterDialog::handleCommand(CommandSender* sender, int cmd,
break; break;
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* LauncherFilterDialog::ourRomTypes[2][5] = {
{ ".a26", ".bin", ".rom", ".zip", ".gz" },
{ "a26", "bin", "rom", "zip", "gz" }
};

View File

@ -74,7 +74,11 @@ class LauncherFilterDialog : public Dialog, public CommandSender
}; };
// Holds static strings representing ROM types // 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: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -18,6 +18,7 @@
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
#pragma warning( disable : 4091 )
#include <shlobj.h> #include <shlobj.h>
#ifdef ARRAYSIZE #ifdef ARRAYSIZE

View File

@ -20,99 +20,58 @@
#ifndef __HOME_FINDER_ #ifndef __HOME_FINDER_
#define __HOME_FINDER_ #define __HOME_FINDER_
#pragma warning( disable : 4091 )
#include <shlobj.h> #include <shlobj.h>
/* /*
* Used to determine the location of the various Win32 user/system folders. * 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 class HomeFinder
{ {
public: public:
HomeFinder() : myFolderModule(0), myFolderPathFunc(0) HomeFinder() = default;
{ ~HomeFinder() = default;
myFolderModule = LoadLibrary("shfolder.dll");
if(myFolderModule)
myFolderPathFunc = reinterpret_cast<function_pointer>
(::GetProcAddress(myFolderModule, "SHGetFolderPathA"));
}
~HomeFinder() { if(myFolderModule) FreeLibrary(myFolderModule); } // Return the 'HOME/User' folder, or an empty string if the folder couldn't be determined.
/** Wrapper for SHGetFolderPathA, returning the 'HOME/User' folder
(or an empty string if the folder couldn't be determined. */
const string& getHomePath() const const string& getHomePath() const
{ {
if(ourHomePath == "") if(ourHomePath == "")
{ {
if(!myFolderPathFunc) char folder_path[MAX_PATH];
ourHomePath = ""; HRESULT const result = SHGetFolderPathA(NULL, CSIDL_PROFILE | CSIDL_FLAG_CREATE,
else NULL, 0, folder_path);
{ ourHomePath = (result == S_OK) ? folder_path : EmptyString;
char folder_path[MAX_PATH];
HRESULT const result = (myFolderPathFunc)
(NULL, CSIDL_PROFILE | CSIDL_FLAG_CREATE, NULL, 0, folder_path);
ourHomePath = (result == 0) ? folder_path : "";
}
} }
return ourHomePath; return ourHomePath;
} }
/** Wrapper for SHGetFolderPathA, returning the 'APPDATA' folder // Return the 'APPDATA' folder, or an empty string if the folder couldn't be determined.
(or an empty string if the folder couldn't be determined. */
const string& getAppDataPath() const const string& getAppDataPath() const
{ {
if(ourAppDataPath == "") if(ourAppDataPath == "")
{ {
if(!myFolderPathFunc) char folder_path[MAX_PATH];
ourAppDataPath = ""; HRESULT const result = SHGetFolderPathA(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE,
else NULL, 0, folder_path);
{ ourAppDataPath = (result == S_OK) ? folder_path : EmptyString;
char folder_path[MAX_PATH];
HRESULT const result = (myFolderPathFunc)
(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, folder_path);
ourAppDataPath = (result == 0) ? folder_path : "";
}
} }
return ourAppDataPath; return ourAppDataPath;
} }
/** Wrapper for SHGetFolderPathA, returning the 'DESKTOPDIRECTORY' folder // Return the 'DESKTOPDIRECTORY' folder, or an empty string if the folder couldn't be determined.
(or an empty string if the folder couldn't be determined. */
const string& getDesktopPath() const const string& getDesktopPath() const
{ {
if(ourDesktopPath == "") if(ourDesktopPath == "")
{ {
if(!myFolderPathFunc) char folder_path[MAX_PATH];
ourDesktopPath = ""; HRESULT const result = SHGetFolderPathA(NULL, CSIDL_DESKTOPDIRECTORY | CSIDL_FLAG_CREATE,
else NULL, 0, folder_path);
{ ourDesktopPath = (result == S_OK) ? folder_path : EmptyString;
char folder_path[MAX_PATH];
HRESULT const result = (myFolderPathFunc)
(NULL, CSIDL_DESKTOPDIRECTORY | CSIDL_FLAG_CREATE, NULL, 0, folder_path);
ourDesktopPath = (result == 0) ? folder_path : "";
}
} }
return ourDesktopPath; return ourDesktopPath;
} }
private: private:
typedef HRESULT (__stdcall * function_pointer)(HWND, int, HANDLE, DWORD, LPCSTR);
HMODULE myFolderModule;
function_pointer myFolderPathFunc;
static string ourHomePath, ourAppDataPath, ourDesktopPath; static string ourHomePath, ourAppDataPath, ourDesktopPath;
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
@ -27,22 +27,22 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120_xp</PlatformToolset> <PlatformToolset>v140_xp</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120_xp</PlatformToolset> <PlatformToolset>v140_xp</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120_xp</PlatformToolset> <PlatformToolset>v140_xp</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120_xp</PlatformToolset> <PlatformToolset>v140_xp</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">