Linux: Removed -Wno-switch option and fixed warnings

This commit is contained in:
Sour 2018-06-25 15:56:05 -04:00
parent 669113710a
commit 1e90a71394
26 changed files with 86 additions and 9 deletions

View File

@ -81,6 +81,10 @@ public:
if(_nesModel != model) {
_nesModel = model;
switch(model) {
case NesModel::Auto:
//Auto should never be set here
break;
case NesModel::NTSC:
case NesModel::Dendy:
memcpy(_stepCycles, _stepCyclesNtsc, sizeof(_stepCycles));

View File

@ -886,6 +886,7 @@ uint32_t BaseMapper::CopyMemory(DebugMemoryType type, uint8_t* buffer)
{
uint32_t chrRomSize = _onlyChrRam ? 0 : _chrRomSize;
switch(type) {
default: break;
case DebugMemoryType::ChrRam: memcpy(buffer, _chrRam, _chrRamSize); return _chrRamSize;
case DebugMemoryType::ChrRom: memcpy(buffer, _chrRom, chrRomSize); return chrRomSize;
case DebugMemoryType::PrgRom: memcpy(buffer, _prgRom, _prgSize); return _prgSize;
@ -899,6 +900,7 @@ uint32_t BaseMapper::CopyMemory(DebugMemoryType type, uint8_t* buffer)
void BaseMapper::WriteMemory(DebugMemoryType type, uint8_t* buffer)
{
switch(type) {
default: break;
case DebugMemoryType::ChrRam: memcpy(_chrRam, buffer, _chrRamSize); break;
case DebugMemoryType::SaveRam: memcpy(_saveRam, buffer, _saveRamSize); break;
case DebugMemoryType::WorkRam: memcpy(_workRam, buffer, _workRamSize); break;
@ -933,6 +935,7 @@ uint8_t BaseMapper::GetMemoryValue(DebugMemoryType memoryType, uint32_t address)
}
switch(memoryType) {
default: break;
case DebugMemoryType::ChrRom: return _chrRom[address];
case DebugMemoryType::ChrRam: return _chrRam[address];
case DebugMemoryType::SaveRam: return _saveRam[address];
@ -952,6 +955,7 @@ void BaseMapper::SetMemoryValue(DebugMemoryType memoryType, uint32_t address, ui
}
switch(memoryType) {
default: break;
case DebugMemoryType::ChrRom: _chrRom[address] = value; break;
case DebugMemoryType::ChrRam: _chrRam[address] = value; break;
case DebugMemoryType::SaveRam: _saveRam[address] = value; break;

View File

@ -968,6 +968,8 @@ uint8_t* Console::GetRamBuffer(DebugMemoryType memoryType, uint32_t &size, int32
{
//Only used by libretro port for achievements - should not be used by anything else.
switch(memoryType) {
default: break;
case DebugMemoryType::InternalRam:
size = MemoryManager::InternalRAMSize;
startAddr = 0;

View File

@ -124,6 +124,7 @@ shared_ptr<BaseControlDevice> ControlManager::CreateControllerDevice(ControllerT
shared_ptr<BaseControlDevice> device;
switch(type) {
case ControllerType::None: break;
case ControllerType::StandardController: device.reset(new StandardController(port, EmulationSettings::GetControllerKeys(port))); break;
case ControllerType::Zapper: device.reset(new Zapper(port)); break;
case ControllerType::ArkanoidController: device.reset(new ArkanoidController(port)); break;

View File

@ -290,6 +290,9 @@ void Debugger::ProcessBreakpoints(BreakpointType type, OperationInfo &operationI
PpuAddressTypeInfo ppuInfo { -1, PpuAddressType::None };
bool isPpuBreakpoint = false;
switch(type) {
case BreakpointType::Global:
break;
case BreakpointType::Execute:
case BreakpointType::ReadRam:
case BreakpointType::WriteRam:
@ -657,8 +660,9 @@ bool Debugger::PrivateProcessRamOperation(MemoryOperationType type, uint16_t &ad
}
if(type != MemoryOperationType::DummyRead) {
BreakpointType breakpointType = BreakpointType::Execute;
BreakpointType breakpointType;
switch(type) {
default: breakpointType = BreakpointType::Execute; break;
case MemoryOperationType::Read: breakpointType = BreakpointType::ReadRam; break;
case MemoryOperationType::Write: breakpointType = BreakpointType::WriteRam; break;
}

View File

@ -156,6 +156,10 @@ bool Disassembler::IsUnconditionalJump(uint8_t opCode)
void Disassembler::GetInfo(AddressTypeInfo &info, uint8_t** source, uint32_t &size, vector<shared_ptr<DisassemblyInfo>> **cache)
{
switch(info.Type) {
case AddressType::Register:
//AddressType::Register should never be used here
break;
case AddressType::InternalRam:
*source = _memoryManager->GetInternalRAM();
*cache = &_disassembleMemoryCache;
@ -264,6 +268,10 @@ void Disassembler::InvalidateCache(AddressTypeInfo &info)
addr = info.Address;
cache = &_disassembleSaveRamCache;
break;
default:
//No need to invalidate PRG ROM cache (since it's not RAM)
break;
}
if(cache && addr >= 0) {
@ -470,6 +478,7 @@ string Disassembler::GetCode(AddressTypeInfo &addressInfo, uint32_t endAddr, uin
uint8_t *source;
char memoryType = 'P';
switch(addressInfo.Type) {
case AddressType::Register: break; //Should never happen
case AddressType::InternalRam: memoryType = 'N'; break;
case AddressType::PrgRom: memoryType = 'P'; break;
case AddressType::WorkRam: memoryType = 'W'; break;
@ -662,6 +671,7 @@ DisassemblyInfo Disassembler::GetDisassemblyInfo(AddressTypeInfo &info)
{
DisassemblyInfo* disassemblyInfo = nullptr;
switch(info.Type) {
case AddressType::Register: break; //Should never happen
case AddressType::InternalRam: disassemblyInfo = _disassembleMemoryCache[info.Address & 0x7FF].get(); break;
case AddressType::PrgRom: disassemblyInfo = _disassembleCache[info.Address].get(); break;
case AddressType::WorkRam: disassemblyInfo = _disassembleWorkRamCache[info.Address].get(); break;

View File

@ -226,6 +226,8 @@ void DisassemblyInfo::GetEffectiveAddressString(string &out, State& cpuState, Me
int32_t DisassemblyInfo::GetEffectiveAddress(State& cpuState, MemoryManager* memoryManager)
{
switch(_opMode) {
default: break;
case AddrMode::ZeroX: return (uint8_t)(_byteCode[1] + cpuState.X); break;
case AddrMode::ZeroY: return (uint8_t)(_byteCode[1] + cpuState.Y); break;

View File

@ -142,6 +142,8 @@ uint32_t EmulationSettings::GetEmulationSpeed(bool ignoreTurbo)
double EmulationSettings::GetAspectRatio()
{
switch(_aspectRatio) {
case VideoAspectRatio::NoStretching: return 0.0;
case VideoAspectRatio::Auto:
{
NesModel model = GetNesModel();

View File

@ -525,7 +525,7 @@ struct KeyCombination
enum class Language
{
SystemDefault = 0,
//SystemDefault = 0, //This value is never used by the C++ core
English = 1,
French = 2,
Japanese = 3,

View File

@ -439,6 +439,7 @@ void GameDatabase::SetGameInfo(uint32_t romCrc, RomData &romData, bool updateRom
}
switch(GetBusConflictType(info.BusConflicts)) {
case BusConflictType::Default: break;
case BusConflictType::Yes: MessageManager::Log("[DB] Bus conflicts: Yes"); break;
case BusConflictType::No: MessageManager::Log("[DB] Bus conflicts: No"); break;
}

View File

@ -92,12 +92,10 @@ protected:
void WriteRAM(uint16_t addr, uint8_t value)
{
switch(GetRegisterID(addr)) {
case PPURegisters::VideoMemoryData:
if(GetRegisterID(addr) == PPURegisters::VideoMemoryData) {
if(_state.VideoRamAddr < 0x2000) {
_needChrHash = true;
}
break;
}
PPU::WriteRAM(addr, value);
}

View File

@ -710,6 +710,7 @@ int LuaApi::GetAccessCounters(lua_State *lua)
uint32_t size = 0;
switch(memoryType) {
case AddressType::Register: error("Invalid memory type"); break;
case AddressType::InternalRam: size = 0x2000; break;
case AddressType::PrgRom: size = _debugger->GetMemoryDumper()->GetMemorySize(DebugMemoryType::PrgRom); break;
case AddressType::WorkRam: size = _debugger->GetMemoryDumper()->GetMemorySize(DebugMemoryType::WorkRam); break;

View File

@ -281,6 +281,9 @@ class MMC3 : public BaseMapper
virtual void NotifyVRAMAddressChange(uint16_t addr) override
{
switch(_a12Watcher.UpdateVramAddress(addr)) {
case A12StateChange::None:
break;
case A12StateChange::Fall:
if(_needIrq) {
//Used by MC-ACC (Acclaim copy of the MMC3), see TriggerIrq above

View File

@ -97,6 +97,10 @@ protected:
{
if((_mode & 0x03) == 1) {
switch(_a12Watcher.UpdateVramAddress(addr)) {
case A12StateChange::None:
case A12StateChange::Fall:
break;
case A12StateChange::Rise:
if(_irqCounter == 0 || _irqReload) {
_irqCounter = _irqReloadValue;

View File

@ -26,6 +26,7 @@ protected:
case MirroringType::Horizontal: mask = 0x800; break;
case MirroringType::ScreenAOnly: mask = 0x1000; break;
case MirroringType::ScreenBOnly: mask = 0x2000; break;
case MirroringType::FourScreens: break; //Will never be FourScreens, see InitMapper() above
}
for(int i = 0; i < 8; i++) {

View File

@ -90,6 +90,8 @@ void MemoryAccessCounter::GetAccessCounts(AddressType memoryType, MemoryOperatio
void MemoryAccessCounter::GetAccessStamps(uint32_t offset, uint32_t length, DebugMemoryType memoryType, MemoryOperationType operationType, uint32_t stamps[])
{
switch(memoryType) {
default: break;
case DebugMemoryType::InternalRam:
memcpy(stamps, GetArray(operationType, AddressType::InternalRam, true).data() + offset, length * sizeof(uint32_t));
break;
@ -119,6 +121,8 @@ void MemoryAccessCounter::GetAccessStamps(uint32_t offset, uint32_t length, Debu
void MemoryAccessCounter::GetAccessCountsEx(uint32_t offset, uint32_t length, DebugMemoryType memoryType, MemoryOperationType operationType, int32_t counts[])
{
switch(memoryType) {
default: break;
case DebugMemoryType::InternalRam:
memcpy(counts, GetArray(operationType, AddressType::InternalRam, false).data() + offset, length * sizeof(uint32_t));
break;

View File

@ -23,6 +23,12 @@ MemoryDumper::MemoryDumper(shared_ptr<PPU> ppu, shared_ptr<MemoryManager> memory
void MemoryDumper::SetMemoryState(DebugMemoryType type, uint8_t *buffer)
{
switch(type) {
case DebugMemoryType::ChrRom:
case DebugMemoryType::PrgRom:
case DebugMemoryType::CpuMemory:
case DebugMemoryType::PpuMemory:
break;
case DebugMemoryType::InternalRam:
for(int i = 0; i < 0x800; i++) {
_memoryManager->DebugWrite(i, buffer[i]);
@ -172,6 +178,7 @@ void MemoryDumper::SetMemoryValue(DebugMemoryType memoryType, uint32_t address,
_debugger->GetAbsoluteAddressAndType(address, &info);
if(info.Address >= 0) {
switch(info.Type) {
case AddressType::Register: break; //not supported
case AddressType::InternalRam: SetMemoryValue(DebugMemoryType::InternalRam, info.Address, value, preventRebuildCache, true); break;
case AddressType::PrgRom: SetMemoryValue(DebugMemoryType::PrgRom, info.Address, value, preventRebuildCache, true); break;
case AddressType::WorkRam: SetMemoryValue(DebugMemoryType::WorkRam, info.Address, value, preventRebuildCache, true); break;
@ -230,6 +237,7 @@ uint8_t MemoryDumper::GetMemoryValue(DebugMemoryType memoryType, uint32_t addres
_debugger->GetAbsoluteAddressAndType(address, &info);
if(info.Address >= 0) {
switch(info.Type) {
case AddressType::Register: return 0; //not supported
case AddressType::InternalRam: return GetMemoryValue(DebugMemoryType::InternalRam, info.Address, true);
case AddressType::PrgRom: return GetMemoryValue(DebugMemoryType::PrgRom, info.Address, true);
case AddressType::WorkRam: return GetMemoryValue(DebugMemoryType::WorkRam, info.Address, true);

View File

@ -77,6 +77,7 @@ void MovieRecorder::GetGameSettings(stringstream &out)
}
switch(model) {
case NesModel::Auto: break; //Console::GetModel() will never return Auto.
case NesModel::NTSC: WriteString(out, MovieKeys::Region, "NTSC"); break;
case NesModel::PAL: WriteString(out, MovieKeys::Region, "PAL"); break;
case NesModel::Dendy: WriteString(out, MovieKeys::Region, "Dendy"); break;

View File

@ -109,6 +109,10 @@ void PPU::SetNesModel(NesModel model)
_nesModel = model;
switch(_nesModel) {
case NesModel::Auto:
//Should never be Auto
break;
case NesModel::NTSC:
_nmiScanline = 241;
_vblankEnd = 260;
@ -239,6 +243,7 @@ uint8_t PPU::ReadRAM(uint16_t addr)
case PpuModel::Ppu2C05C: openBusMask = 0x00; returnValue |= 0x1C; break;
case PpuModel::Ppu2C05D: openBusMask = 0x00; returnValue |= 0x1B; break;
case PpuModel::Ppu2C05E: openBusMask = 0x00; break;
default: break;
}
break;

View File

@ -89,6 +89,9 @@ void RecordedRomTest::ProcessNotification(ConsoleNotificationType type, void* pa
Save();
}
break;
default:
break;
}
}

View File

@ -105,6 +105,12 @@ public:
_chrOr[1] = 2;
_chrOr[2] = 3;
break;
case Sachen8259Variant::Sachen8259D:
//Variant D does not use the _shift / _chrOr variables at all
_shift = 0;
_chrOr[0] = _chrOr[1] = _chrOr[2] = 0;
break;
}
}
};

View File

@ -103,6 +103,15 @@ shared_ptr<ScaleFilter> ScaleFilter::GetScaleFilter(VideoFilterType filter)
{
shared_ptr<ScaleFilter> scaleFilter;
switch(filter) {
case VideoFilterType::BisqwitNtsc:
case VideoFilterType::BisqwitNtscHalfRes:
case VideoFilterType::BisqwitNtscQuarterRes:
case VideoFilterType::NTSC:
case VideoFilterType::HdPack:
case VideoFilterType::Raw:
case VideoFilterType::None:
break;
case VideoFilterType::xBRZ2x: scaleFilter.reset(new ScaleFilter(ScaleFilterType::xBRZ, 2)); break;
case VideoFilterType::xBRZ3x: scaleFilter.reset(new ScaleFilter(ScaleFilterType::xBRZ, 3)); break;
case VideoFilterType::xBRZ4x: scaleFilter.reset(new ScaleFilter(ScaleFilterType::xBRZ, 4)); break;

View File

@ -42,6 +42,7 @@ void ScriptHost::ProcessCpuOperation(uint16_t addr, uint8_t &value, MemoryOperat
case MemoryOperationType::Read: _context->CallMemoryCallback(addr, value, CallbackType::CpuRead); break;
case MemoryOperationType::Write: _context->CallMemoryCallback(addr, value, CallbackType::CpuWrite); break;
case MemoryOperationType::ExecOpCode: _context->CallMemoryCallback(addr, value, CallbackType::CpuExec); break;
default: break;
}
}
}
@ -52,6 +53,7 @@ void ScriptHost::ProcessPpuOperation(uint16_t addr, uint8_t &value, MemoryOperat
switch(type) {
case MemoryOperationType::Read: _context->CallMemoryCallback(addr, value, CallbackType::PpuRead); break;
case MemoryOperationType::Write: _context->CallMemoryCallback(addr, value, CallbackType::PpuWrite); break;
default: break;
}
}
}

View File

@ -139,6 +139,7 @@ void SoundMixer::PlayAudioBuffer(uint32_t time)
}
switch(EmulationSettings::GetStereoFilter()) {
case StereoFilter::None: break;
case StereoFilter::Delay: _stereoDelay.ApplyFilter(_outputBuffer, sampleCount, _sampleRate); break;
case StereoFilter::Panning: _stereoPanning.ApplyFilter(_outputBuffer, sampleCount); break;
}

View File

@ -20,6 +20,7 @@ private:
if(_useChrForNametables) {
switch(GetMirroringType()) {
case MirroringType::FourScreens: break; //4-screen mirroring is not supported by this mapper
case MirroringType::Vertical: SetNametables(4, 5, 4, 5); break;
case MirroringType::Horizontal: SetNametables(4, 4, 5, 5); break;
case MirroringType::ScreenAOnly: SetNametables(4, 4, 4, 4); break;

View File

@ -32,7 +32,7 @@ else
PROFILE_USE_FLAG = -fprofile-instr-use=$(CURDIR)/PGOHelper/pgo.profdata
endif
GCCOPTIONS=-fPIC -Wall --std=c++14 -O3 $(MESENFLAGS) -Wno-switch
GCCOPTIONS=-fPIC -Wall --std=c++14 -O3 $(MESENFLAGS)
CCOPTIONS=-fPIC -Wall -O3 $(MESENFLAGS)
ifeq ($(MESENPLATFORM),x86)