mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2025-02-16 17:35:39 +00:00
Merge pull request #1 from toxieainc/master
Fix some errors, fix some performance warnings, and some simple (but effective) optimizations
This commit is contained in:
commit
d60feab2ca
|
@ -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);
|
||||||
|
|
|
@ -251,8 +251,8 @@ static const char* g_cpcc[64] =
|
||||||
{/* 000 001 010 011 100 101 110 111 */
|
{/* 000 001 010 011 100 101 110 111 */
|
||||||
"f", "eq", "ogt", "oge", "olt", "ole", "ogl", "or", /* 000 */
|
"f", "eq", "ogt", "oge", "olt", "ole", "ogl", "or", /* 000 */
|
||||||
"un", "ueq", "ugt", "uge", "ult", "ule", "ne", "t", /* 001 */
|
"un", "ueq", "ugt", "uge", "ult", "ule", "ne", "t", /* 001 */
|
||||||
"sf", "seq", "gt", "ge", "lt", "le", "gl" "gle", /* 010 */
|
"sf", "seq", "gt", "ge", "lt", "le", "gl", "gle", /* 010 */
|
||||||
"ngle", "ngl", "nle", "nlt", "nge", "ngt", "sne", "st", /* 011 */
|
"ngle", "ngl", "nle", "nlt", "nge", "ngt", "sne","st", /* 011 */
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", /* 100 */
|
"?", "?", "?", "?", "?", "?", "?", "?", /* 100 */
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", /* 101 */
|
"?", "?", "?", "?", "?", "?", "?", "?", /* 101 */
|
||||||
"?", "?", "?", "?", "?", "?", "?", "?", /* 110 */
|
"?", "?", "?", "?", "?", "?", "?", "?", /* 110 */
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
#ifndef stricmp
|
#ifndef stricmp
|
||||||
#ifdef _MSC_VER // MS VisualC++
|
#ifdef _MSC_VER // MS VisualC++
|
||||||
#define stricmp _stricmp
|
#define stricmp _stricmp
|
||||||
#else // Assume GC
|
#elif defined(__GNUC__)
|
||||||
#define stricmp strcasecmp
|
#define stricmp strcasecmp
|
||||||
#endif // _MSC_VER
|
#endif // _MSC_VER
|
||||||
#endif // stricmp
|
#endif // stricmp
|
||||||
|
|
|
@ -20,7 +20,7 @@ bool GameLoader::LoadZipArchive(ZipArchive *zip, const std::string &zipfilename)
|
||||||
zip->zfs.push_back(zf);
|
zip->zfs.push_back(zf);
|
||||||
|
|
||||||
// Identify all files in zip archive
|
// Identify all files in zip archive
|
||||||
int err = UNZ_OK;
|
int err;
|
||||||
for (err = unzGoToFirstFile(zf); err == UNZ_OK; err = unzGoToNextFile(zf))
|
for (err = unzGoToFirstFile(zf); err == UNZ_OK; err = unzGoToNextFile(zf))
|
||||||
{
|
{
|
||||||
unz_file_info file_info;
|
unz_file_info file_info;
|
||||||
|
@ -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")) // no || to easier detect errors
|
||||||
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")) // no || to easier detect errors
|
||||||
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>();
|
||||||
|
@ -191,7 +191,7 @@ bool GameLoader::Region::FindFileIndexByOffset(size_t *idx, uint32_t offset) con
|
||||||
static void PopulateGameInfo(Game *game, const Util::Config::Node &game_node)
|
static void PopulateGameInfo(Game *game, const Util::Config::Node &game_node)
|
||||||
{
|
{
|
||||||
game->name = game_node["name"].ValueAs<std::string>();
|
game->name = game_node["name"].ValueAs<std::string>();
|
||||||
game->parent = game_node["parent"].ValueAsDefault<std::string>(std::string());
|
game->parent = game_node["parent"].ValueAsDefault<std::string>("");
|
||||||
game->title = game_node["identity/title"].ValueAsDefault<std::string>("Unknown");
|
game->title = game_node["identity/title"].ValueAsDefault<std::string>("Unknown");
|
||||||
game->version = game_node["identity/version"].ValueAsDefault<std::string>("");
|
game->version = game_node["identity/version"].ValueAsDefault<std::string>("");
|
||||||
game->manufacturer = game_node["identity/manufacturer"].ValueAsDefault<std::string>("Unknown");
|
game->manufacturer = game_node["identity/manufacturer"].ValueAsDefault<std::string>("Unknown");
|
||||||
|
@ -210,7 +210,7 @@ static void PopulateGameInfo(Game *game, const Util::Config::Node &game_node)
|
||||||
{ "QuadRearFrontReversed", Game::QUAD_1_RRL_2_FRL },
|
{ "QuadRearFrontReversed", Game::QUAD_1_RRL_2_FRL },
|
||||||
{ "QuadMix", Game::QUAD_1_LR_2_FR_MIX}
|
{ "QuadMix", Game::QUAD_1_LR_2_FR_MIX}
|
||||||
};
|
};
|
||||||
std::string audio_type = game_node["hardware/audio"].ValueAsDefault<std::string>(std::string());
|
std::string audio_type = game_node["hardware/audio"].ValueAsDefault<std::string>("");
|
||||||
game->audio = audio_types[audio_type];
|
game->audio = audio_types[audio_type];
|
||||||
game->pci_bridge = game_node["hardware/pci_bridge"].ValueAsDefault<std::string>("");
|
game->pci_bridge = game_node["hardware/pci_bridge"].ValueAsDefault<std::string>("");
|
||||||
game->real3d_pci_id = game_node["hardware/real3d_pci_id"].ValueAsDefault<uint32_t>(0);
|
game->real3d_pci_id = game_node["hardware/real3d_pci_id"].ValueAsDefault<uint32_t>(0);
|
||||||
|
@ -849,7 +849,7 @@ std::string StripFilename(const std::string &filepath)
|
||||||
|
|
||||||
// If none found, there is directory component here
|
// If none found, there is directory component here
|
||||||
if (last_slash == std::string::npos)
|
if (last_slash == std::string::npos)
|
||||||
return "";
|
return std::string();
|
||||||
|
|
||||||
// Otherwise, strip everything after the slash
|
// Otherwise, strip everything after the slash
|
||||||
return std::string(filepath, 0, last_slash + 1);
|
return std::string(filepath, 0, last_slash + 1);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "GLSLShader.h"
|
#include "GLSLShader.h"
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
|
|
||||||
GLSLShader::GLSLShader() {
|
GLSLShader::GLSLShader() {
|
||||||
|
|
||||||
|
@ -107,6 +107,3 @@ int GLSLShader::GetAttributeLocation(const char *str)
|
||||||
{
|
{
|
||||||
return glGetAttribLocation(m_program, str);
|
return glGetAttribLocation(m_program, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
#include "Mat4.h"
|
#include "Mat4.h"
|
||||||
|
|
||||||
|
@ -32,24 +31,19 @@ struct Vertex // half vertex
|
||||||
|
|
||||||
static bool Equal(const Vertex& p1, const Vertex& p2)
|
static bool Equal(const Vertex& p1, const Vertex& p2)
|
||||||
{
|
{
|
||||||
if (p1.pos[0] == p2.pos[0] &&
|
return (p1.pos[0] == p2.pos[0] &&
|
||||||
p1.pos[1] == p2.pos[1] &&
|
p1.pos[1] == p2.pos[1] &&
|
||||||
p1.pos[2] == p2.pos[2])
|
p1.pos[2] == p2.pos[2]);
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Average(const Vertex& p1, const Vertex& p2, Vertex& p3)
|
static void Average(const Vertex& p1, const Vertex& p2, Vertex& p3)
|
||||||
{
|
{
|
||||||
p3.pos[3] = 1.0f; //always 1
|
p3.pos[3] = 1.0f; //always 1
|
||||||
p3.fixedShade = (p1.fixedShade + p2.fixedShade) / 2.0f;
|
p3.fixedShade = (p1.fixedShade + p2.fixedShade) * 0.5f;
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) { p3.pos[i] = (p1.pos[i] + p2.pos[i]) / 2.0f; }
|
for (int i = 0; i < 3; i++) { p3.pos[i] = (p1.pos[i] + p2.pos[i]) * 0.5f; }
|
||||||
for (int i = 0; i < 3; i++) { p3.normal[i] = (p1.normal[i] + p2.normal[i]) / 2.0f; }
|
for (int i = 0; i < 3; i++) { p3.normal[i] = (p1.normal[i] + p2.normal[i]) * 0.5f; }
|
||||||
for (int i = 0; i < 2; i++) { p3.texcoords[i] = (p1.texcoords[i] + p2.texcoords[i]) / 2.0f; }
|
for (int i = 0; i < 2; i++) { p3.texcoords[i] = (p1.texcoords[i] + p2.texcoords[i]) * 0.5f; }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -265,4 +259,4 @@ struct Node
|
||||||
} // New3D
|
} // New3D
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -117,7 +117,7 @@ int PolyHeader::NumVerts()
|
||||||
|
|
||||||
int PolyHeader::NumSharedVerts()
|
int PolyHeader::NumSharedVerts()
|
||||||
{
|
{
|
||||||
int sharedVerts[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
|
static const int sharedVerts[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
|
||||||
|
|
||||||
return sharedVerts[header[0] & 0xf];
|
return sharedVerts[header[0] & 0xf];
|
||||||
}
|
}
|
||||||
|
@ -135,9 +135,9 @@ bool PolyHeader::SharedVertex(int vertex)
|
||||||
|
|
||||||
void PolyHeader::FaceNormal(float n[3])
|
void PolyHeader::FaceNormal(float n[3])
|
||||||
{
|
{
|
||||||
n[0] = (float)(((INT32)header[1]) >> 8) * (1.0f / 4194304.0f);
|
n[0] = (float)(((INT32)header[1]) >> 8) * (float)(1.0 / 4194304.0);
|
||||||
n[1] = (float)(((INT32)header[2]) >> 8) * (1.0f / 4194304.0f);
|
n[1] = (float)(((INT32)header[2]) >> 8) * (float)(1.0 / 4194304.0);
|
||||||
n[2] = (float)(((INT32)header[3]) >> 8) * (1.0f / 4194304.0f);
|
n[2] = (float)(((INT32)header[3]) >> 8) * (float)(1.0 / 4194304.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
float PolyHeader::UVScale()
|
float PolyHeader::UVScale()
|
||||||
|
|
|
@ -43,7 +43,7 @@ void main()
|
||||||
position = spotEllipse.xy;
|
position = spotEllipse.xy;
|
||||||
size = spotEllipse.zw;
|
size = spotEllipse.zw;
|
||||||
ellipse = length((gl_FragCoord.xy - position) / size);
|
ellipse = length((gl_FragCoord.xy - position) / size);
|
||||||
ellipse = pow(ellipse, 2.0); // decay rate = square of distance from center
|
ellipse = ellipse * ellipse; // decay rate = square of distance from center
|
||||||
ellipse = 1.0 - ellipse; // invert
|
ellipse = 1.0 - ellipse; // invert
|
||||||
ellipse = max(0.0, ellipse); // clamp
|
ellipse = max(0.0, ellipse); // clamp
|
||||||
|
|
||||||
|
@ -149,4 +149,4 @@ void R3DScrollFog::DeallocResources()
|
||||||
m_vbo.Destroy();
|
m_vbo.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,6 +134,7 @@ GLint R3DShader::GetVertexAttribPos(const std::string& attrib)
|
||||||
if (m_vertexLocCache.count(attrib)==0) {
|
if (m_vertexLocCache.count(attrib)==0) {
|
||||||
auto pos = glGetAttribLocation(m_shaderProgram, attrib.c_str());
|
auto pos = glGetAttribLocation(m_shaderProgram, attrib.c_str());
|
||||||
m_vertexLocCache[attrib] = pos;
|
m_vertexLocCache[attrib] = pos;
|
||||||
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_vertexLocCache[attrib];
|
return m_vertexLocCache[attrib];
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include "Util/NewConfig.h"
|
#include "Util/NewConfig.h"
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
#include <map>
|
#include <unordered_map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace New3D {
|
namespace New3D {
|
||||||
|
@ -109,11 +109,11 @@ private:
|
||||||
GLint m_locDiscardAlpha;
|
GLint m_locDiscardAlpha;
|
||||||
|
|
||||||
// vertex attribute position cache
|
// vertex attribute position cache
|
||||||
std::map<std::string, GLint> m_vertexLocCache;
|
std::unordered_map<std::string, GLint> m_vertexLocCache;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // New3D
|
} // New3D
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace New3D {
|
||||||
|
|
||||||
TextureSheet::TextureSheet()
|
TextureSheet::TextureSheet()
|
||||||
{
|
{
|
||||||
m_temp.resize(1024 * 1024 * 4); // temporay buffer for textures
|
m_temp.resize(1024 * 1024 * 4); // temporary buffer for textures
|
||||||
}
|
}
|
||||||
|
|
||||||
int TextureSheet::ToIndex(int x, int y)
|
int TextureSheet::ToIndex(int x, int y)
|
||||||
|
|
|
@ -1,33 +1,9 @@
|
||||||
#include "Vec.h"
|
#include "Vec.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace New3D {
|
namespace New3D {
|
||||||
|
|
||||||
static float fastSqrt(float number) {
|
|
||||||
long i;
|
|
||||||
float x, y;
|
|
||||||
const float f = 1.5F;
|
|
||||||
|
|
||||||
x = number * 0.5F;
|
|
||||||
y = number;
|
|
||||||
i = * ( long * ) &y;
|
|
||||||
i = 0x5f375a86 - ( i >> 1 );
|
|
||||||
y = * ( float * ) &i;
|
|
||||||
y = y * ( f - ( x * y * y ) );
|
|
||||||
y = y * ( f - ( x * y * y ) );
|
|
||||||
return number * y;
|
|
||||||
}
|
|
||||||
|
|
||||||
static float fastInvSqrt(float x)
|
|
||||||
{
|
|
||||||
float xhalf = 0.5f*x;
|
|
||||||
int i = *(int*)&x; // get bits for floating value
|
|
||||||
i = 0x5f375a86- (i>>1); // gives initial guess y0
|
|
||||||
x = *(float*)&i; // convert bits back to float
|
|
||||||
x = x*(1.5f-xhalf*x*x); // Newton step, repeating increases accuracy
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
void V3::subtract(const Vec3 a, const Vec3 b, Vec3 out) {
|
void V3::subtract(const Vec3 a, const Vec3 b, Vec3 out) {
|
||||||
|
|
||||||
out[0] = a[0] - b[0];
|
out[0] = a[0] - b[0];
|
||||||
|
@ -58,7 +34,7 @@ void V3::add(Vec3 a, const Vec3 b) {
|
||||||
|
|
||||||
void V3::divide(Vec3 a, float number) {
|
void V3::divide(Vec3 a, float number) {
|
||||||
|
|
||||||
multiply(a,1/number);
|
multiply(a,1.f/number);
|
||||||
}
|
}
|
||||||
|
|
||||||
void V3::multiply(Vec3 a, float number) {
|
void V3::multiply(Vec3 a, float number) {
|
||||||
|
@ -123,13 +99,13 @@ float V3::length(const Vec3 v) {
|
||||||
void V3::normalise(Vec3 v) {
|
void V3::normalise(Vec3 v) {
|
||||||
|
|
||||||
//========
|
//========
|
||||||
float len;
|
float inv_len;
|
||||||
//========
|
//========
|
||||||
|
|
||||||
len = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
|
inv_len = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
|
||||||
len = fastInvSqrt(len);
|
inv_len = 1.f/std::sqrt(inv_len);
|
||||||
|
|
||||||
multiply(v,len);
|
multiply(v,inv_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void V3::multiplyAdd(const Vec3 a, float scale, const Vec3 b, Vec3 out) {
|
void V3::multiplyAdd(const Vec3 a, float scale, const Vec3 b, Vec3 out) {
|
||||||
|
@ -141,9 +117,9 @@ void V3::multiplyAdd(const Vec3 a, float scale, const Vec3 b, Vec3 out) {
|
||||||
|
|
||||||
void V3::reset(Vec3 v) {
|
void V3::reset(Vec3 v) {
|
||||||
|
|
||||||
v[0] = 0;
|
v[0] = 0.f;
|
||||||
v[1] = 0;
|
v[1] = 0.f;
|
||||||
v[2] = 0;
|
v[2] = 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void V3::set(Vec3 v, float value) {
|
void V3::set(Vec3 v, float value) {
|
||||||
|
@ -171,7 +147,7 @@ void V3::reflect(const Vec3 a, const Vec3 b, Vec3 out) {
|
||||||
|
|
||||||
V3::copy(a,v);
|
V3::copy(a,v);
|
||||||
|
|
||||||
temp = V3::dotProduct(a,b) * 2;
|
temp = V3::dotProduct(a,b) * 2.f;
|
||||||
|
|
||||||
V3::multiply(v,temp);
|
V3::multiply(v,temp);
|
||||||
V3::subtract(b,v,out);
|
V3::subtract(b,v,out);
|
||||||
|
@ -191,16 +167,16 @@ void V3::createNormal(const Vec3 a, const Vec3 b, const Vec3 c, Vec3 outNormal)
|
||||||
|
|
||||||
void V3::_max(Vec3 a, const Vec3 compare) {
|
void V3::_max(Vec3 a, const Vec3 compare) {
|
||||||
|
|
||||||
if(a[0] < compare[0]) a[0] = compare[0];
|
a[0] = std::max(compare[0], a[0]);
|
||||||
if(a[1] < compare[1]) a[1] = compare[1];
|
a[1] = std::max(compare[1], a[1]);
|
||||||
if(a[2] < compare[2]) a[2] = compare[2];
|
a[2] = std::max(compare[2], a[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void V3::_min(Vec3 a, const Vec3 compare) {
|
void V3::_min(Vec3 a, const Vec3 compare) {
|
||||||
|
|
||||||
if(a[0] > compare[0]) a[0] = compare[0];
|
a[0] = std::min(compare[0], a[0]);
|
||||||
if(a[1] > compare[1]) a[1] = compare[1];
|
a[1] = std::min(compare[1], a[1]);
|
||||||
if(a[2] > compare[2]) a[2] = compare[2];
|
a[2] = std::min(compare[2], a[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool V3::cmp(const Vec3 a, float b) {
|
bool V3::cmp(const Vec3 a, float b) {
|
||||||
|
@ -223,14 +199,9 @@ bool V3::cmp(const Vec3 a, const Vec3 b) {
|
||||||
|
|
||||||
void V3::clamp(Vec3 a, float _min, float _max) {
|
void V3::clamp(Vec3 a, float _min, float _max) {
|
||||||
|
|
||||||
if(a[0] < _min) a[0] = _min;
|
a[0] = std::min(std::max(_min, a[0]), _max);
|
||||||
if(a[0] > _max) a[0] = _max;
|
a[1] = std::min(std::max(_min, a[1]), _max);
|
||||||
|
a[2] = std::min(std::max(_min, a[2]), _max);
|
||||||
if(a[1] < _min) a[1] = _min;
|
|
||||||
if(a[1] > _max) a[1] = _max;
|
|
||||||
|
|
||||||
if(a[2] < _min) a[2] = _min;
|
|
||||||
if(a[2] > _max) a[2] = _max;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // New3D
|
} // New3D
|
||||||
|
|
|
@ -333,23 +333,13 @@ static inline void DrawTileLine(uint32_t *line, int pixelOffset, uint16_t tile,
|
||||||
uint32_t pattern = vram[patternOffset + patternLine];
|
uint32_t pattern = vram[patternOffset + patternLine];
|
||||||
for (int p = 7; p >= 0; p--)
|
for (int p = 7; p >= 0; p--)
|
||||||
{
|
{
|
||||||
if (!clip || (clip && pixelOffset >= 0 && pixelOffset < 496))
|
if (!clip || (/*pixelOffset >= 0 &&*/ (unsigned int)pixelOffset < 496u)) // the >= 0 check is accounted for, as the cast to uint makes them appear as very large unsigned values
|
||||||
{
|
{
|
||||||
uint16_t maskTest = 1 << (15-((pixelOffset+0)/32));
|
uint16_t maskTest = 1 << (15-((pixelOffset+0)/32));
|
||||||
bool visible = (mask & maskTest) != 0;
|
bool visible = (mask & maskTest) != 0;
|
||||||
uint32_t pixel = palette[((pattern >> (p*4)) & 0xF) | colorHi];
|
uint32_t pixel = visible ? palette[((pattern >> (p*4)) & 0xF) | colorHi] : 0;
|
||||||
if (alphaTest)
|
if (!alphaTest || (visible && (pixel >> 24) != 0)) // only draw opaque pixels
|
||||||
{
|
|
||||||
if (visible && (pixel >> 24) != 0) // only draw opaque pixels
|
|
||||||
line[pixelOffset] = pixel;
|
line[pixelOffset] = pixel;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (visible)
|
|
||||||
line[pixelOffset] = pixel;
|
|
||||||
else
|
|
||||||
line[pixelOffset] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
++pixelOffset;
|
++pixelOffset;
|
||||||
}
|
}
|
||||||
|
@ -361,23 +351,13 @@ static inline void DrawTileLine(uint32_t *line, int pixelOffset, uint16_t tile,
|
||||||
uint32_t pattern = vram[patternOffset + patternLine + i];
|
uint32_t pattern = vram[patternOffset + patternLine + i];
|
||||||
for (int p = 3; p >= 0; p--)
|
for (int p = 3; p >= 0; p--)
|
||||||
{
|
{
|
||||||
if (!clip || (clip && pixelOffset >= 0 && pixelOffset < 496))
|
if (!clip || (/*pixelOffset >= 0 &&*/ (unsigned int)pixelOffset < 496u)) // the >= 0 check is accounted for, as the cast to uint makes them appear as very large unsigned values
|
||||||
{
|
{
|
||||||
uint16_t maskTest = 1 << (15-((pixelOffset+0)/32));
|
uint16_t maskTest = 1 << (15-((pixelOffset+0)/32));
|
||||||
bool visible = (mask & maskTest) != 0;
|
bool visible = (mask & maskTest) != 0;
|
||||||
uint32_t pixel = palette[((pattern >> (p*8)) & 0xFF) | colorHi];
|
uint32_t pixel = visible ? palette[((pattern >> (p*8)) & 0xFF) | colorHi] : 0;
|
||||||
if (alphaTest)
|
if (!alphaTest || (visible && (pixel >> 24) != 0))
|
||||||
{
|
|
||||||
if (visible && (pixel >> 24) != 0)
|
|
||||||
line[pixelOffset] = pixel;
|
line[pixelOffset] = pixel;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (visible)
|
|
||||||
line[pixelOffset] = pixel;
|
|
||||||
else
|
|
||||||
line[pixelOffset] = 0; // transparent
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
++pixelOffset;
|
++pixelOffset;
|
||||||
}
|
}
|
||||||
|
@ -417,12 +397,11 @@ static void DrawLayer(uint32_t *pixels, int layerNum, const uint32_t *vram, cons
|
||||||
int extraTile = (hFine != 0) ? 1 : 0; // h-scrolling requires part of 63rd tile
|
int extraTile = (hFine != 0) ? 1 : 0; // h-scrolling requires part of 63rd tile
|
||||||
|
|
||||||
// First tile may be clipped
|
// First tile may be clipped
|
||||||
int tx = 0;
|
|
||||||
DrawTileLine<bits, alphaTest, true>(line, pixelOffset, nameTable[(hTile ^ 1) & 63], vFine, vram, palette, mask);
|
DrawTileLine<bits, alphaTest, true>(line, pixelOffset, nameTable[(hTile ^ 1) & 63], vFine, vram, palette, mask);
|
||||||
++hTile;
|
++hTile;
|
||||||
pixelOffset += 8;
|
pixelOffset += 8;
|
||||||
// Middle tiles will not be clipped
|
// Middle tiles will not be clipped
|
||||||
for (tx = 1; tx < (62 - 1 + extraTile); tx++)
|
for (int tx = 1; tx < (62 - 1 + extraTile); tx++)
|
||||||
{
|
{
|
||||||
DrawTileLine<bits, alphaTest, false>(line, pixelOffset, nameTable[(hTile ^ 1) & 63], vFine, vram, palette, mask);
|
DrawTileLine<bits, alphaTest, false>(line, pixelOffset, nameTable[(hTile ^ 1) & 63], vFine, vram, palette, mask);
|
||||||
++hTile;
|
++hTile;
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -53,8 +53,8 @@
|
||||||
* OKAY is successfully loaded, otherwise FAIL. Prints own error messages.
|
* OKAY is successfully loaded, otherwise FAIL. Prints own error messages.
|
||||||
*/
|
*/
|
||||||
extern bool LoadShaderProgram(GLuint *shaderProgramPtr, GLuint *vertexShaderPtr,
|
extern bool LoadShaderProgram(GLuint *shaderProgramPtr, GLuint *vertexShaderPtr,
|
||||||
GLuint *fragmentShaderPtr, std::string vsFile,
|
GLuint *fragmentShaderPtr, const std::string& vsFile,
|
||||||
std::string fsFile, const char *vsString,
|
const std::string& fsFile, const char *vsString,
|
||||||
const char *fsString);
|
const char *fsString);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -724,7 +724,7 @@ void CInputSystem::CheckKeySources(int kbdNum, bool fullAxisOnly, vector<CInputS
|
||||||
find(badSources.begin(), badSources.end(), source) == badSources.end())
|
find(badSources.begin(), badSources.end(), source) == badSources.end())
|
||||||
{
|
{
|
||||||
// Update mapping string and add source to list
|
// Update mapping string and add source to list
|
||||||
if (sources.size() == 0)
|
if (sources.empty())
|
||||||
mapping.assign("KEY");
|
mapping.assign("KEY");
|
||||||
else
|
else
|
||||||
mapping.append("+KEY");
|
mapping.append("+KEY");
|
||||||
|
@ -758,7 +758,7 @@ void CInputSystem::CheckMouseSources(int mseNum, bool fullAxisOnly, bool mseCent
|
||||||
{
|
{
|
||||||
// Otherwise, update mapping string and add source to list
|
// Otherwise, update mapping string and add source to list
|
||||||
const char *partName = LookupName(msePart);
|
const char *partName = LookupName(msePart);
|
||||||
if (sources.size() == 0)
|
if (sources.empty())
|
||||||
mapping.assign("MOUSE");
|
mapping.assign("MOUSE");
|
||||||
else
|
else
|
||||||
mapping.append("+MOUSE");
|
mapping.append("+MOUSE");
|
||||||
|
@ -787,7 +787,7 @@ void CInputSystem::CheckJoySources(int joyNum, bool fullAxisOnly, vector<CInputS
|
||||||
{
|
{
|
||||||
// Otherwise, update mapping string and add source to list
|
// Otherwise, update mapping string and add source to list
|
||||||
const char *partName = LookupName(joyPart);
|
const char *partName = LookupName(joyPart);
|
||||||
if (sources.size() == 0)
|
if (sources.empty())
|
||||||
mapping.assign("JOY");
|
mapping.assign("JOY");
|
||||||
else
|
else
|
||||||
mapping.append("+JOY");
|
mapping.append("+JOY");
|
||||||
|
@ -800,7 +800,7 @@ void CInputSystem::CheckJoySources(int joyNum, bool fullAxisOnly, vector<CInputS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInputSystem::ParseInt(string str, int &num)
|
bool CInputSystem::ParseInt(const string& str, int &num)
|
||||||
{
|
{
|
||||||
stringstream ss(str);
|
stringstream ss(str);
|
||||||
return !(ss >> num).fail();
|
return !(ss >> num).fail();
|
||||||
|
@ -813,9 +813,9 @@ string CInputSystem::IntToString(int num)
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInputSystem::EqualsIgnoreCase(string str1, const char *str2)
|
bool CInputSystem::EqualsIgnoreCase(const 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;
|
||||||
|
@ -824,9 +824,9 @@ bool CInputSystem::EqualsIgnoreCase(string str1, const char *str2)
|
||||||
return *str2 == '\0';
|
return *str2 == '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInputSystem::StartsWithIgnoreCase(string str1, const char *str2)
|
bool CInputSystem::StartsWithIgnoreCase(const 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();
|
||||||
|
@ -1023,7 +1023,7 @@ CInputSource *CInputSystem::ParseSingleSource(string str)
|
||||||
if (rightSource != NULL)
|
if (rightSource != NULL)
|
||||||
sources.push_back(rightSource);
|
sources.push_back(rightSource);
|
||||||
}
|
}
|
||||||
if (sources.size() > 0)
|
if (!sources.empty())
|
||||||
return new CMultiInputSource(true, sources);
|
return new CMultiInputSource(true, sources);
|
||||||
}
|
}
|
||||||
return m_emptySource;
|
return m_emptySource;
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1772,11 +1772,11 @@ bool CInputSystem::ReadMapping(char *buffer, unsigned bufSize, bool fullAxisOnly
|
||||||
CheckAllSources(readFlags, fullAxisOnly, mseCentered, sources, mapping, badSources);
|
CheckAllSources(readFlags, fullAxisOnly, mseCentered, sources, mapping, badSources);
|
||||||
|
|
||||||
// When some inputs have been activated, keep looping until they have all been released again.
|
// When some inputs have been activated, keep looping until they have all been released again.
|
||||||
if (sources.size() > 0)
|
if (!sources.empty())
|
||||||
{
|
{
|
||||||
// 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())
|
||||||
{
|
{
|
||||||
|
|
|
@ -420,23 +420,23 @@ private:
|
||||||
*/
|
*/
|
||||||
void CheckJoySources(int joyNum, bool fullAxisOnly, std::vector<CInputSource*> &sources, std::string &mapping, std::vector<CInputSource*> &badSources);
|
void CheckJoySources(int joyNum, bool fullAxisOnly, std::vector<CInputSource*> &sources, std::string &mapping, std::vector<CInputSource*> &badSources);
|
||||||
|
|
||||||
bool ParseInt(std::string str, int &num);
|
bool ParseInt(const std::string& str, int &num);
|
||||||
|
|
||||||
std::string IntToString(int num);
|
std::string IntToString(int num);
|
||||||
|
|
||||||
bool EqualsIgnoreCase(std::string str1, const char *str2);
|
bool EqualsIgnoreCase(const std::string& str1, const char *str2);
|
||||||
|
|
||||||
bool StartsWithIgnoreCase(std::string str1, const char *str2);
|
bool StartsWithIgnoreCase(const std::string& str1, const char *str2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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();
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,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 +403,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 +413,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 +421,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 +446,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 +455,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 +495,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 +697,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 +720,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 +749,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 +773,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;
|
||||||
|
|
|
@ -36,13 +36,13 @@ using namespace std;
|
||||||
ESourceType CMultiInputSource::GetCombinedType(vector<CInputSource*> &sources)
|
ESourceType CMultiInputSource::GetCombinedType(vector<CInputSource*> &sources)
|
||||||
{
|
{
|
||||||
// Check if vector is empty
|
// Check if vector is empty
|
||||||
if (sources.size() == 0)
|
if (sources.empty())
|
||||||
return SourceEmpty;
|
return SourceEmpty;
|
||||||
// Otherwise, see whether all sources are switches, or if have a full- or half-axis present
|
// Otherwise, see whether all sources are switches, or if have a full- or half-axis present
|
||||||
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
|
||||||
|
|
|
@ -29,10 +29,10 @@
|
||||||
* be decoded incorrectly.
|
* be decoded incorrectly.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#ifdef STANDALONE
|
#ifdef STANDALONE
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
#endif
|
#endif
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
#include "93C46.h"
|
#include "93C46.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include "Supermodel.h"
|
#include "Supermodel.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ int CDSBResampler::UpSampleAndMix(INT16 *outL, INT16 *outR, INT16 *inL, INT16 *i
|
||||||
int outIdx = 0;
|
int outIdx = 0;
|
||||||
int inIdx = 0;
|
int inIdx = 0;
|
||||||
INT32 leftSample, rightSample, leftSoundSample, rightSoundSample;
|
INT32 leftSample, rightSample, leftSoundSample, rightSoundSample;
|
||||||
INT32 v[2], musicVol, soundVol;
|
INT32 v[2], musicVol;
|
||||||
|
|
||||||
// Obtain program volume settings and convert to 24.8 fixed point (0-200 -> 0x00-0x200)
|
// Obtain program volume settings and convert to 24.8 fixed point (0-200 -> 0x00-0x200)
|
||||||
musicVol = m_config["MusicVolume"].ValueAs<int>();
|
musicVol = m_config["MusicVolume"].ValueAs<int>();
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -1144,7 +1144,7 @@ UINT16 CModel3::Read16(UINT32 addr)
|
||||||
|
|
||||||
#ifdef NET_BOARD
|
#ifdef NET_BOARD
|
||||||
case 0xc0: // spikeout call this
|
case 0xc0: // spikeout call this
|
||||||
// interresting : poking @4 master to same value as slave (0x100) or simply !=0 -> connected and go in game, but freeze (prints comm error) as soon as players appear after the gate
|
// interesting : poking @4 master to same value as slave (0x100) or simply !=0 -> connected and go in game, but freeze (prints comm error) as soon as players appear after the gate
|
||||||
// sort of sync ack ? who writes this 16b value ?
|
// sort of sync ack ? who writes this 16b value ?
|
||||||
{
|
{
|
||||||
UINT16 result;
|
UINT16 result;
|
||||||
|
@ -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...
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
#include "RTC72421.h"
|
#include "RTC72421.h"
|
||||||
|
|
||||||
#include <time.h>
|
#include <ctime>
|
||||||
#include "Supermodel.h"
|
#include "Supermodel.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,11 +43,16 @@
|
||||||
|
|
||||||
UINT8 CRTC72421::ReadRegister(unsigned reg)
|
UINT8 CRTC72421::ReadRegister(unsigned reg)
|
||||||
{
|
{
|
||||||
time_t currentTime;
|
static time_t oldTime{0};
|
||||||
struct tm *Time;
|
time_t currentTime;
|
||||||
|
static struct tm *Time;
|
||||||
|
|
||||||
time(¤tTime);
|
time(¤tTime);
|
||||||
Time = localtime(¤tTime);
|
if (currentTime != oldTime)
|
||||||
|
{
|
||||||
|
Time = localtime(¤tTime);
|
||||||
|
oldTime = currentTime;
|
||||||
|
}
|
||||||
|
|
||||||
switch (reg&0xF)
|
switch (reg&0xF)
|
||||||
{
|
{
|
||||||
|
|
|
@ -809,7 +809,7 @@ uint32_t CReal3D::ReadRegister(unsigned reg)
|
||||||
int index = (reg - 20) / 4;
|
int index = (reg - 20) / 4;
|
||||||
float val = Render3D->GetLosValue(index);
|
float val = Render3D->GetLosValue(index);
|
||||||
|
|
||||||
if (val) {
|
if (val != 0.f) {
|
||||||
//val = 1.0f / val; // test program indicate z values are 1 over
|
//val = 1.0f / val; // test program indicate z values are 1 over
|
||||||
return 0xffffffff; // infinity
|
return 0xffffffff; // infinity
|
||||||
}
|
}
|
||||||
|
@ -922,7 +922,6 @@ uint32_t CReal3D::GetASICIDCode(ASIC asic) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void CReal3D::SetStepping(int stepping, uint32_t pciIDValue)
|
void CReal3D::SetStepping(int stepping, uint32_t pciIDValue)
|
||||||
|
|
||||||
{
|
{
|
||||||
step = stepping;
|
step = stepping;
|
||||||
if ((step!=0x10) && (step!=0x15) && (step!=0x20) && (step!=0x21))
|
if ((step!=0x10) && (step!=0x15) && (step!=0x20) && (step!=0x21))
|
||||||
|
@ -979,7 +978,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
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include "Util/NewConfig.h"
|
#include "Util/NewConfig.h"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <map>
|
#include <unordered_map>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* QueuedUploadTextures:
|
* QueuedUploadTextures:
|
||||||
|
@ -505,7 +505,7 @@ private:
|
||||||
bool m_evenFrame = false;
|
bool m_evenFrame = false;
|
||||||
|
|
||||||
// Internal ASIC state
|
// Internal ASIC state
|
||||||
std::map<ASIC, uint32_t> m_asicID;
|
std::unordered_map<ASIC, uint32_t> m_asicID;
|
||||||
uint64_t m_internalRenderConfig[2];
|
uint64_t m_internalRenderConfig[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
|
|
||||||
virtual bool Init(UINT8* netRAMPtr, UINT8* netBufferPtr) = 0;
|
virtual bool Init(UINT8* netRAMPtr, UINT8* netBufferPtr) = 0;
|
||||||
|
|
||||||
virtual void GetGame(Game) = 0;
|
virtual void GetGame(const Game&) = 0;
|
||||||
|
|
||||||
virtual UINT8 ReadCommRAM8(unsigned addr) = 0;
|
virtual UINT8 ReadCommRAM8(unsigned addr) = 0;
|
||||||
virtual UINT16 ReadCommRAM16(unsigned addr) = 0;
|
virtual UINT16 ReadCommRAM16(unsigned addr) = 0;
|
||||||
|
|
|
@ -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);
|
||||||
|
@ -104,7 +104,7 @@ private:
|
||||||
// netsock
|
// netsock
|
||||||
UINT16 port_in = 0;
|
UINT16 port_in = 0;
|
||||||
UINT16 port_out = 0;
|
UINT16 port_out = 0;
|
||||||
std::string addr_out = "";
|
std::string addr_out;
|
||||||
|
|
||||||
std::unique_ptr<TCPSend> nets;
|
std::unique_ptr<TCPSend> nets;
|
||||||
std::unique_ptr<TCPReceive> netr;
|
std::unique_ptr<TCPReceive> netr;
|
||||||
|
|
|
@ -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);
|
||||||
|
@ -85,7 +85,7 @@ private:
|
||||||
// netsock
|
// netsock
|
||||||
uint16_t port_in = 0;
|
uint16_t port_in = 0;
|
||||||
uint16_t port_out = 0;
|
uint16_t port_out = 0;
|
||||||
std::string addr_out = "";
|
std::string addr_out;
|
||||||
std::thread m_connectThread;
|
std::thread m_connectThread;
|
||||||
std::atomic_bool m_quit = false;
|
std::atomic_bool m_quit = false;
|
||||||
std::atomic_bool m_connected = false;
|
std::atomic_bool m_connected = false;
|
||||||
|
|
|
@ -60,9 +60,7 @@ bool TCPSend::Send(const void * data, int length)
|
||||||
|
|
||||||
DPRINTF("Sending %i bytes\n", length);
|
DPRINTF("Sending %i bytes\n", length);
|
||||||
|
|
||||||
int sent = 0;
|
int sent = SDLNet_TCP_Send(m_socket, &length, sizeof(int)); // pack the length at the start of transmission.
|
||||||
|
|
||||||
sent = SDLNet_TCP_Send(m_socket, &length, sizeof(int)); // pack the length at the start of transmission.
|
|
||||||
|
|
||||||
if (!length)
|
if (!length)
|
||||||
return true; // 0 sized packet will blow our connex
|
return true; // 0 sized packet will blow our connex
|
||||||
|
|
|
@ -112,7 +112,7 @@ std::shared_ptr<CLogger> CreateLogger(const Util::Config::Node &config)
|
||||||
loggers.push_back(std::make_shared<CConsoleErrorLogger>());
|
loggers.push_back(std::make_shared<CConsoleErrorLogger>());
|
||||||
|
|
||||||
// Parse other log outputs
|
// Parse other log outputs
|
||||||
std::string logOutputs = config["LogOutput"].ValueAsDefault<std::string>("");
|
std::string logOutputs = config["LogOutput"].ValueAsDefault<std::string>(std::string());
|
||||||
std::vector<std::string> outputs = Util::Format(logOutputs).Split(',');
|
std::vector<std::string> outputs = Util::Format(logOutputs).Split(',');
|
||||||
|
|
||||||
std::set<std::string> supportedDestinations { "stdout", "stderr", "syslog" };
|
std::set<std::string> supportedDestinations { "stdout", "stderr", "syslog" };
|
||||||
|
|
|
@ -326,13 +326,14 @@ 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);
|
||||||
}
|
}
|
||||||
if (infoLog) InfoLog("");
|
if (infoLog) InfoLog("");
|
||||||
else printf("\n");
|
else printf("\n");
|
||||||
|
@ -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();
|
||||||
|
@ -1444,7 +1444,7 @@ HRESULT CDirectInputSystem::CreateJoystickEffect(LPDIRECTINPUTDEVICE8 joystick,
|
||||||
DICONSTANTFORCE dicf;
|
DICONSTANTFORCE dicf;
|
||||||
DICONDITION dic;
|
DICONDITION dic;
|
||||||
DIPERIODIC dip;
|
DIPERIODIC dip;
|
||||||
DIENVELOPE die;
|
//DIENVELOPE die;
|
||||||
GUID guid;
|
GUID guid;
|
||||||
|
|
||||||
// Set common effects parameters
|
// Set common effects parameters
|
||||||
|
@ -1865,7 +1865,7 @@ bool CDirectInputSystem::ProcessForceFeedbackCmd(int joyNum, int axisNum, ForceF
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LPDIRECTINPUTDEVICE8 joystick = m_di8Joysticks[pInfo->dInputNum];
|
LPDIRECTINPUTDEVICE8 joystick = m_di8Joysticks[pInfo->dInputNum];
|
||||||
|
|
||||||
// See if command is to stop all force feedback, if so send appropriate command
|
// See if command is to stop all force feedback, if so send appropriate command
|
||||||
if (ffCmd.id == FFStop)
|
if (ffCmd.id == FFStop)
|
||||||
return SUCCEEDED(hr = joystick->SendForceFeedbackCommand(DISFFC_STOPALL));
|
return SUCCEEDED(hr = joystick->SendForceFeedbackCommand(DISFFC_STOPALL));
|
||||||
|
@ -1878,13 +1878,13 @@ bool CDirectInputSystem::ProcessForceFeedbackCmd(int joyNum, int axisNum, ForceF
|
||||||
if (FAILED(hr = CreateJoystickEffect(joystick, axisNum, ffCmd, pEffect)))
|
if (FAILED(hr = CreateJoystickEffect(joystick, axisNum, ffCmd, pEffect)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LONG lDirection = 0;
|
LONG lDirection = 0;
|
||||||
DICONSTANTFORCE dicf;
|
DICONSTANTFORCE dicf;
|
||||||
DICONDITION dic;
|
DICONDITION dic;
|
||||||
DIPERIODIC dip;
|
DIPERIODIC dip;
|
||||||
DIENVELOPE die;
|
//DIENVELOPE die;
|
||||||
|
|
||||||
// Set common parameters
|
// Set common parameters
|
||||||
DIEFFECT eff;
|
DIEFFECT eff;
|
||||||
memset(&eff, 0, sizeof(eff));
|
memset(&eff, 0, sizeof(eff));
|
||||||
|
@ -1894,7 +1894,7 @@ bool CDirectInputSystem::ProcessForceFeedbackCmd(int joyNum, int axisNum, ForceF
|
||||||
eff.rglDirection = &lDirection;
|
eff.rglDirection = &lDirection;
|
||||||
eff.dwStartDelay = 0;
|
eff.dwStartDelay = 0;
|
||||||
eff.lpEnvelope = NULL;
|
eff.lpEnvelope = NULL;
|
||||||
|
|
||||||
// Set command specific parameters
|
// Set command specific parameters
|
||||||
LONG lFFMag;
|
LONG lFFMag;
|
||||||
DWORD dFFMag;
|
DWORD dFFMag;
|
||||||
|
|
|
@ -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));
|
||||||
|
|
|
@ -54,14 +54,14 @@
|
||||||
// stricmp() is non-standard, apparently...
|
// stricmp() is non-standard, apparently...
|
||||||
#ifdef _MSC_VER // MS VisualC++
|
#ifdef _MSC_VER // MS VisualC++
|
||||||
#define stricmp _stricmp
|
#define stricmp _stricmp
|
||||||
#else // assume GCC
|
#elif defined(__GNUC__)
|
||||||
#define stricmp strcasecmp
|
#define stricmp strcasecmp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 32-bit rotate left
|
// 32-bit rotate left
|
||||||
#ifdef _MSC_VER // MS VisualC++ - use VS intrinsic function _rotl
|
#ifdef _MSC_VER // MS VisualC++ - use VS intrinsic function _rotl
|
||||||
#define rotl(val, shift) val = _rotl(val, shift)
|
#define rotl(val, shift) val = _rotl(val, shift)
|
||||||
#else // Otherwise assume GCC which should optimise following to asm
|
#elif defined(__GNUC__) // GCC should optimise following to asm
|
||||||
#define rotl(val, shift) val = (val>>shift)|(val<<(32-shift))
|
#define rotl(val, shift) val = (val>>shift)|(val<<(32-shift))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -276,7 +276,7 @@ namespace Util
|
||||||
std::string BitRegister::ToBinaryString() const
|
std::string BitRegister::ToBinaryString() const
|
||||||
{
|
{
|
||||||
if (Empty())
|
if (Empty())
|
||||||
return std::string("");
|
return std::string();
|
||||||
std::string out(Size(), '0');
|
std::string out(Size(), '0');
|
||||||
for (size_t i = 0; i < Size(); i++)
|
for (size_t i = 0; i < Size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -287,9 +287,9 @@ namespace Util
|
||||||
|
|
||||||
std::string BitRegister::ToHexString() const
|
std::string BitRegister::ToHexString() const
|
||||||
{
|
{
|
||||||
const char digits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
|
static const char digits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
|
||||||
if (Empty())
|
if (Empty())
|
||||||
return std::string("");
|
return std::string();
|
||||||
size_t partial = Size() & 3;
|
size_t partial = Size() & 3;
|
||||||
size_t num_digits = Size() / 4 + (partial != 0 ? 1 : 0);
|
size_t num_digits = Size() / 4 + (partial != 0 ? 1 : 0);
|
||||||
std::string out(num_digits + 2, '0');
|
std::string out(num_digits + 2, '0');
|
||||||
|
|
|
@ -1,19 +1,41 @@
|
||||||
#include "Util/ByteSwap.h"
|
#include "Util/ByteSwap.h"
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <intrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Util
|
namespace Util
|
||||||
{
|
{
|
||||||
void FlipEndian16(uint8_t *buffer, size_t size)
|
void FlipEndian16(uint8_t * const buffer, const size_t size)
|
||||||
{
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
uint16_t * const buffer16 = (uint16_t*)buffer;
|
||||||
|
for (size_t i = 0; i < size/2; i++)
|
||||||
|
buffer16[i] = _byteswap_ushort(buffer16[i]);
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
uint16_t * const buffer16 = (uint16_t*)buffer;
|
||||||
|
for (size_t i = 0; i < size/2; i++)
|
||||||
|
buffer16[i] = __builtin_bswap16(buffer16[i]);
|
||||||
|
#else
|
||||||
for (size_t i = 0; i < (size & ~1); i += 2)
|
for (size_t i = 0; i < (size & ~1); i += 2)
|
||||||
{
|
{
|
||||||
uint8_t tmp = buffer[i + 0];
|
uint8_t tmp = buffer[i + 0];
|
||||||
buffer[i + 0] = buffer[i + 1];
|
buffer[i + 0] = buffer[i + 1];
|
||||||
buffer[i + 1] = tmp;
|
buffer[i + 1] = tmp;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlipEndian32(uint8_t *buffer, size_t size)
|
void FlipEndian32(uint8_t * const buffer, const size_t size)
|
||||||
{
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
uint32_t * const buffer32 = (uint32_t*)buffer;
|
||||||
|
for (size_t i = 0; i < size/4; i++)
|
||||||
|
buffer32[i] = _byteswap_ulong(buffer32[i]);
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
uint32_t * const buffer32 = (uint32_t*)buffer;
|
||||||
|
for (size_t i = 0; i < size/4; i++)
|
||||||
|
buffer32[i] = __builtin_bswap32(buffer32[i]);
|
||||||
|
#else
|
||||||
for (size_t i = 0; i < (size & ~3); i += 4)
|
for (size_t i = 0; i < (size & ~3); i += 4)
|
||||||
{
|
{
|
||||||
uint8_t tmp1 = buffer[i+0];
|
uint8_t tmp1 = buffer[i+0];
|
||||||
|
@ -23,5 +45,6 @@ namespace Util
|
||||||
buffer[i+2] = tmp2;
|
buffer[i+2] = tmp2;
|
||||||
buffer[i+3] = tmp1;
|
buffer[i+3] = tmp1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // Util
|
} // Util
|
||||||
|
|
|
@ -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