diff --git a/Core/Assembler.cpp b/Core/Assembler.cpp index 177b1bbf..10cfc623 100644 --- a/Core/Assembler.cpp +++ b/Core/Assembler.cpp @@ -308,14 +308,13 @@ void Assembler::AssembleInstruction(LineData &lineData, uint16_t &instructionAdd if(lineData.OpCode.compare(opName[i]) == 0) { bool modeMatch = opMode == lineData.Mode; if(!modeMatch) { - if(lineData.Mode == AddrMode::Imp && opMode == AddrMode::Acc || - lineData.Mode == AddrMode::IndY && opMode == AddrMode::IndYW || - lineData.Mode == AddrMode::AbsY && opMode == AddrMode::AbsYW || - lineData.Mode == AddrMode::AbsX && opMode == AddrMode::AbsXW) { + if((lineData.Mode == AddrMode::Imp && opMode == AddrMode::Acc) || + (lineData.Mode == AddrMode::IndY && opMode == AddrMode::IndYW) || + (lineData.Mode == AddrMode::AbsY && opMode == AddrMode::AbsYW) || + (lineData.Mode == AddrMode::AbsX && opMode == AddrMode::AbsXW)) { modeMatch = true; - } else if(lineData.Mode == AddrMode::Abs && opMode == AddrMode::Rel || - lineData.Mode == AddrMode::Imm && opMode == AddrMode::Rel) { - + } else if((lineData.Mode == AddrMode::Abs && opMode == AddrMode::Rel) || + (lineData.Mode == AddrMode::Imm && opMode == AddrMode::Rel)) { if(lineData.OperandSize == 2) { if(lineData.Mode == AddrMode::Imm) { //Hardcoded jump values must be 1-byte diff --git a/Core/BmcHpxx.h b/Core/BmcHpxx.h index 80121491..6ea99a6a 100644 --- a/Core/BmcHpxx.h +++ b/Core/BmcHpxx.h @@ -45,8 +45,8 @@ protected: switch(_exRegs[0] & 0x03) { case 0: case 1: SelectChrPage8x(0, (_exRegs[2] & 0x3F) << 3); break; - case 2: SelectChrPage8x(0, ((_exRegs[2] & 0x3E) | _exRegs[4] & 0x01) << 3); break; - case 3: SelectChrPage8x(0, ((_exRegs[2] & 0x3C) | _exRegs[4] & 0x03) << 3); break; + case 2: SelectChrPage8x(0, ((_exRegs[2] & 0x3E) | (_exRegs[4] & 0x01)) << 3); break; + case 3: SelectChrPage8x(0, ((_exRegs[2] & 0x3C) | (_exRegs[4] & 0x03)) << 3); break; } } else { uint8_t base, mask; diff --git a/Core/Breakpoint.cpp b/Core/Breakpoint.cpp index 1f6ecd99..176fd1fa 100644 --- a/Core/Breakpoint.cpp +++ b/Core/Breakpoint.cpp @@ -23,9 +23,9 @@ bool Breakpoint::Matches(uint32_t memoryAddr, AddressTypeInfo &info) return (int32_t)memoryAddr >= _startAddr && (int32_t)memoryAddr <= _endAddr; } } else if( - _memoryType == DebugMemoryType::PrgRom && info.Type == AddressType::PrgRom || - _memoryType == DebugMemoryType::WorkRam && info.Type == AddressType::WorkRam || - _memoryType == DebugMemoryType::SaveRam && info.Type == AddressType::SaveRam + (_memoryType == DebugMemoryType::PrgRom && info.Type == AddressType::PrgRom) || + (_memoryType == DebugMemoryType::WorkRam && info.Type == AddressType::WorkRam) || + (_memoryType == DebugMemoryType::SaveRam && info.Type == AddressType::SaveRam) ) { if(_endAddr == -1) { return info.Address == _startAddr; @@ -50,9 +50,9 @@ bool Breakpoint::Matches(uint32_t memoryAddr, PpuAddressTypeInfo &info) return (int32_t)memoryAddr >= _startAddr && (int32_t)memoryAddr <= _endAddr; } } else if( - _memoryType == DebugMemoryType::ChrRam && info.Type == PpuAddressType::ChrRam || - _memoryType == DebugMemoryType::ChrRom && info.Type == PpuAddressType::ChrRom || - _memoryType == DebugMemoryType::PaletteMemory && info.Type == PpuAddressType::PaletteRam + (_memoryType == DebugMemoryType::ChrRam && info.Type == PpuAddressType::ChrRam) || + (_memoryType == DebugMemoryType::ChrRom && info.Type == PpuAddressType::ChrRom) || + (_memoryType == DebugMemoryType::PaletteMemory && info.Type == PpuAddressType::PaletteRam) ) { if(_endAddr == -1) { return info.Address == _startAddr; diff --git a/Core/Debugger.cpp b/Core/Debugger.cpp index 8d6ebeab..1a2c0a95 100644 --- a/Core/Debugger.cpp +++ b/Core/Debugger.cpp @@ -323,8 +323,8 @@ void Debugger::ProcessBreakpoints(BreakpointType type, OperationInfo &operationI Breakpoint &breakpoint = breakpoints[i]; if( type == BreakpointType::Global || - !isPpuBreakpoint && breakpoint.Matches(operationInfo.Address, info) || - isPpuBreakpoint && breakpoint.Matches(operationInfo.Address, ppuInfo) + (!isPpuBreakpoint && breakpoint.Matches(operationInfo.Address, info)) || + (isPpuBreakpoint && breakpoint.Matches(operationInfo.Address, ppuInfo)) ) { if(!breakpoint.HasCondition()) { processBreakpoint(breakpoint); diff --git a/Core/Disassembler.cpp b/Core/Disassembler.cpp index db545f57..222996ff 100644 --- a/Core/Disassembler.cpp +++ b/Core/Disassembler.cpp @@ -532,7 +532,7 @@ string Disassembler::GetCode(AddressTypeInfo &addressInfo, uint32_t endAddr, uin isVerifiedData = addressInfo.Type == AddressType::PrgRom && cdl->IsData(addr&mask); info = infoRef.get(); - if(!info && (disassembleUnidentifiedData && !isVerifiedData || disassembleVerifiedData && isVerifiedData)) { + if(!info && ((disassembleUnidentifiedData && !isVerifiedData) || (disassembleVerifiedData && isVerifiedData))) { dataType = isVerifiedData ? DataType::VerifiedData : (addressInfo.Type == AddressType::PrgRom ? DataType::UnidentifiedData : DataType::VerifiedCode); info = new DisassemblyInfo(source + (addr & mask), false); } else if(info) { diff --git a/Core/DrawStringCommand.h b/Core/DrawStringCommand.h index fd32e1c1..e5cc35ba 100644 --- a/Core/DrawStringCommand.h +++ b/Core/DrawStringCommand.h @@ -136,7 +136,7 @@ protected: int width = GetCharWidth(c); int rowOffset = (c == 'y' || c == 'g' || c == 'p' || c == 'q') ? 1 : 0; for(int j = 0; j < 8; j++) { - uint8_t rowData = (j == 7 && rowOffset == 0 || j == 0 && rowOffset == 1) ? 0 : _font[ch * 8 + 1 + j - rowOffset]; + uint8_t rowData = ((j == 7 && rowOffset == 0) || (j == 0 && rowOffset == 1)) ? 0 : _font[ch * 8 + 1 + j - rowOffset]; for(int i = 0; i < width; i++) { int drawFg = (rowData >> (7 - i)) & 0x01; DrawPixel(x + i, y + j, drawFg ? _color : _backColor); diff --git a/Core/ExpressionEvaluator.cpp b/Core/ExpressionEvaluator.cpp index 2bf2f09a..104238d8 100644 --- a/Core/ExpressionEvaluator.cpp +++ b/Core/ExpressionEvaluator.cpp @@ -61,7 +61,7 @@ bool ExpressionEvaluator::CheckSpecialTokens(string expression, size_t &pos, str size_t len = expression.size(); do { char c = std::tolower(expression[pos]); - if(c >= 'a' && c <= 'z' || c >= '0' && c <= '9' || c == '_' || c == '@') { + if((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '_' || c == '@') { //Only letters, numbers and underscore are allowed in code labels token += c; pos++; diff --git a/Core/FDS.cpp b/Core/FDS.cpp index 60b089d4..02341ff2 100644 --- a/Core/FDS.cpp +++ b/Core/FDS.cpp @@ -332,7 +332,7 @@ void FDS::UpdateCrc(uint8_t value) void FDS::WriteRegister(uint16_t addr, uint8_t value) { - if(!_diskRegEnabled && addr >= 0x4024 && addr <= 0x4026 || !_soundRegEnabled && addr >= 0x4040) { + if((!_diskRegEnabled && addr >= 0x4024 && addr <= 0x4026) || (!_soundRegEnabled && addr >= 0x4040)) { return; } diff --git a/Core/MMC3_121.h b/Core/MMC3_121.h index b1e465bc..6266ba55 100644 --- a/Core/MMC3_121.h +++ b/Core/MMC3_121.h @@ -49,7 +49,7 @@ protected: //Hack for Super 3-in-1 BaseMapper::SelectCHRPage(slot, page | ((_exRegs[3] & 0x80) << 1), memoryType); } else { - if(slot < 4 && _chrMode == 0 || slot >= 4 && _chrMode == 1) { + if((slot < 4 && _chrMode == 0) || (slot >= 4 && _chrMode == 1)) { page |= 0x100; } BaseMapper::SelectCHRPage(slot, page, memoryType); diff --git a/Core/MMC3_14.h b/Core/MMC3_14.h index 0ed35a2d..c2ba70ca 100644 --- a/Core/MMC3_14.h +++ b/Core/MMC3_14.h @@ -73,7 +73,7 @@ protected: uint8_t regNumber = ((((addr >> 12) & 0x07) - 3) << 1) + ((addr >> 1) & 0x01); bool lowBits = (addr & 0x01) == 0x00; if(lowBits) { - _vrcChrRegs[regNumber] = (_vrcChrRegs[regNumber] & 0xF0) | value & 0x0F; + _vrcChrRegs[regNumber] = (_vrcChrRegs[regNumber] & 0xF0) | (value & 0x0F); } else { _vrcChrRegs[regNumber] = (_vrcChrRegs[regNumber] & 0x0F) | ((value & 0x0F) << 4); } diff --git a/Core/Mapper225.h b/Core/Mapper225.h index 426703d6..8a5561f6 100644 --- a/Core/Mapper225.h +++ b/Core/Mapper225.h @@ -27,7 +27,7 @@ protected: SelectPRGPage(1, (prgPage & 0xFE) + 1); } - SelectCHRPage(0, addr & 0x3F | highBit); + SelectCHRPage(0, (addr & 0x3F) | highBit); SetMirroringType(addr & 0x2000 ? MirroringType::Horizontal : MirroringType::Vertical); } diff --git a/Core/Mapper234.h b/Core/Mapper234.h index f777b611..d2004b84 100644 --- a/Core/Mapper234.h +++ b/Core/Mapper234.h @@ -27,11 +27,11 @@ protected: if(_regs[0] & 0x40) { //NINA-03 mode SelectPRGPage(0, (_regs[0] & 0x0E) | (_regs[1] & 0x01)); - SelectCHRPage(0, ((_regs[0] << 2) & 0x38) | (_regs[1] >> 4) & 0x07); + SelectCHRPage(0, ((_regs[0] << 2) & 0x38) | ((_regs[1] >> 4) & 0x07)); } else { //CNROM mode SelectPRGPage(0, _regs[0] & 0x0F); - SelectCHRPage(0, ((_regs[0] << 2) & 0x3C) | (_regs[1] >> 4) & 0x03); + SelectCHRPage(0, ((_regs[0] << 2) & 0x3C) | ((_regs[1] >> 4) & 0x03)); } SetMirroringType(_regs[0] & 0x80 ? MirroringType::Horizontal : MirroringType::Vertical); diff --git a/Core/Nanjing.h b/Core/Nanjing.h index 66e52c26..ebc9cd39 100644 --- a/Core/Nanjing.h +++ b/Core/Nanjing.h @@ -91,7 +91,7 @@ public: //Copy protection stuff - based on FCEUX's implementation switch(addr & 0x7700) { case 0x5100: - return _registers[3] | _registers[1] | _registers[0] | _registers[2] ^ 0xFF; + return _registers[3] | _registers[1] | _registers[0] | (_registers[2] ^ 0xFF); case 0x5500: if(_toggle) { diff --git a/Core/NsfMapper.cpp b/Core/NsfMapper.cpp index bf2d78b0..29ab5527 100644 --- a/Core/NsfMapper.cpp +++ b/Core/NsfMapper.cpp @@ -327,7 +327,7 @@ void NsfMapper::WriteRegister(uint16_t addr, uint8_t value) _fdsAudio.WriteRegister(addr, value); } else if((_nsfHeader.SoundChips & NsfSoundChips::MMC5) && addr >= 0x5000 && addr <= 0x5015) { _mmc5Audio.WriteRegister(addr, value); - } else if((_nsfHeader.SoundChips & NsfSoundChips::Namco) && (addr >= 0x4800 && addr <= 0x4FFF || addr >= 0xF800 && addr <= 0xFFFF)) { + } else if((_nsfHeader.SoundChips & NsfSoundChips::Namco) && ((addr >= 0x4800 && addr <= 0x4FFF) || (addr >= 0xF800 && addr <= 0xFFFF))) { _namcoAudio.WriteRegister(addr, value); //Technically we should call this, but doing so breaks some NSFs diff --git a/Core/Sunsoft89.h b/Core/Sunsoft89.h index be3e9a92..ad64dd0a 100644 --- a/Core/Sunsoft89.h +++ b/Core/Sunsoft89.h @@ -16,7 +16,7 @@ protected: void WriteRegister(uint16_t addr, uint8_t value) override { SelectPRGPage(0, (value >> 4) & 0x07); - SelectCHRPage(0, value & 0x07 | ((value & 0x80) >> 4)); + SelectCHRPage(0, (value & 0x07) | ((value & 0x80) >> 4)); SetMirroringType((value & 0x08) == 0x08 ? MirroringType::ScreenBOnly : MirroringType::ScreenAOnly); } }; \ No newline at end of file diff --git a/Core/SunsoftFme7.h b/Core/SunsoftFme7.h index c7bd9432..42b77bf2 100644 --- a/Core/SunsoftFme7.h +++ b/Core/SunsoftFme7.h @@ -107,11 +107,11 @@ protected: break; case 0xE: - _irqCounter = _irqCounter & 0xFF00 | value; + _irqCounter = (_irqCounter & 0xFF00) | value; break; case 0xF: - _irqCounter = _irqCounter & 0xFF | (value << 8); + _irqCounter = (_irqCounter & 0xFF) | (value << 8); break; } break; diff --git a/Core/T230.h b/Core/T230.h index 430d5fb6..e922db25 100644 --- a/Core/T230.h +++ b/Core/T230.h @@ -64,7 +64,7 @@ protected: void WriteRegister(uint16_t addr, uint8_t value) override { - addr = addr & 0xF000 | (addr & 0x2A ? 0x02 : 0) | (addr & 0x15 ? 0x01 : 0); + addr = (addr & 0xF000) | (addr & 0x2A ? 0x02 : 0) | (addr & 0x15 ? 0x01 : 0); if(addr >= 0x9000 && addr <= 0x9001) { switch(value) { diff --git a/Core/Txc22000.h b/Core/Txc22000.h index be51c852..cc105e17 100644 --- a/Core/Txc22000.h +++ b/Core/Txc22000.h @@ -38,7 +38,7 @@ protected: virtual uint8_t ReadRegister(uint16_t addr) override { - return MemoryManager::GetOpenBus() & 0xCF | (_state << 4); + return (MemoryManager::GetOpenBus() & 0xCF) | (_state << 4); } void WriteRegister(uint16_t addr, uint8_t value) override diff --git a/Core/UnlDripGame.h b/Core/UnlDripGame.h index ddabbdbb..f585ecd6 100644 --- a/Core/UnlDripGame.h +++ b/Core/UnlDripGame.h @@ -93,6 +93,7 @@ protected: //Attribute fetches uint8_t bank; switch(GetMirroringType()) { + default: case MirroringType::ScreenAOnly: bank = 0; break; case MirroringType::ScreenBOnly: bank = 1; break; case MirroringType::Horizontal: bank = (addr & 0x800) ? 1 : 0; break; diff --git a/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs b/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs index a00056ee..dc61c418 100644 --- a/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs @@ -85,7 +85,6 @@ namespace Mesen.GUI.Debugger.Controls this.txtColor.Text = _paletteRam[paletteIndex].ToString("X2"); this.txtPaletteAddress.Text = (0x3F00 + paletteIndex).ToString("X4"); - Color selectedColor = Color.FromArgb(_palettePixelData[paletteIndex]); this.txtColorCodeHex.Text = GetHexColorString(); this.txtColorCodeRgb.Text = GetRgbColorString(); diff --git a/Linux/LinuxGameController.cpp b/Linux/LinuxGameController.cpp index 6e613d10..dc0a36c0 100644 --- a/Linux/LinuxGameController.cpp +++ b/Linux/LinuxGameController.cpp @@ -33,8 +33,8 @@ std::shared_ptr LinuxGameController::GetController(int devi return nullptr; } - if(libevdev_has_event_type(device, EV_KEY) && libevdev_has_event_code(device, EV_KEY, BTN_GAMEPAD) || - libevdev_has_event_type(device, EV_ABS) && libevdev_has_event_code(device, EV_ABS, ABS_X)) { + if((libevdev_has_event_type(device, EV_KEY) && libevdev_has_event_code(device, EV_KEY, BTN_GAMEPAD)) || + (libevdev_has_event_type(device, EV_ABS) && libevdev_has_event_code(device, EV_ABS, ABS_X))) { MessageManager::Log(std::string("[Input Connected] Name: ") + libevdev_get_name(device) + " Vendor: " + std::to_string(libevdev_get_id_vendor(device)) + " Product: " + std::to_string(libevdev_get_id_product(device))); return std::shared_ptr(new LinuxGameController(deviceID, fd, device)); } else { @@ -67,7 +67,8 @@ LinuxGameController::LinuxGameController(int deviceID, int fileDescriptor, libev timeout.tv_sec = 0; timeout.tv_usec = 100000; - if(rc = select((int)_fd+1, &readSet, nullptr, nullptr, &timeout)) { + rc = select((int)_fd+1, &readSet, nullptr, nullptr, &timeout); + if(rc) { do { struct input_event ev; rc = libevdev_next_event(_device, LIBEVDEV_READ_FLAG_NORMAL, &ev); diff --git a/makefile b/makefile index 1e231fc5..2f5cf2fb 100644 --- a/makefile +++ b/makefile @@ -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-parentheses -Wno-switch +GCCOPTIONS=-fPIC -Wall --std=c++14 -O3 $(MESENFLAGS) -Wno-switch CCOPTIONS=-fPIC -Wall -O3 $(MESENFLAGS) ifeq ($(MESENPLATFORM),x86)