mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-22 13:55:38 +00:00
fix some real errors (Model3,InputSystem), minor errors (SCSP,SDL/Main) and some performance warnings
This commit is contained in:
parent
46eff8c5eb
commit
e0053b3a46
|
@ -45,7 +45,7 @@ void CBlockFile::ReadString(std::string *str, uint32_t length)
|
||||||
str->clear();
|
str->clear();
|
||||||
//TODO: use fstream to get rid of this ugly hack
|
//TODO: use fstream to get rid of this ugly hack
|
||||||
bool keep_loading = true;
|
bool keep_loading = true;
|
||||||
for (size_t i = 0; i < length; i++)
|
for (uint32_t i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
fread(&c, sizeof(char), 1, fp);
|
fread(&c, sizeof(char), 1, fp);
|
||||||
|
|
|
@ -135,7 +135,7 @@ bool GameLoader::MissingAttrib(const GameLoader &loader, const Util::Config::Nod
|
||||||
|
|
||||||
GameLoader::File::ptr_t GameLoader::File::Create(const GameLoader &loader, const Util::Config::Node &file_node)
|
GameLoader::File::ptr_t GameLoader::File::Create(const GameLoader &loader, const Util::Config::Node &file_node)
|
||||||
{
|
{
|
||||||
if (GameLoader::MissingAttrib(loader, file_node, "name") | GameLoader::MissingAttrib(loader, file_node, "offset"))
|
if (GameLoader::MissingAttrib(loader, file_node, "name") || GameLoader::MissingAttrib(loader, file_node, "offset"))
|
||||||
return ptr_t();
|
return ptr_t();
|
||||||
ptr_t file = std::make_shared<File>();
|
ptr_t file = std::make_shared<File>();
|
||||||
file->offset = file_node["offset"].ValueAs<uint32_t>();
|
file->offset = file_node["offset"].ValueAs<uint32_t>();
|
||||||
|
@ -159,7 +159,7 @@ bool GameLoader::File::operator==(const File &rhs) const
|
||||||
|
|
||||||
GameLoader::Region::ptr_t GameLoader::Region::Create(const GameLoader &loader, const Util::Config::Node ®ion_node)
|
GameLoader::Region::ptr_t GameLoader::Region::Create(const GameLoader &loader, const Util::Config::Node ®ion_node)
|
||||||
{
|
{
|
||||||
if (GameLoader::MissingAttrib(loader, region_node, "name") | MissingAttrib(loader, region_node, "stride") | GameLoader::MissingAttrib(loader, region_node, "chunk_size"))
|
if (GameLoader::MissingAttrib(loader, region_node, "name") || MissingAttrib(loader, region_node, "stride") | GameLoader::MissingAttrib(loader, region_node, "chunk_size"))
|
||||||
return ptr_t();
|
return ptr_t();
|
||||||
ptr_t region = std::make_shared<Region>();
|
ptr_t region = std::make_shared<Region>();
|
||||||
region->region_name = region_node["name"].Value<std::string>();
|
region->region_name = region_node["name"].Value<std::string>();
|
||||||
|
|
|
@ -82,7 +82,7 @@ static char *LoadShaderSource(const char *file)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadShaderProgram(GLuint *shaderProgramPtr, GLuint *vertexShaderPtr, GLuint *fragmentShaderPtr, std::string vsFile, std::string fsFile, const char *vsString, const char *fsString)
|
bool LoadShaderProgram(GLuint *shaderProgramPtr, GLuint *vertexShaderPtr, GLuint *fragmentShaderPtr, const std::string& vsFile, const std::string& fsFile, const char *vsString, const char *fsString)
|
||||||
{
|
{
|
||||||
char infoLog[2048];
|
char infoLog[2048];
|
||||||
const char *vsSource, *fsSource; // source code
|
const char *vsSource, *fsSource; // source code
|
||||||
|
|
|
@ -815,7 +815,7 @@ string CInputSystem::IntToString(int num)
|
||||||
|
|
||||||
bool CInputSystem::EqualsIgnoreCase(string str1, const char *str2)
|
bool CInputSystem::EqualsIgnoreCase(string str1, const char *str2)
|
||||||
{
|
{
|
||||||
for (string::const_iterator ci = str1.begin(); ci < str1.end(); ci++)
|
for (string::const_iterator ci = str1.begin(); ci < str1.end(); ++ci)
|
||||||
{
|
{
|
||||||
if (*str2 == '\0' || tolower(*ci) != tolower(*str2))
|
if (*str2 == '\0' || tolower(*ci) != tolower(*str2))
|
||||||
return false;
|
return false;
|
||||||
|
@ -826,7 +826,7 @@ bool CInputSystem::EqualsIgnoreCase(string str1, const char *str2)
|
||||||
|
|
||||||
bool CInputSystem::StartsWithIgnoreCase(string str1, const char *str2)
|
bool CInputSystem::StartsWithIgnoreCase(string str1, const char *str2)
|
||||||
{
|
{
|
||||||
for (string::const_iterator ci = str1.begin(); ci < str1.end(); ci++)
|
for (string::const_iterator ci = str1.begin(); ci < str1.end(); ++ci)
|
||||||
{
|
{
|
||||||
if (*str2 == '\0')
|
if (*str2 == '\0')
|
||||||
return true;
|
return true;
|
||||||
|
@ -837,7 +837,7 @@ bool CInputSystem::StartsWithIgnoreCase(string str1, const char *str2)
|
||||||
return *str2 == '\0';
|
return *str2 == '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInputSystem::IsValidKeyName(string str)
|
bool CInputSystem::IsValidKeyName(const string& str)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < NUM_VALID_KEYS; i++)
|
for (size_t i = 0; i < NUM_VALID_KEYS; i++)
|
||||||
{
|
{
|
||||||
|
@ -847,7 +847,7 @@ bool CInputSystem::IsValidKeyName(string str)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EMousePart CInputSystem::LookupMousePart(string str)
|
EMousePart CInputSystem::LookupMousePart(const string& str)
|
||||||
{
|
{
|
||||||
for (int i = 0; s_mseParts[i].id != NULL; i++)
|
for (int i = 0; s_mseParts[i].id != NULL; i++)
|
||||||
{
|
{
|
||||||
|
@ -867,7 +867,7 @@ const char *CInputSystem::LookupName(EMousePart msePart)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
EJoyPart CInputSystem::LookupJoyPart(string str)
|
EJoyPart CInputSystem::LookupJoyPart(const string& str)
|
||||||
{
|
{
|
||||||
for (int i = 0; s_joyParts[i].id != NULL; i++)
|
for (int i = 0; s_joyParts[i].id != NULL; i++)
|
||||||
{
|
{
|
||||||
|
@ -887,7 +887,7 @@ const char *CInputSystem::LookupName(EJoyPart joyPart)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CInputSystem::ParseDevMapping(string str, const char *devType, int &devNum)
|
size_t CInputSystem::ParseDevMapping(const string& str, const char *devType, int &devNum)
|
||||||
{
|
{
|
||||||
if (!StartsWithIgnoreCase(str, devType))
|
if (!StartsWithIgnoreCase(str, devType))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -913,7 +913,7 @@ size_t CInputSystem::ParseDevMapping(string str, const char *devType, int &devNu
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CInputSource* CInputSystem::ParseMultiSource(string str, bool fullAxisOnly, bool isOr)
|
CInputSource* CInputSystem::ParseMultiSource(const string& str, bool fullAxisOnly, bool isOr)
|
||||||
{
|
{
|
||||||
// Check for empty or NONE mapping
|
// Check for empty or NONE mapping
|
||||||
size_t size = str.size();
|
size_t size = str.size();
|
||||||
|
@ -1265,7 +1265,7 @@ void CInputSystem::StoreJoySettings(Util::Config::Node *config, JoySettings *set
|
||||||
KeySettings *CInputSystem::GetKeySettings(int kbdNum, bool useDefault)
|
KeySettings *CInputSystem::GetKeySettings(int kbdNum, bool useDefault)
|
||||||
{
|
{
|
||||||
KeySettings *common = NULL;
|
KeySettings *common = NULL;
|
||||||
for (vector<KeySettings*>::iterator it = m_keySettings.begin(); it != m_keySettings.end(); it++)
|
for (vector<KeySettings*>::iterator it = m_keySettings.begin(); it != m_keySettings.end(); ++it)
|
||||||
{
|
{
|
||||||
if ((*it)->kbdNum == kbdNum)
|
if ((*it)->kbdNum == kbdNum)
|
||||||
return *it;
|
return *it;
|
||||||
|
@ -1280,7 +1280,7 @@ KeySettings *CInputSystem::GetKeySettings(int kbdNum, bool useDefault)
|
||||||
MouseSettings *CInputSystem::GetMouseSettings(int mseNum, bool useDefault)
|
MouseSettings *CInputSystem::GetMouseSettings(int mseNum, bool useDefault)
|
||||||
{
|
{
|
||||||
MouseSettings *common = NULL;
|
MouseSettings *common = NULL;
|
||||||
for (vector<MouseSettings*>::iterator it = m_mseSettings.begin(); it != m_mseSettings.end(); it++)
|
for (vector<MouseSettings*>::iterator it = m_mseSettings.begin(); it != m_mseSettings.end(); ++it)
|
||||||
{
|
{
|
||||||
if ((*it)->mseNum == mseNum)
|
if ((*it)->mseNum == mseNum)
|
||||||
return *it;
|
return *it;
|
||||||
|
@ -1295,7 +1295,7 @@ MouseSettings *CInputSystem::GetMouseSettings(int mseNum, bool useDefault)
|
||||||
JoySettings *CInputSystem::GetJoySettings(int joyNum, bool useDefault)
|
JoySettings *CInputSystem::GetJoySettings(int joyNum, bool useDefault)
|
||||||
{
|
{
|
||||||
JoySettings *common = NULL;
|
JoySettings *common = NULL;
|
||||||
for (vector<JoySettings*>::iterator it = m_joySettings.begin(); it != m_joySettings.end(); it++)
|
for (vector<JoySettings*>::iterator it = m_joySettings.begin(); it != m_joySettings.end(); ++it)
|
||||||
{
|
{
|
||||||
if ((*it)->joyNum == joyNum)
|
if ((*it)->joyNum == joyNum)
|
||||||
return *it;
|
return *it;
|
||||||
|
@ -1340,7 +1340,7 @@ int CInputSystem::GetButtonNumber(EMousePart msePart)
|
||||||
|
|
||||||
EMousePart CInputSystem::GetMouseAxis(int axisNum, int axisDir)
|
EMousePart CInputSystem::GetMouseAxis(int axisNum, int axisDir)
|
||||||
{
|
{
|
||||||
if (axisNum > 0 || axisNum >= NUM_MOUSE_AXES || axisDir < 0 || axisDir > 3)
|
if (axisNum < 0 || axisNum >= NUM_MOUSE_AXES || axisDir < 0 || axisDir > 3)
|
||||||
return MouseUnknown;
|
return MouseUnknown;
|
||||||
return (EMousePart)(MouseXAxis + 4 * axisNum + axisDir);
|
return (EMousePart)(MouseXAxis + 4 * axisNum + axisDir);
|
||||||
}
|
}
|
||||||
|
@ -1587,17 +1587,17 @@ CInputSource* CInputSystem::ParseSource(const char *mapping, bool fullAxisOnly)
|
||||||
void CInputSystem::ClearSettings()
|
void CInputSystem::ClearSettings()
|
||||||
{
|
{
|
||||||
// Delete all key settings
|
// Delete all key settings
|
||||||
for (vector<KeySettings*>::iterator it = m_keySettings.begin(); it != m_keySettings.end(); it++)
|
for (vector<KeySettings*>::iterator it = m_keySettings.begin(); it != m_keySettings.end(); ++it)
|
||||||
delete *it;
|
delete *it;
|
||||||
m_keySettings.clear();
|
m_keySettings.clear();
|
||||||
|
|
||||||
// Delete all mouse settings
|
// Delete all mouse settings
|
||||||
for (vector<MouseSettings*>::iterator it = m_mseSettings.begin(); it != m_mseSettings.end(); it++)
|
for (vector<MouseSettings*>::iterator it = m_mseSettings.begin(); it != m_mseSettings.end(); ++it)
|
||||||
delete *it;
|
delete *it;
|
||||||
m_mseSettings.clear();
|
m_mseSettings.clear();
|
||||||
|
|
||||||
// Delete all joystick settings
|
// Delete all joystick settings
|
||||||
for (vector<JoySettings*>::iterator it = m_joySettings.begin(); it != m_joySettings.end(); it++)
|
for (vector<JoySettings*>::iterator it = m_joySettings.begin(); it != m_joySettings.end(); ++it)
|
||||||
delete *it;
|
delete *it;
|
||||||
m_joySettings.clear();
|
m_joySettings.clear();
|
||||||
}
|
}
|
||||||
|
@ -1715,15 +1715,15 @@ void CInputSystem::LoadFromConfig(const Util::Config::Node &config)
|
||||||
void CInputSystem::StoreToConfig(Util::Config::Node *config)
|
void CInputSystem::StoreToConfig(Util::Config::Node *config)
|
||||||
{
|
{
|
||||||
// Write all key settings
|
// Write all key settings
|
||||||
for (vector<KeySettings*>::iterator it = m_keySettings.begin(); it != m_keySettings.end(); it++)
|
for (vector<KeySettings*>::iterator it = m_keySettings.begin(); it != m_keySettings.end(); ++it)
|
||||||
StoreKeySettings(config, *it);
|
StoreKeySettings(config, *it);
|
||||||
|
|
||||||
// Write all mouse settings
|
// Write all mouse settings
|
||||||
for (vector<MouseSettings*>::iterator it = m_mseSettings.begin(); it != m_mseSettings.end(); it++)
|
for (vector<MouseSettings*>::iterator it = m_mseSettings.begin(); it != m_mseSettings.end(); ++it)
|
||||||
StoreMouseSettings(config, *it);
|
StoreMouseSettings(config, *it);
|
||||||
|
|
||||||
// Write all joystick settings
|
// Write all joystick settings
|
||||||
for (vector<JoySettings*>::iterator it = m_joySettings.begin(); it != m_joySettings.end(); it++)
|
for (vector<JoySettings*>::iterator it = m_joySettings.begin(); it != m_joySettings.end(); ++it)
|
||||||
StoreJoySettings(config, *it);
|
StoreJoySettings(config, *it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1776,7 +1776,7 @@ bool CInputSystem::ReadMapping(char *buffer, unsigned bufSize, bool fullAxisOnly
|
||||||
{
|
{
|
||||||
// Check each source is no longer active
|
// Check each source is no longer active
|
||||||
bool active = false;
|
bool active = false;
|
||||||
for (vector<CInputSource*>::iterator it = sources.begin(); it != sources.end(); it++)
|
for (vector<CInputSource*>::iterator it = sources.begin(); it != sources.end(); ++it)
|
||||||
{
|
{
|
||||||
if ((*it)->IsActive())
|
if ((*it)->IsActive())
|
||||||
{
|
{
|
||||||
|
|
|
@ -431,12 +431,12 @@ private:
|
||||||
/*
|
/*
|
||||||
* Returns true if the given string represents a valid key name.
|
* Returns true if the given string represents a valid key name.
|
||||||
*/
|
*/
|
||||||
bool IsValidKeyName(std::string str);
|
bool IsValidKeyName(const std::string& str);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the EMousePart with the given mapping name or MouseUnknown if not found.
|
* Returns the EMousePart with the given mapping name or MouseUnknown if not found.
|
||||||
*/
|
*/
|
||||||
EMousePart LookupMousePart(std::string str);
|
EMousePart LookupMousePart(const std::string& str);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the mapping name for the given EMousePart.
|
* Returns the mapping name for the given EMousePart.
|
||||||
|
@ -446,21 +446,21 @@ private:
|
||||||
/*
|
/*
|
||||||
* Returns the EJoyPart with the given mapping name or JoyUnknown if not found.
|
* Returns the EJoyPart with the given mapping name or JoyUnknown if not found.
|
||||||
*/
|
*/
|
||||||
EJoyPart LookupJoyPart(std::string str);
|
EJoyPart LookupJoyPart(const std::string& str);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the mapping name for the given EJoyPart.
|
* Returns the mapping name for the given EJoyPart.
|
||||||
*/
|
*/
|
||||||
const char *LookupName(EJoyPart joyPart);
|
const char *LookupName(EJoyPart joyPart);
|
||||||
|
|
||||||
size_t ParseDevMapping(std::string str, const char *devType, int &devNum);
|
size_t ParseDevMapping(const std::string& str, const char *devType, int &devNum);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses the given mapping string, possibly representing more than one mapping, and returns an input source for it or NULL if the
|
* Parses the given mapping string, possibly representing more than one mapping, and returns an input source for it or NULL if the
|
||||||
* mapping is invalid.
|
* mapping is invalid.
|
||||||
* If fullAxisOnly is true, then only mappings that represent a full axis range (eg MouseXAxis) are parsed.
|
* If fullAxisOnly is true, then only mappings that represent a full axis range (eg MouseXAxis) are parsed.
|
||||||
*/
|
*/
|
||||||
CInputSource* ParseMultiSource(std::string str, bool fullAxisOnly, bool isOr);
|
CInputSource* ParseMultiSource(const std::string& str, bool fullAxisOnly, bool isOr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses the given single mapping string and returns an input source for it, or NULL if non exists.
|
* Parses the given single mapping string and returns an input source for it, or NULL if non exists.
|
||||||
|
|
|
@ -278,7 +278,7 @@ CInputs::CInputs(CInputSystem *system)
|
||||||
|
|
||||||
CInputs::~CInputs()
|
CInputs::~CInputs()
|
||||||
{
|
{
|
||||||
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); it++)
|
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it)
|
||||||
delete *it;
|
delete *it;
|
||||||
m_inputs.clear();
|
m_inputs.clear();
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,8 @@ void CInputs::PrintHeader(const char *fmt, ...)
|
||||||
va_end(vl);
|
va_end(vl);
|
||||||
|
|
||||||
puts(header);
|
puts(header);
|
||||||
for (size_t i = 0; i < strlen(header); i++)
|
const size_t hs = strlen(header);
|
||||||
|
for (size_t i = 0; i < hs; i++)
|
||||||
putchar('-');
|
putchar('-');
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
}
|
}
|
||||||
|
@ -383,7 +384,7 @@ CInput *CInputs::operator[](const unsigned index)
|
||||||
|
|
||||||
CInput *CInputs::operator[](const char *idOrLabel)
|
CInput *CInputs::operator[](const char *idOrLabel)
|
||||||
{
|
{
|
||||||
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); it++)
|
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it)
|
||||||
{
|
{
|
||||||
if (stricmp((*it)->id, idOrLabel) == 0 || stricmp((*it)->label, idOrLabel) == 0)
|
if (stricmp((*it)->id, idOrLabel) == 0 || stricmp((*it)->label, idOrLabel) == 0)
|
||||||
return *it;
|
return *it;
|
||||||
|
@ -403,7 +404,7 @@ bool CInputs::Initialize()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Initialize all the inputs
|
// Initialize all the inputs
|
||||||
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); it++)
|
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it)
|
||||||
(*it)->Initialize(m_system);
|
(*it)->Initialize(m_system);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -413,7 +414,7 @@ void CInputs::LoadFromConfig(const Util::Config::Node &config)
|
||||||
{
|
{
|
||||||
m_system->LoadFromConfig(config);
|
m_system->LoadFromConfig(config);
|
||||||
|
|
||||||
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); it++)
|
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it)
|
||||||
(*it)->LoadFromConfig(config);
|
(*it)->LoadFromConfig(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +422,7 @@ void CInputs::StoreToConfig(Util::Config::Node *config)
|
||||||
{
|
{
|
||||||
m_system->StoreToConfig(config);
|
m_system->StoreToConfig(config);
|
||||||
|
|
||||||
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); it++)
|
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it)
|
||||||
(*it)->StoreToConfig(config);
|
(*it)->StoreToConfig(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,7 +447,7 @@ bool CInputs::ConfigureInputs(const Game &game)
|
||||||
// Get all inputs to be configured
|
// Get all inputs to be configured
|
||||||
vector<CInput*> toConfigure;
|
vector<CInput*> toConfigure;
|
||||||
vector<CInput*>::iterator it;
|
vector<CInput*>::iterator it;
|
||||||
for (it = m_inputs.begin(); it != m_inputs.end(); it++)
|
for (it = m_inputs.begin(); it != m_inputs.end(); ++it)
|
||||||
{
|
{
|
||||||
if ((*it)->IsConfigurable() && ((*it)->gameFlags & gameFlags))
|
if ((*it)->IsConfigurable() && ((*it)->gameFlags & gameFlags))
|
||||||
toConfigure.push_back(*it);
|
toConfigure.push_back(*it);
|
||||||
|
@ -455,7 +456,7 @@ bool CInputs::ConfigureInputs(const Game &game)
|
||||||
// Remember current mappings for each input in case changes need to be undone later
|
// Remember current mappings for each input in case changes need to be undone later
|
||||||
vector<string> oldMappings(toConfigure.size());
|
vector<string> oldMappings(toConfigure.size());
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
for (it = toConfigure.begin(); it != toConfigure.end(); it++)
|
for (it = toConfigure.begin(); it != toConfigure.end(); ++it)
|
||||||
oldMappings[index++] = (*it)->GetMapping();
|
oldMappings[index++] = (*it)->GetMapping();
|
||||||
|
|
||||||
const char *groupLabel = NULL;
|
const char *groupLabel = NULL;
|
||||||
|
@ -495,7 +496,7 @@ Redisplay:
|
||||||
{
|
{
|
||||||
// If user pressed aborted input, then undo all changes and finish configuration
|
// If user pressed aborted input, then undo all changes and finish configuration
|
||||||
index = 0;
|
index = 0;
|
||||||
for (it = toConfigure.begin(); it != toConfigure.end(); it++)
|
for (it = toConfigure.begin(); it != toConfigure.end(); ++it)
|
||||||
{
|
{
|
||||||
(*it)->SetMapping(oldMappings[index].c_str());
|
(*it)->SetMapping(oldMappings[index].c_str());
|
||||||
index++;
|
index++;
|
||||||
|
@ -697,7 +698,7 @@ void CInputs::CalibrateJoystick(int joyNum)
|
||||||
puts("");
|
puts("");
|
||||||
if (m_system->CalibrateJoystickAxis(joyNum, axisNum))
|
if (m_system->CalibrateJoystickAxis(joyNum, axisNum))
|
||||||
{
|
{
|
||||||
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); it++)
|
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it)
|
||||||
(*it)->InputSystemChanged();
|
(*it)->InputSystemChanged();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -720,7 +721,7 @@ void CInputs::PrintInputs(const Game *game)
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *groupLabel = NULL;
|
const char *groupLabel = NULL;
|
||||||
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); it++)
|
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it)
|
||||||
{
|
{
|
||||||
if (!(*it)->IsConfigurable() || !((*it)->gameFlags & gameFlags))
|
if (!(*it)->IsConfigurable() || !((*it)->gameFlags & gameFlags))
|
||||||
continue;
|
continue;
|
||||||
|
@ -749,7 +750,7 @@ bool CInputs::Poll(const Game *game, unsigned dispX, unsigned dispY, unsigned di
|
||||||
|
|
||||||
// Poll all UI inputs and all the inputs used by the current game, or all inputs if game is NULL
|
// Poll all UI inputs and all the inputs used by the current game, or all inputs if game is NULL
|
||||||
uint32_t gameFlags = game ? game->inputs : Game::INPUT_ALL;
|
uint32_t gameFlags = game ? game->inputs : Game::INPUT_ALL;
|
||||||
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); it++)
|
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it)
|
||||||
{
|
{
|
||||||
if ((*it)->IsUIInput() || ((*it)->gameFlags & gameFlags))
|
if ((*it)->IsUIInput() || ((*it)->gameFlags & gameFlags))
|
||||||
(*it)->Poll();
|
(*it)->Poll();
|
||||||
|
@ -773,7 +774,7 @@ void CInputs::DumpState(const Game *game)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop through the inputs used by the current game, or all inputs if game is NULL, and dump their values to stdout
|
// Loop through the inputs used by the current game, or all inputs if game is NULL, and dump their values to stdout
|
||||||
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); it++)
|
for (vector<CInput*>::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it)
|
||||||
{
|
{
|
||||||
if (!(*it)->IsUIInput() && !((*it)->gameFlags & gameFlags))
|
if (!(*it)->IsUIInput() && !((*it)->gameFlags & gameFlags))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -42,7 +42,7 @@ ESourceType CMultiInputSource::GetCombinedType(vector<CInputSource*> &sources)
|
||||||
bool allSwitches = true;
|
bool allSwitches = true;
|
||||||
bool hasFullAxis = false;
|
bool hasFullAxis = false;
|
||||||
bool hasHalfAxis = false;
|
bool hasHalfAxis = false;
|
||||||
for (vector<CInputSource*>::iterator it = sources.begin(); it != sources.end(); it++)
|
for (vector<CInputSource*>::iterator it = sources.begin(); it != sources.end(); ++it)
|
||||||
{
|
{
|
||||||
if ((*it)->type == SourceInvalid)
|
if ((*it)->type == SourceInvalid)
|
||||||
return SourceInvalid; // An invalid source makes the whole lot invalid
|
return SourceInvalid; // An invalid source makes the whole lot invalid
|
||||||
|
|
|
@ -686,7 +686,7 @@ void CModel3::WriteInputs(unsigned reg, UINT8 data)
|
||||||
case 0x87: // Read light gun register
|
case 0x87: // Read light gun register
|
||||||
serialFIFO1 = 0; // clear serial FIFO 1
|
serialFIFO1 = 0; // clear serial FIFO 1
|
||||||
serialFIFO2 = 0;
|
serialFIFO2 = 0;
|
||||||
if ((m_game.inputs & Game::INPUT_GUN1||m_game.inputs & Game::INPUT_GUN2))
|
if ((m_game.inputs & Game::INPUT_GUN1)||(m_game.inputs & Game::INPUT_GUN2))
|
||||||
{
|
{
|
||||||
switch (gunReg)
|
switch (gunReg)
|
||||||
{
|
{
|
||||||
|
@ -1906,7 +1906,7 @@ void CModel3::LoadState(CBlockFile *SaveState)
|
||||||
SaveState->Read(securityRAM, 0x20000);
|
SaveState->Read(securityRAM, 0x20000);
|
||||||
SaveState->Read(&midiCtrlPort, sizeof(midiCtrlPort));
|
SaveState->Read(&midiCtrlPort, sizeof(midiCtrlPort));
|
||||||
int32_t securityFirstRead;
|
int32_t securityFirstRead;
|
||||||
SaveState->Write(&securityFirstRead, sizeof(securityFirstRead));
|
SaveState->Read(&securityFirstRead, sizeof(securityFirstRead));
|
||||||
m_securityFirstRead = securityFirstRead != 0;
|
m_securityFirstRead = securityFirstRead != 0;
|
||||||
|
|
||||||
// All devices...
|
// All devices...
|
||||||
|
|
|
@ -979,7 +979,7 @@ void CReal3D::SetStepping(int stepping, uint32_t pciIDValue)
|
||||||
|
|
||||||
bool CReal3D::Init(const uint8_t *vromPtr, IBus *BusObjectPtr, CIRQ *IRQObjectPtr, unsigned dmaIRQBit)
|
bool CReal3D::Init(const uint8_t *vromPtr, IBus *BusObjectPtr, CIRQ *IRQObjectPtr, unsigned dmaIRQBit)
|
||||||
{
|
{
|
||||||
uint32_t memSize = (m_config["GPUMultiThreaded"].ValueAs<bool>() ? MEMORY_POOL_SIZE : MEM_POOL_SIZE_RW);
|
uint32_t memSize = (m_gpuMultiThreaded ? MEMORY_POOL_SIZE : MEM_POOL_SIZE_RW);
|
||||||
float memSizeMB = (float)memSize/(float)0x100000;
|
float memSizeMB = (float)memSize/(float)0x100000;
|
||||||
|
|
||||||
// IRQ and bus objects
|
// IRQ and bus objects
|
||||||
|
|
|
@ -1309,7 +1309,7 @@ bool CNetBoard::IsRunning(void)
|
||||||
return m_attached && (ioreg[0xc0] != 0);
|
return m_attached && (ioreg[0xc0] != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNetBoard::GetGame(Game gameinfo)
|
void CNetBoard::GetGame(const Game& gameinfo)
|
||||||
{
|
{
|
||||||
Gameinfo = gameinfo;
|
Gameinfo = gameinfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public:
|
||||||
|
|
||||||
bool Init(UINT8 *netRAMPtr, UINT8 *netBufferPtr);
|
bool Init(UINT8 *netRAMPtr, UINT8 *netBufferPtr);
|
||||||
|
|
||||||
void GetGame(Game);
|
void GetGame(const Game&);
|
||||||
|
|
||||||
UINT8 ReadCommRAM8(unsigned addr);
|
UINT8 ReadCommRAM8(unsigned addr);
|
||||||
UINT16 ReadCommRAM16(unsigned addr);
|
UINT16 ReadCommRAM16(unsigned addr);
|
||||||
|
|
|
@ -520,7 +520,7 @@ bool CSimNetBoard::IsRunning(void)
|
||||||
return m_attached && m_running;
|
return m_attached && m_running;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimNetBoard::GetGame(Game gameInfo)
|
void CSimNetBoard::GetGame(const Game& gameInfo)
|
||||||
{
|
{
|
||||||
m_gameInfo = gameInfo;
|
m_gameInfo = gameInfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public:
|
||||||
bool IsAttached(void);
|
bool IsAttached(void);
|
||||||
bool IsRunning(void);
|
bool IsRunning(void);
|
||||||
|
|
||||||
void GetGame(Game gameInfo);
|
void GetGame(const Game& gameInfo);
|
||||||
|
|
||||||
uint8_t ReadCommRAM8(unsigned addr);
|
uint8_t ReadCommRAM8(unsigned addr);
|
||||||
uint16_t ReadCommRAM16(unsigned addr);
|
uint16_t ReadCommRAM16(unsigned addr);
|
||||||
|
|
|
@ -326,10 +326,11 @@ static void PrintGLInfo(bool createScreen, bool infoLog, bool printExtensions)
|
||||||
strcpy(strLocal, (char *) str);
|
strcpy(strLocal, (char *) str);
|
||||||
if (infoLog) InfoLog(" Supported Extensions : %s", (strLocal = strtok(strLocal, " \t\n")));
|
if (infoLog) InfoLog(" Supported Extensions : %s", (strLocal = strtok(strLocal, " \t\n")));
|
||||||
else printf(" Supported Extensions : %s\n", (strLocal = strtok(strLocal, " \t\n")));
|
else printf(" Supported Extensions : %s\n", (strLocal = strtok(strLocal, " \t\n")));
|
||||||
while ((strLocal = strtok(NULL, " \t\n")) != NULL)
|
char* strLocalTmp = strLocal;
|
||||||
|
while ((strLocalTmp = strtok(NULL, " \t\n")) != NULL)
|
||||||
{
|
{
|
||||||
if (infoLog) InfoLog(" %s", strLocal);
|
if (infoLog) InfoLog(" %s", strLocalTmp);
|
||||||
else printf(" %s\n", strLocal);
|
else printf(" %s\n", strLocalTmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(strLocal);
|
free(strLocal);
|
||||||
|
@ -1735,7 +1736,7 @@ static ParsedCommandLine ParseCommandLine(int argc, char **argv)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned x, y;
|
unsigned x, y;
|
||||||
if (2 == sscanf(&argv[i][4],"=%d,%d", &x, &y))
|
if (2 == sscanf(&argv[i][4],"=%u,%u", &x, &y))
|
||||||
{
|
{
|
||||||
std::string xres = Util::Format() << x;
|
std::string xres = Util::Format() << x;
|
||||||
std::string yres = Util::Format() << y;
|
std::string yres = Util::Format() << y;
|
||||||
|
|
|
@ -781,7 +781,7 @@ void CDirectInputSystem::PollKeyboardsAndMice()
|
||||||
if (m_useRawInput)
|
if (m_useRawInput)
|
||||||
{
|
{
|
||||||
// For RawInput, only thing to do is update wheelDir from wheelData for each mouse state. Everything else is updated via WM events.
|
// For RawInput, only thing to do is update wheelDir from wheelData for each mouse state. Everything else is updated via WM events.
|
||||||
for (std::vector<RawMseState>::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); it++)
|
for (std::vector<RawMseState>::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); ++it)
|
||||||
{
|
{
|
||||||
if (it->wheelDelta != 0)
|
if (it->wheelDelta != 0)
|
||||||
{
|
{
|
||||||
|
@ -875,7 +875,7 @@ void CDirectInputSystem::CloseKeyboardsAndMice()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete storage for keyboards
|
// Delete storage for keyboards
|
||||||
for (std::vector<bool*>::iterator it = m_rawKeyStates.begin(); it != m_rawKeyStates.end(); it++)
|
for (std::vector<bool*>::iterator it = m_rawKeyStates.begin(); it != m_rawKeyStates.end(); ++it)
|
||||||
delete[] *it;
|
delete[] *it;
|
||||||
m_keyDetails.clear();
|
m_keyDetails.clear();
|
||||||
m_rawKeyboards.clear();
|
m_rawKeyboards.clear();
|
||||||
|
@ -915,7 +915,7 @@ void CDirectInputSystem::ResetMice()
|
||||||
m_combRawMseState.x = p.x;
|
m_combRawMseState.x = p.x;
|
||||||
m_combRawMseState.y = p.y;
|
m_combRawMseState.y = p.y;
|
||||||
m_combRawMseState.z = 0;
|
m_combRawMseState.z = 0;
|
||||||
for (std::vector<RawMseState>::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); it++)
|
for (std::vector<RawMseState>::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); ++it)
|
||||||
{
|
{
|
||||||
it->x = p.x;
|
it->x = p.x;
|
||||||
it->y = p.y;
|
it->y = p.y;
|
||||||
|
@ -1057,7 +1057,7 @@ void CDirectInputSystem::ProcessRawInput(HRAWINPUT hInput)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_combRawMseState.buttons = 0;
|
m_combRawMseState.buttons = 0;
|
||||||
for (std::vector<RawMseState>::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); it++)
|
for (std::vector<RawMseState>::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); ++it)
|
||||||
m_combRawMseState.buttons |= it->buttons;
|
m_combRawMseState.buttons |= it->buttons;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1080,7 +1080,7 @@ void CDirectInputSystem::OpenJoysticks()
|
||||||
// Loop through those found
|
// Loop through those found
|
||||||
int joyNum = 0;
|
int joyNum = 0;
|
||||||
int xNum = 0;
|
int xNum = 0;
|
||||||
for (std::vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++)
|
for (std::vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); ++it)
|
||||||
{
|
{
|
||||||
joyNum++;
|
joyNum++;
|
||||||
|
|
||||||
|
@ -1145,7 +1145,7 @@ void CDirectInputSystem::OpenJoysticks()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gather joystick details (name, num POVs & buttons, which axes are available and whether force feedback is available)
|
// Gather joystick details (name, num POVs & buttons, which axes are available and whether force feedback is available)
|
||||||
DIPROPSTRING didps;
|
DIPROPSTRING didps{};
|
||||||
didps.diph.dwSize = sizeof(DIPROPSTRING);
|
didps.diph.dwSize = sizeof(DIPROPSTRING);
|
||||||
didps.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
didps.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||||
didps.diph.dwHow = DIPH_DEVICE;
|
didps.diph.dwHow = DIPH_DEVICE;
|
||||||
|
@ -1293,7 +1293,7 @@ void CDirectInputSystem::ActivateJoysticks()
|
||||||
{
|
{
|
||||||
// Set DirectInput cooperative level of joysticks
|
// Set DirectInput cooperative level of joysticks
|
||||||
unsigned joyNum = 0;
|
unsigned joyNum = 0;
|
||||||
for (std::vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++)
|
for (std::vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); ++it)
|
||||||
{
|
{
|
||||||
if (!it->isXInput)
|
if (!it->isXInput)
|
||||||
{
|
{
|
||||||
|
@ -1313,7 +1313,7 @@ void CDirectInputSystem::PollJoysticks()
|
||||||
{
|
{
|
||||||
// Get current joystick states from XInput and DirectInput
|
// Get current joystick states from XInput and DirectInput
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (std::vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++)
|
for (std::vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); ++it)
|
||||||
{
|
{
|
||||||
LPDIJOYSTATE2 pJoyState = &m_diJoyStates[i++];
|
LPDIJOYSTATE2 pJoyState = &m_diJoyStates[i++];
|
||||||
|
|
||||||
|
@ -1394,7 +1394,7 @@ void CDirectInputSystem::PollJoysticks()
|
||||||
void CDirectInputSystem::CloseJoysticks()
|
void CDirectInputSystem::CloseJoysticks()
|
||||||
{
|
{
|
||||||
// Release any DirectInput force feedback effects that were created
|
// Release any DirectInput force feedback effects that were created
|
||||||
for (std::vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++)
|
for (std::vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); ++it)
|
||||||
{
|
{
|
||||||
for (unsigned axisNum = 0; axisNum < NUM_JOY_AXES; axisNum++)
|
for (unsigned axisNum = 0; axisNum < NUM_JOY_AXES; axisNum++)
|
||||||
{
|
{
|
||||||
|
@ -1410,7 +1410,7 @@ void CDirectInputSystem::CloseJoysticks()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release each DirectInput joystick
|
// Release each DirectInput joystick
|
||||||
for (std::vector<LPDIRECTINPUTDEVICE8>::iterator it = m_di8Joysticks.begin(); it != m_di8Joysticks.end(); it++)
|
for (std::vector<LPDIRECTINPUTDEVICE8>::iterator it = m_di8Joysticks.begin(); it != m_di8Joysticks.end(); ++it)
|
||||||
{
|
{
|
||||||
(*it)->Unacquire();
|
(*it)->Unacquire();
|
||||||
(*it)->Release();
|
(*it)->Release();
|
||||||
|
|
|
@ -111,7 +111,7 @@ void CWinOutputs::SendOutput(EOutputs output, UINT8 prevValue, UINT8 value)
|
||||||
|
|
||||||
// Loop through all registered clients and send them new output value
|
// Loop through all registered clients and send them new output value
|
||||||
LPARAM param = (LPARAM)output + 1;
|
LPARAM param = (LPARAM)output + 1;
|
||||||
for (vector<RegisteredClient>::iterator it = m_clients.begin(), end = m_clients.end(); it != end; it++)
|
for (vector<RegisteredClient>::iterator it = m_clients.begin(), end = m_clients.end(); it != end; ++it)
|
||||||
PostMessage(it->hwnd, m_updateState, param, value);
|
PostMessage(it->hwnd, m_updateState, param, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ LRESULT CWinOutputs::OutputWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
|
||||||
LRESULT CWinOutputs::RegisterClient(HWND hwnd, LPARAM id)
|
LRESULT CWinOutputs::RegisterClient(HWND hwnd, LPARAM id)
|
||||||
{
|
{
|
||||||
// Check that given client is not already registered
|
// Check that given client is not already registered
|
||||||
for (vector<RegisteredClient>::iterator it = m_clients.begin(), end = m_clients.end(); it != end; it++)
|
for (vector<RegisteredClient>::iterator it = m_clients.begin(), end = m_clients.end(); it != end; ++it)
|
||||||
{
|
{
|
||||||
if (it->id == id)
|
if (it->id == id)
|
||||||
{
|
{
|
||||||
|
@ -224,7 +224,7 @@ LRESULT CWinOutputs::UnregisterClient(HWND hwnd, LPARAM id)
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
it++;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return error if no matches found
|
// Return error if no matches found
|
||||||
|
|
|
@ -772,7 +772,7 @@ bool SCSP_Init(const Util::Config::Node &config, int n)
|
||||||
buffertmpfr=(signed int*) malloc(44100*sizeof(signed int));
|
buffertmpfr=(signed int*) malloc(44100*sizeof(signed int));
|
||||||
if (NULL == buffertmpfr)
|
if (NULL == buffertmpfr)
|
||||||
{
|
{
|
||||||
free(buffertmpfr);
|
free(buffertmpfl);
|
||||||
return ErrorLog("Insufficient memory for internal SCSP buffers.");
|
return ErrorLog("Insufficient memory for internal SCSP buffers.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,8 +781,10 @@ bool SCSP_Init(const Util::Config::Node &config, int n)
|
||||||
return ErrorLog("Insufficient memory for internal SCSP buffers.");
|
return ErrorLog("Insufficient memory for internal SCSP buffers.");
|
||||||
buffertmprr=(signed int*)malloc(44100*sizeof(signed int));
|
buffertmprr=(signed int*)malloc(44100*sizeof(signed int));
|
||||||
if (NULL == buffertmprr)
|
if (NULL == buffertmprr)
|
||||||
|
{
|
||||||
|
free(buffertmprl);
|
||||||
return ErrorLog("Insufficient memory for internal SCSP buffers.");
|
return ErrorLog("Insufficient memory for internal SCSP buffers.");
|
||||||
|
}
|
||||||
|
|
||||||
memset(buffertmpfl, 0, 44100*sizeof(signed int));
|
memset(buffertmpfl, 0, 44100*sizeof(signed int));
|
||||||
memset(buffertmpfr, 0, 44100*sizeof(signed int));
|
memset(buffertmpfr, 0, 44100*sizeof(signed int));
|
||||||
|
|
|
@ -156,7 +156,7 @@ namespace Util
|
||||||
{
|
{
|
||||||
if (m_missing)
|
if (m_missing)
|
||||||
throw std::range_error(Util::Format() << "Node \"" << m_key << "\" does not exist");
|
throw std::range_error(Util::Format() << "Node \"" << m_key << "\" does not exist");
|
||||||
if (Empty() && !m_missing)
|
if (Empty())
|
||||||
throw std::logic_error(Util::Format() << "Node \"" << m_key << "\" has no value" );
|
throw std::logic_error(Util::Format() << "Node \"" << m_key << "\" has no value" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue