fix a real error (m68kdasm) and some harmless performance warnings and use modern headers

This commit is contained in:
toxieainc 2022-07-11 18:10:41 +02:00
parent e0053b3a46
commit 4961951a89
25 changed files with 81 additions and 119 deletions

View file

@ -251,8 +251,8 @@ static const char* g_cpcc[64] =
{/* 000 001 010 011 100 101 110 111 */
"f", "eq", "ogt", "oge", "olt", "ole", "ogl", "or", /* 000 */
"un", "ueq", "ugt", "uge", "ult", "ule", "ne", "t", /* 001 */
"sf", "seq", "gt", "ge", "lt", "le", "gl" "gle", /* 010 */
"ngle", "ngl", "nle", "nlt", "nge", "ngt", "sne", "st", /* 011 */
"sf", "seq", "gt", "ge", "lt", "le", "gl", "gle", /* 010 */
"ngle", "ngl", "nle", "nlt", "nge", "ngt", "sne","st", /* 011 */
"?", "?", "?", "?", "?", "?", "?", "?", /* 100 */
"?", "?", "?", "?", "?", "?", "?", "?", /* 101 */
"?", "?", "?", "?", "?", "?", "?", "?", /* 110 */

View file

@ -20,7 +20,7 @@ bool GameLoader::LoadZipArchive(ZipArchive *zip, const std::string &zipfilename)
zip->zfs.push_back(zf);
// Identify all files in zip archive
int err = UNZ_OK;
int err;
for (err = unzGoToFirstFile(zf); err == UNZ_OK; err = unzGoToNextFile(zf))
{
unz_file_info file_info;
@ -193,11 +193,11 @@ static void PopulateGameInfo(Game *game, const Util::Config::Node &game_node)
game->name = game_node["name"].ValueAs<std::string>();
game->parent = game_node["parent"].ValueAsDefault<std::string>(std::string());
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>(std::string());
game->manufacturer = game_node["identity/manufacturer"].ValueAsDefault<std::string>("Unknown");
game->year = game_node["identity/year"].ValueAsDefault<unsigned>(0);
game->stepping = game_node["hardware/stepping"].ValueAsDefault<std::string>("");
game->mpeg_board = game_node["hardware/mpeg_board"].ValueAsDefault<std::string>("");
game->stepping = game_node["hardware/stepping"].ValueAsDefault<std::string>(std::string());
game->mpeg_board = game_node["hardware/mpeg_board"].ValueAsDefault<std::string>(std::string());
std::map<std::string, Game::AudioTypes> audio_types
{
{ "", Game::STEREO_LR }, // default to stereo
@ -212,7 +212,7 @@ static void PopulateGameInfo(Game *game, const Util::Config::Node &game_node)
};
std::string audio_type = game_node["hardware/audio"].ValueAsDefault<std::string>(std::string());
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>(std::string());
game->real3d_pci_id = game_node["hardware/real3d_pci_id"].ValueAsDefault<uint32_t>(0);
game->real3d_status_bit_set_percent_of_frame = game_node["hardware/real3d_status_bit_set_percent_of_frame"].ValueAsDefault<float>(0);
game->encryption_key = game_node["hardware/encryption_key"].ValueAsDefault<uint32_t>(0);
@ -849,7 +849,7 @@ std::string StripFilename(const std::string &filepath)
// If none found, there is directory component here
if (last_slash == std::string::npos)
return "";
return std::string();
// Otherwise, strip everything after the slash
return std::string(filepath, 0, last_slash + 1);

View file

@ -1,5 +1,5 @@
#include "GLSLShader.h"
#include <stdio.h>
#include <cstdio>
GLSLShader::GLSLShader() {
@ -107,6 +107,3 @@ int GLSLShader::GetAttributeLocation(const char *str)
{
return glGetAttribLocation(m_program, str);
}

View file

@ -3,9 +3,8 @@
#include <vector>
#include <unordered_map>
#include <map>
#include <memory>
#include <string.h>
#include <cstring>
#include "Texture.h"
#include "Mat4.h"
@ -32,24 +31,19 @@ struct Vertex // half vertex
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[2] == p2.pos[2])
{
return true;
}
return false;
p1.pos[2] == p2.pos[2]);
}
static void Average(const Vertex& p1, const Vertex& p2, Vertex& p3)
{
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.normal[i] = (p1.normal[i] + p2.normal[i]) / 2.0f; }
for (int i = 0; i < 2; i++) { p3.texcoords[i] = (p1.texcoords[i] + p2.texcoords[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]) * 0.5f; }
for (int i = 0; i < 2; i++) { p3.texcoords[i] = (p1.texcoords[i] + p2.texcoords[i]) * 0.5f; }
}
};

View file

@ -117,7 +117,7 @@ int PolyHeader::NumVerts()
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];
}
@ -135,9 +135,9 @@ bool PolyHeader::SharedVertex(int vertex)
void PolyHeader::FaceNormal(float n[3])
{
n[0] = (float)(((INT32)header[1]) >> 8) * (1.0f / 4194304.0f);
n[1] = (float)(((INT32)header[2]) >> 8) * (1.0f / 4194304.0f);
n[2] = (float)(((INT32)header[3]) >> 8) * (1.0f / 4194304.0f);
n[0] = (float)(((INT32)header[1]) >> 8) * (float)(1.0 / 4194304.0);
n[1] = (float)(((INT32)header[2]) >> 8) * (float)(1.0 / 4194304.0);
n[2] = (float)(((INT32)header[3]) >> 8) * (float)(1.0 / 4194304.0);
}
float PolyHeader::UVScale()

View file

@ -43,7 +43,7 @@ void main()
position = spotEllipse.xy;
size = spotEllipse.zw;
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 = max(0.0, ellipse); // clamp

View file

@ -134,6 +134,7 @@ GLint R3DShader::GetVertexAttribPos(const std::string& attrib)
if (m_vertexLocCache.count(attrib)==0) {
auto pos = glGetAttribLocation(m_shaderProgram, attrib.c_str());
m_vertexLocCache[attrib] = pos;
return pos;
}
return m_vertexLocCache[attrib];

View file

@ -4,7 +4,7 @@
#include <GL/glew.h>
#include "Util/NewConfig.h"
#include "Model.h"
#include <map>
#include <unordered_map>
#include <string>
namespace New3D {
@ -109,7 +109,7 @@ private:
GLint m_locDiscardAlpha;
// vertex attribute position cache
std::map<std::string, GLint> m_vertexLocCache;
std::unordered_map<std::string, GLint> m_vertexLocCache;
};

View file

@ -4,7 +4,7 @@ namespace New3D {
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)

View file

@ -1,33 +1,9 @@
#include "Vec.h"
#include <cmath>
#include <algorithm>
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) {
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) {
multiply(a,1/number);
multiply(a,1.f/number);
}
void V3::multiply(Vec3 a, float number) {
@ -123,13 +99,13 @@ float V3::length(const 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];
len = fastInvSqrt(len);
inv_len = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
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) {
@ -141,9 +117,9 @@ void V3::multiplyAdd(const Vec3 a, float scale, const Vec3 b, Vec3 out) {
void V3::reset(Vec3 v) {
v[0] = 0;
v[1] = 0;
v[2] = 0;
v[0] = 0.f;
v[1] = 0.f;
v[2] = 0.f;
}
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);
temp = V3::dotProduct(a,b) * 2;
temp = V3::dotProduct(a,b) * 2.f;
V3::multiply(v,temp);
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) {
if(a[0] < compare[0]) a[0] = compare[0];
if(a[1] < compare[1]) a[1] = compare[1];
if(a[2] < compare[2]) a[2] = compare[2];
a[0] = std::max(compare[0], a[0]);
a[1] = std::max(compare[1], a[1]);
a[2] = std::max(compare[2], a[2]);
}
void V3::_min(Vec3 a, const Vec3 compare) {
if(a[0] > compare[0]) a[0] = compare[0];
if(a[1] > compare[1]) a[1] = compare[1];
if(a[2] > compare[2]) a[2] = compare[2];
a[0] = std::min(compare[0], a[0]);
a[1] = std::min(compare[1], a[1]);
a[2] = std::min(compare[2], a[2]);
}
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) {
if(a[0] < _min) a[0] = _min;
if(a[0] > _max) a[0] = _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;
a[0] = std::min(std::max(_min, a[0]), _max);
a[1] = std::min(std::max(_min, a[1]), _max);
a[2] = std::min(std::max(_min, a[2]), _max);
}
} // New3D

View file

@ -724,7 +724,7 @@ void CInputSystem::CheckKeySources(int kbdNum, bool fullAxisOnly, vector<CInputS
find(badSources.begin(), badSources.end(), source) == badSources.end())
{
// Update mapping string and add source to list
if (sources.size() == 0)
if (sources.empty())
mapping.assign("KEY");
else
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
const char *partName = LookupName(msePart);
if (sources.size() == 0)
if (sources.empty())
mapping.assign("MOUSE");
else
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
const char *partName = LookupName(joyPart);
if (sources.size() == 0)
if (sources.empty())
mapping.assign("JOY");
else
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);
return !(ss >> num).fail();
@ -813,7 +813,7 @@ string CInputSystem::IntToString(int num)
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)
{
@ -824,7 +824,7 @@ bool CInputSystem::EqualsIgnoreCase(string str1, const char *str2)
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)
{
@ -1023,7 +1023,7 @@ CInputSource *CInputSystem::ParseSingleSource(string str)
if (rightSource != NULL)
sources.push_back(rightSource);
}
if (sources.size() > 0)
if (!sources.empty())
return new CMultiInputSource(true, sources);
}
return m_emptySource;
@ -1772,7 +1772,7 @@ bool CInputSystem::ReadMapping(char *buffer, unsigned bufSize, bool fullAxisOnly
CheckAllSources(readFlags, fullAxisOnly, mseCentered, sources, mapping, badSources);
// 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
bool active = false;

View file

@ -420,13 +420,13 @@ private:
*/
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);
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.

View file

@ -36,7 +36,7 @@ using namespace std;
ESourceType CMultiInputSource::GetCombinedType(vector<CInputSource*> &sources)
{
// Check if vector is empty
if (sources.size() == 0)
if (sources.empty())
return SourceEmpty;
// Otherwise, see whether all sources are switches, or if have a full- or half-axis present
bool allSwitches = true;

View file

@ -29,10 +29,10 @@
* be decoded incorrectly.
*/
#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <cstring>
#ifdef STANDALONE
#include <stdlib.h>
#include <cstdlib>
#endif
#include "Types.h"

View file

@ -33,7 +33,7 @@
#include "93C46.h"
#include <string.h>
#include <cstring>
#include "Supermodel.h"

View file

@ -143,7 +143,7 @@ int CDSBResampler::UpSampleAndMix(INT16 *outL, INT16 *outR, INT16 *inL, INT16 *i
int outIdx = 0;
int inIdx = 0;
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)
musicVol = m_config["MusicVolume"].ValueAs<int>();

View file

@ -1144,7 +1144,7 @@ UINT16 CModel3::Read16(UINT32 addr)
#ifdef NET_BOARD
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 ?
{
UINT16 result;

View file

@ -809,7 +809,7 @@ uint32_t CReal3D::ReadRegister(unsigned reg)
int index = (reg - 20) / 4;
float val = Render3D->GetLosValue(index);
if (val) {
if (val != 0.f) {
//val = 1.0f / val; // test program indicate z values are 1 over
return 0xffffffff; // infinity
}
@ -922,7 +922,6 @@ uint32_t CReal3D::GetASICIDCode(ASIC asic) const
}
void CReal3D::SetStepping(int stepping, uint32_t pciIDValue)
{
step = stepping;
if ((step!=0x10) && (step!=0x15) && (step!=0x20) && (step!=0x21))

View file

@ -36,7 +36,7 @@
#include "Util/NewConfig.h"
#include <cstdint>
#include <map>
#include <unordered_map>
/*
* QueuedUploadTextures:
@ -505,7 +505,7 @@ private:
bool m_evenFrame = false;
// Internal ASIC state
std::map<ASIC, uint32_t> m_asicID;
std::unordered_map<ASIC, uint32_t> m_asicID;
uint64_t m_internalRenderConfig[2];
};

View file

@ -104,7 +104,7 @@ private:
// netsock
UINT16 port_in = 0;
UINT16 port_out = 0;
std::string addr_out = "";
std::string addr_out;
std::unique_ptr<TCPSend> nets;
std::unique_ptr<TCPReceive> netr;

View file

@ -85,7 +85,7 @@ private:
// netsock
uint16_t port_in = 0;
uint16_t port_out = 0;
std::string addr_out = "";
std::string addr_out;
std::thread m_connectThread;
std::atomic_bool m_quit = false;
std::atomic_bool m_connected = false;

View file

@ -60,7 +60,7 @@ bool TCPSend::Send(const void * data, int length)
DPRINTF("Sending %i bytes\n", length);
int sent = 0;
int sent;
sent = SDLNet_TCP_Send(m_socket, &length, sizeof(int)); // pack the length at the start of transmission.

View file

@ -112,7 +112,7 @@ std::shared_ptr<CLogger> CreateLogger(const Util::Config::Node &config)
loggers.push_back(std::make_shared<CConsoleErrorLogger>());
// 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::set<std::string> supportedDestinations { "stdout", "stderr", "syslog" };

View file

@ -1444,7 +1444,7 @@ HRESULT CDirectInputSystem::CreateJoystickEffect(LPDIRECTINPUTDEVICE8 joystick,
DICONSTANTFORCE dicf;
DICONDITION dic;
DIPERIODIC dip;
DIENVELOPE die;
//DIENVELOPE die;
GUID guid;
// Set common effects parameters
@ -1883,7 +1883,7 @@ bool CDirectInputSystem::ProcessForceFeedbackCmd(int joyNum, int axisNum, ForceF
DICONSTANTFORCE dicf;
DICONDITION dic;
DIPERIODIC dip;
DIENVELOPE die;
//DIENVELOPE die;
// Set common parameters
DIEFFECT eff;

View file

@ -276,7 +276,7 @@ namespace Util
std::string BitRegister::ToBinaryString() const
{
if (Empty())
return std::string("");
return std::string();
std::string out(Size(), '0');
for (size_t i = 0; i < Size(); i++)
{
@ -287,9 +287,9 @@ namespace Util
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())
return std::string("");
return std::string();
size_t partial = Size() & 3;
size_t num_digits = Size() / 4 + (partial != 0 ? 1 : 0);
std::string out(num_digits + 2, '0');