GCC: Fixed warnings

This commit is contained in:
Sour 2018-03-24 11:22:43 -04:00
parent 566a46e21f
commit 8af8ab205c
19 changed files with 65 additions and 53 deletions

View file

@ -275,7 +275,6 @@ void Debugger::ProcessBreakpoints(BreakpointType type, OperationInfo &operationI
return;
}
uint32_t absoluteAddr;
AddressTypeInfo info { -1, AddressType::InternalRam };
PpuAddressTypeInfo ppuInfo { -1, PpuAddressType::None };
bool isPpuBreakpoint = false;
@ -284,13 +283,11 @@ void Debugger::ProcessBreakpoints(BreakpointType type, OperationInfo &operationI
case BreakpointType::ReadRam:
case BreakpointType::WriteRam:
GetAbsoluteAddressAndType(operationInfo.Address, &info);
absoluteAddr = info.Address;
break;
case BreakpointType::ReadVram:
case BreakpointType::WriteVram:
GetPpuAbsoluteAddressAndType(operationInfo.Address, &ppuInfo);
absoluteAddr = ppuInfo.Address;
isPpuBreakpoint = true;
break;
}
@ -446,7 +443,7 @@ void Debugger::StaticProcessEvent(EventType type)
}
}
void Debugger::ProcessStepConditions(uint32_t addr)
void Debugger::ProcessStepConditions(uint16_t addr)
{
if(_stepOut && (_lastInstruction == 0x60 || _lastInstruction == 0x40) && _stepOutReturnAddress == addr) {
//RTS/RTI found, if we're on the expected return address, break immediately

View file

@ -137,7 +137,7 @@ private:
void UpdateCallstack(uint8_t currentInstruction, uint32_t addr);
void PrivateProcessInterrupt(uint16_t cpuAddr, uint16_t destCpuAddr, bool forNmi);
void ProcessStepConditions(uint32_t addr);
void ProcessStepConditions(uint16_t addr);
bool SleepUntilResume(BreakSource source = BreakSource::Break);
void AddDebugEvent(DebugEventType type, uint16_t address = -1, uint8_t value = 0, int16_t breakpointId = -1, int8_t ppuLatch = -1);

View file

@ -468,7 +468,7 @@ string Disassembler::GetCode(AddressTypeInfo &addressInfo, uint32_t endAddr, uin
vector<shared_ptr<DisassemblyInfo>> *cache;
uint8_t *source;
char memoryType;
char memoryType = 'P';
switch(addressInfo.Type) {
case AddressType::InternalRam: memoryType = 'N'; break;
case AddressType::PrgRom: memoryType = 'P'; break;
@ -489,7 +489,7 @@ string Disassembler::GetCode(AddressTypeInfo &addressInfo, uint32_t endAddr, uin
string commentLines;
shared_ptr<DisassemblyInfo> infoRef;
DisassemblyInfo* info;
DataType dataType;
DataType dataType = DataType::UnidentifiedData;
string spaces = " ";
string effAddress;
string code;

View file

@ -7,7 +7,7 @@
class FamilyBasicDataRecorder : public BaseControlDevice
{
private:
static const uint32_t SamplingRate = 88;
static const int32_t SamplingRate = 88;
vector<uint8_t> _data;
vector<uint8_t> _fileData;
bool _enabled = false;

View file

@ -6,11 +6,11 @@
struct HdTileKey
{
static const uint32_t NoTile = -1;
static const int32_t NoTile = -1;
uint32_t PaletteColors;
uint8_t TileData[16];
uint32_t TileIndex;
int32_t TileIndex;
bool IsChrRamTile = false;
HdTileKey GetKey(bool defaultKey)

View file

@ -29,12 +29,12 @@ void HdNesPack::BlendColors(uint8_t output[4], uint8_t input[4])
uint32_t HdNesPack::AdjustBrightness(uint8_t input[4], uint16_t brightness)
{
uint8_t output[4];
output[0] = std::min(255, (brightness * input[0]) >> 8);
output[1] = std::min(255, (brightness * input[1]) >> 8);
output[2] = std::min(255, (brightness * input[2]) >> 8);
output[3] = input[3];
return *((uint32_t*)output);
return (
std::min(255, (brightness * input[0]) >> 8) |
(std::min(255, (brightness * input[1]) >> 8) << 8) |
(std::min(255, (brightness * input[2]) >> 8) << 16) |
(input[3] << 24)
);
}
void HdNesPack::DrawColor(uint32_t color, uint32_t *outputBuffer, uint32_t scale, uint32_t screenWidth)

View file

@ -31,7 +31,7 @@ private:
uint32_t _flags;
//Used to group blank tiles together
int _blankTileIndex = 0;
uint32_t _blankTileIndex = 0;
int _blankTilePalette = 0;
void AddTile(HdPackTileInfo *tile, uint32_t usageCount);

View file

@ -292,6 +292,7 @@ void HdPackLoader::ProcessTileTag(vector<string> &tokens, vector<HdPackCondition
tileInfo->TileData[i] = HexUtilities::FromHex(tileData.substr(i * 2, 2));
}
tileInfo->IsChrRamTile = true;
tileInfo->TileIndex = -1;
} else {
tileInfo->TileIndex = std::stoi(tileData);
tileInfo->IsChrRamTile = false;
@ -453,6 +454,8 @@ void HdPackLoader::ProcessConditionTag(vector<string> &tokens, bool createInvert
op = HdPackConditionOperator::GreaterThan;
} else if(opString == "<") {
op = HdPackConditionOperator::LowerThan;
} else {
checkConstraint(false, "[HDPack] Invalid operator.");
}
uint32_t operandB = HexUtilities::FromHex(tokens[index++]);

View file

@ -14,13 +14,25 @@ NtscFilter::NtscFilter()
FrameInfo NtscFilter::GetFrameInfo()
{
OverscanDimensions overscan = GetOverscan();
int overscanLeft = overscan.Left > 0 ? NES_NTSC_OUT_WIDTH(overscan.Left) : 0;
int overscanRight = overscan.Right > 0 ? NES_NTSC_OUT_WIDTH(overscan.Right) : 0;
uint32_t overscanLeft = overscan.Left > 0 ? NES_NTSC_OUT_WIDTH(overscan.Left) : 0;
uint32_t overscanRight = overscan.Right > 0 ? NES_NTSC_OUT_WIDTH(overscan.Right) : 0;
if(_keepVerticalRes) {
return { NES_NTSC_OUT_WIDTH(PPU::ScreenWidth) - overscanLeft - overscanRight, (PPU::ScreenHeight - overscan.Top - overscan.Bottom), NES_NTSC_OUT_WIDTH(PPU::ScreenWidth), PPU::ScreenHeight, 4 };
return {
(NES_NTSC_OUT_WIDTH(PPU::ScreenWidth) - overscanLeft - overscanRight),
(PPU::ScreenHeight - overscan.Top - overscan.Bottom),
NES_NTSC_OUT_WIDTH(PPU::ScreenWidth),
PPU::ScreenHeight,
4
};
} else {
return { NES_NTSC_OUT_WIDTH(PPU::ScreenWidth) - overscanLeft - overscanRight, (PPU::ScreenHeight - overscan.Top - overscan.Bottom) * 2, NES_NTSC_OUT_WIDTH(PPU::ScreenWidth), PPU::ScreenHeight * 2, 4 };
return {
NES_NTSC_OUT_WIDTH(PPU::ScreenWidth) - overscanLeft - overscanRight,
(PPU::ScreenHeight - overscan.Top - overscan.Bottom) * 2,
NES_NTSC_OUT_WIDTH(PPU::ScreenWidth),
PPU::ScreenHeight * 2,
4
};
}
}

View file

@ -159,10 +159,10 @@ class PPU : public IMemoryHandler, public Snapshotable
void StreamState(bool saving) override;
public:
static const uint32_t ScreenWidth = 256;
static const uint32_t ScreenHeight = 240;
static const uint32_t PixelCount = 256*240;
static const uint32_t OutputBufferSize = 256*240*2;
static const int32_t ScreenWidth = 256;
static const int32_t ScreenHeight = 240;
static const int32_t PixelCount = 256*240;
static const int32_t OutputBufferSize = 256*240*2;
PPU(BaseMapper *mapper, ControlManager *controlManager);
virtual ~PPU();

View file

@ -226,7 +226,7 @@ void RewindManager::ProcessFrame(void * frameBuffer, uint32_t width, uint32_t he
_videoHistoryBuilder.push_back(vector<uint32_t>((uint32_t*)frameBuffer, (uint32_t*)frameBuffer + width*height));
if(_videoHistoryBuilder.size() == _historyBackup.front().FrameCount) {
if(_videoHistoryBuilder.size() == (size_t)_historyBackup.front().FrameCount) {
for(int i = (int)_videoHistoryBuilder.size() - 1; i >= 0; i--) {
_videoHistory.push_front(_videoHistoryBuilder[i]);
}

View file

@ -18,7 +18,7 @@ enum class RewindState
class RewindManager : public INotificationListener, public IInputProvider, public IInputRecorder
{
private:
static const uint32_t BufferSize = 30; //Number of frames between each save state
static const int32_t BufferSize = 30; //Number of frames between each save state
static RewindManager* _instance;
std::deque<RewindData> _history;
std::deque<RewindData> _historyBackup;

View file

@ -67,7 +67,7 @@ void TraceLogger::StopLogging()
}
}
void TraceLogger::LogStatic(char *log)
void TraceLogger::LogStatic(const char *log)
{
if(_instance && _instance->_logToFile && _instance->_options.ShowExtraInfo) {
LogStatic(string(log));

View file

@ -88,7 +88,7 @@ public:
const char* GetExecutionTrace(uint32_t lineCount);
static void LogStatic(char *log);
static void LogStatic(const char *log);
static void LogStatic(string log);
};

View file

@ -4,9 +4,9 @@
#include "BpsPatcher.h"
#include "CRC32.h"
uint64_t BpsPatcher::ReadBase128Number(std::istream &file)
int64_t BpsPatcher::ReadBase128Number(std::istream &file)
{
uint64_t result = 0;
int64_t result = 0;
int shift = 0;
uint8_t buffer;
while(true) {
@ -19,7 +19,7 @@ uint64_t BpsPatcher::ReadBase128Number(std::istream &file)
if(buffer & 0x80) {
break;
}
result += (uint64_t)1 << shift;
result += (int64_t)1 << shift;
}
return result;
@ -47,14 +47,14 @@ bool BpsPatcher::PatchBuffer(std::istream &bpsFile, vector<uint8_t> &input, vect
return false;
}
uint64_t inputFileSize = ReadBase128Number(bpsFile);
uint64_t outputFileSize = ReadBase128Number(bpsFile);
int64_t inputFileSize = ReadBase128Number(bpsFile);
int64_t outputFileSize = ReadBase128Number(bpsFile);
if(inputFileSize == -1 || outputFileSize == -1) {
//Invalid file
return false;
}
uint64_t metadataSize = ReadBase128Number(bpsFile);
int64_t metadataSize = ReadBase128Number(bpsFile);
bpsFile.seekg(metadataSize, std::ios::cur);
output.resize((size_t)outputFileSize);
@ -63,7 +63,7 @@ bool BpsPatcher::PatchBuffer(std::istream &bpsFile, vector<uint8_t> &input, vect
uint32_t inputRelativeOffset = 0;
uint32_t outputRelativeOffset = 0;
while((size_t)bpsFile.tellg() < fileSize - 12) {
uint64_t data = ReadBase128Number(bpsFile);
int64_t data = ReadBase128Number(bpsFile);
if(data == -1) {
//Invalid file
return false;
@ -92,7 +92,7 @@ bool BpsPatcher::PatchBuffer(std::istream &bpsFile, vector<uint8_t> &input, vect
case 2: {
//SourceCopy
uint32_t data = (uint32_t)ReadBase128Number(bpsFile);
int32_t data = (int32_t)ReadBase128Number(bpsFile);
inputRelativeOffset += (data & 1 ? -1 : +1) * (data >> 1);
while(length--) {
output[outputOffset++] = input[inputRelativeOffset++];
@ -102,7 +102,7 @@ bool BpsPatcher::PatchBuffer(std::istream &bpsFile, vector<uint8_t> &input, vect
case 3: {
//TargetCopy
uint32_t data = (uint32_t)ReadBase128Number(bpsFile);
int32_t data = (int32_t)ReadBase128Number(bpsFile);
outputRelativeOffset += (data & 1 ? -1 : +1) * (data >> 1);
while(length--) {
output[outputOffset++] = output[outputRelativeOffset++];

View file

@ -5,7 +5,7 @@
class BpsPatcher
{
private:
static uint64_t ReadBase128Number(std::istream &file);
static int64_t ReadBase128Number(std::istream &file);
public:
static bool PatchBuffer(std::istream &bpsFile, vector<uint8_t> &input, vector<uint8_t> &output);

View file

@ -4,9 +4,9 @@
#include "UpsPatcher.h"
#include "CRC32.h"
uint64_t UpsPatcher::ReadBase128Number(std::istream &file)
int64_t UpsPatcher::ReadBase128Number(std::istream &file)
{
uint64_t result = 0;
int64_t result = 0;
int shift = 0;
uint8_t buffer;
while(true) {
@ -19,7 +19,7 @@ uint64_t UpsPatcher::ReadBase128Number(std::istream &file)
if(buffer & 0x80) {
break;
}
result += (uint64_t)1 << shift;
result += (int64_t)1 << shift;
}
return result;
@ -47,8 +47,8 @@ bool UpsPatcher::PatchBuffer(std::istream &upsFile, vector<uint8_t> &input, vect
return false;
}
uint64_t inputFileSize = ReadBase128Number(upsFile);
uint64_t outputFileSize = ReadBase128Number(upsFile);
int64_t inputFileSize = ReadBase128Number(upsFile);
int64_t outputFileSize = ReadBase128Number(upsFile);
if(inputFileSize == -1 || outputFileSize == -1) {
//Invalid file
return false;
@ -59,7 +59,7 @@ bool UpsPatcher::PatchBuffer(std::istream &upsFile, vector<uint8_t> &input, vect
uint32_t pos = 0;
while((size_t)upsFile.tellg() < fileSize - 12) {
uint32_t offset = (uint32_t)ReadBase128Number(upsFile);
int32_t offset = (int32_t)ReadBase128Number(upsFile);
if(offset == -1) {
//Invalid file
return false;

View file

@ -5,7 +5,7 @@
class UpsPatcher
{
private:
static uint64_t ReadBase128Number(std::istream &file);
static int64_t ReadBase128Number(std::istream &file);
public:
static bool PatchBuffer(std::istream &upsFile, vector<uint8_t> &input, vector<uint8_t> &output);

View file

@ -21,7 +21,7 @@ MESENFLAGS=
libretro : MESENFLAGS=-D LIBRETRO
CPPC=clang++
GCCOPTIONS=-fPIC -Wall --std=c++14 -O3 $(MESENFLAGS)
GCCOPTIONS=-fPIC -Wall --std=c++14 -O3 $(MESENFLAGS) -Wno-parentheses -Wno-switch
CC=clang
CCOPTIONS=-fPIC -Wall -O3 $(MESENFLAGS)
@ -90,7 +90,7 @@ testhelper: InteropDLL/$(OBJFOLDER)/$(SHAREDLIB)
$(AR) TestHelper/$(OBJFOLDER)/libMesenLinux.a $(LINUXOBJ) $(LIBEVDEVOBJ)
$(AR) TestHelper/$(OBJFOLDER)/libUtilities.a $(UTILOBJ)
$(AR) TestHelper/$(OBJFOLDER)/libCore.a $(COREOBJ)
cd TestHelper/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) $(LINKFLAG) -Wl,-z,defs -Wno-parentheses -Wno-switch -o testhelper ../*.cpp ../../InteropDLL/ConsoleWrapper.cpp -L ./ -lCore -lMesenLinux -lUtilities -lSevenZip -pthread -lSDL2 -lstdc++fs
cd TestHelper/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) $(LINKFLAG) -Wl,-z,defs -o testhelper ../*.cpp ../../InteropDLL/ConsoleWrapper.cpp -L ./ -lCore -lMesenLinux -lUtilities -lSevenZip -pthread -lSDL2 -lstdc++fs
SevenZip/$(OBJFOLDER)/%.o: SevenZip/%.c
mkdir -p SevenZip/$(OBJFOLDER) && cd SevenZip/$(OBJFOLDER) && $(CC) $(CCOPTIONS) -c $(patsubst SevenZip/%, ../%, $<)
@ -107,11 +107,11 @@ Utilities/$(OBJFOLDER)/%.o: Utilities/KreedSaiEagle/%.cpp
Utilities/$(OBJFOLDER)/%.o: Utilities/Scale2x/%.cpp
mkdir -p Utilities/$(OBJFOLDER) && cd Utilities/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<)
Core/$(OBJFOLDER)/%.o: Core/%.cpp
mkdir -p Core/$(OBJFOLDER) && cd Core/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -Wno-parentheses -Wno-switch -c $(patsubst Core/%, ../%, $<)
mkdir -p Core/$(OBJFOLDER) && cd Core/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Core/%, ../%, $<)
Linux/$(OBJFOLDER)/%.o: Linux/%.cpp
mkdir -p Linux/$(OBJFOLDER) && cd Linux/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -Wno-parentheses -Wno-switch -c $(patsubst Linux/%, ../%, $<)
mkdir -p Linux/$(OBJFOLDER) && cd Linux/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Linux/%, ../%, $<)
Linux/$(OBJFOLDER)/%.o: Linux/libevdev/%.c
mkdir -p Linux/$(OBJFOLDER) && cd Linux/$(OBJFOLDER) && $(CC) $(CCOPTIONS) -Wno-parentheses -Wno-switch -c $(patsubst Linux/%, ../%, $<)
mkdir -p Linux/$(OBJFOLDER) && cd Linux/$(OBJFOLDER) && $(CC) $(CCOPTIONS) -c $(patsubst Linux/%, ../%, $<)
InteropDLL/$(OBJFOLDER)/$(SHAREDLIB): $(SEVENZIPOBJ) $(LUAOBJ) $(UTILOBJ) $(COREOBJ) $(LIBEVDEVOBJ) $(LINUXOBJ) InteropDLL/ConsoleWrapper.cpp InteropDLL/DebugWrapper.cpp
mkdir -p InteropDLL/$(OBJFOLDER)
@ -120,7 +120,7 @@ InteropDLL/$(OBJFOLDER)/$(SHAREDLIB): $(SEVENZIPOBJ) $(LUAOBJ) $(UTILOBJ) $(CORE
$(AR) InteropDLL/$(OBJFOLDER)/libMesenLinux.a $(LINUXOBJ) $(LIBEVDEVOBJ)
$(AR) InteropDLL/$(OBJFOLDER)/libUtilities.a $(UTILOBJ)
$(AR) InteropDLL/$(OBJFOLDER)/libCore.a $(COREOBJ)
cd InteropDLL/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) $(LINKFLAG) -Wl,-z,defs -Wno-parentheses -Wno-switch -shared -o $(SHAREDLIB) ../*.cpp -L . -lMesenLinux -lCore -lUtilities -lLua -lSevenZip -pthread -lSDL2 -lstdc++fs
cd InteropDLL/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) $(LINKFLAG) -Wl,-z,defs -shared -o $(SHAREDLIB) ../*.cpp -L . -lMesenLinux -lCore -lUtilities -lLua -lSevenZip -pthread -lSDL2 -lstdc++fs
Libretro/$(OBJFOLDER)/$(LIBRETROLIB): $(SEVENZIPOBJ) $(UTILOBJ) $(COREOBJ) Libretro/libretro.cpp
@ -128,7 +128,7 @@ Libretro/$(OBJFOLDER)/$(LIBRETROLIB): $(SEVENZIPOBJ) $(UTILOBJ) $(COREOBJ) Libre
$(AR) Libretro/$(OBJFOLDER)/libSevenZip.a $(SEVENZIPOBJ)
$(AR) Libretro/$(OBJFOLDER)/libUtilities.a $(UTILOBJ)
$(AR) Libretro/$(OBJFOLDER)/libCore.a $(COREOBJ)
cd Libretro/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) $(LINKFLAG) -Wl,-z,defs -Wno-parentheses -Wno-switch -shared -o $(LIBRETROLIB) ../*.cpp -L . -lCore -lUtilities -lSevenZip -pthread
cd Libretro/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) $(LINKFLAG) -Wl,-z,defs -shared -o $(LIBRETROLIB) ../*.cpp -L . -lCore -lUtilities -lSevenZip -pthread
debug:
MONO_LOG_LEVEL=debug mono $(RELEASEFOLDER)/Mesen.exe