Enable SA1139 and fix noncompliance

"Use literal suffix notation instead of casting"
This commit is contained in:
YoshiRulz 2020-01-25 07:55:48 +10:00
parent 14d088f907
commit bfde89b9f3
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
14 changed files with 27 additions and 32 deletions

View File

@ -91,7 +91,7 @@ namespace BizHawk.Client.Common
[LuaMethod("set", "Sets the bit 'pos' in 'num'")] [LuaMethod("set", "Sets the bit 'pos' in 'num'")]
public static uint Set(uint num, int pos) public static uint Set(uint num, int pos)
{ {
return (uint)(num | (uint)1 << pos); return (uint)(num | 1U << pos);
} }
[LuaMethodExample("local lobitcle = bit.clear( 25, 35 );")] [LuaMethodExample("local lobitcle = bit.clear( 25, 35 );")]

View File

@ -20,10 +20,10 @@ namespace BizHawk.Client.Common
["NES_PAL"] = 50.006977968268290849, ["NES_PAL"] = 50.006977968268290849,
["FDS"] = 60.098813897440515532, ["FDS"] = 60.098813897440515532,
["FDS_PAL"] = 50.006977968268290849, ["FDS_PAL"] = 50.006977968268290849,
["SNES"] = (double)21477272 / (4 * 341 * 262), // 60.098475521 ["SNES"] = 21477272.0 / (4 * 341 * 262), // 60.098475521
["SNES_PAL"] = (double)21281370 / (4 * 341 * 312), // 50.0069789082 ["SNES_PAL"] = 21281370.0 / (4 * 341 * 312), // 50.0069789082
["SGB"] = (double)21477272 / (4 * 341 * 262), // 60.098475521 ["SGB"] = 21477272.0 / (4 * 341 * 262), // 60.098475521
["SGB_PAL"] = (double)21281370 / (4 * 341 * 312), // 50.0069789082 ["SGB_PAL"] = 21281370.0 / (4 * 341 * 312), // 50.0069789082
["PCE"] = (7159090.90909090 / 455 / 263), // 59.8261054535 ["PCE"] = (7159090.90909090 / 455 / 263), // 59.8261054535
["PCECD"] = (7159090.90909090 / 455 / 263), // 59.8261054535 ["PCECD"] = (7159090.90909090 / 455 / 263), // 59.8261054535
["SMS"] = (3579545 / 262.0 / 228.0), // 59.9227434043 ["SMS"] = (3579545 / 262.0 / 228.0), // 59.9227434043

View File

@ -69,7 +69,7 @@ namespace BizHawk.Client.Common
if (RewindActive) if (RewindActive)
{ {
var capacity = Global.Config.Rewind_BufferSize * (long)1024 * 1024; var capacity = Global.Config.Rewind_BufferSize * 1048576L;
_rewindBuffer = new StreamBlobDatabase(Global.Config.Rewind_OnDisk, capacity, BufferManage); _rewindBuffer = new StreamBlobDatabase(Global.Config.Rewind_OnDisk, capacity, BufferManage);

View File

@ -50,20 +50,20 @@ namespace BizHawk.Client.EmuHawk
private void WriteHeaders() private void WriteHeaders()
{ {
_file.Write(Encoding.ASCII.GetBytes("RIFF")); // ChunkID _file.Write(Encoding.ASCII.GetBytes("RIFF")); // ChunkID
_file.Write((uint)0); // ChunkSize _file.Write(0U); // ChunkSize
_file.Write(Encoding.ASCII.GetBytes("WAVE")); // Format _file.Write(Encoding.ASCII.GetBytes("WAVE")); // Format
_file.Write(Encoding.ASCII.GetBytes("fmt ")); // SubchunkID _file.Write(Encoding.ASCII.GetBytes("fmt ")); // SubchunkID
_file.Write((uint)16); // SubchunkSize _file.Write(16U); // SubchunkSize
_file.Write((ushort)1); // AudioFormat (PCM) _file.Write((ushort)1U); // AudioFormat (PCM)
_file.Write((ushort)_numChannels); // NumChannels _file.Write((ushort)_numChannels); // NumChannels
_file.Write((uint)_sampleRate); // SampleRate _file.Write((uint)_sampleRate); // SampleRate
_file.Write((uint)(_sampleRate * _numChannels * 2)); // ByteRate _file.Write((uint)(_sampleRate * _numChannels * 2)); // ByteRate
_file.Write((ushort)(_numChannels * 2)); // BlockAlign _file.Write((ushort)(_numChannels * 2)); // BlockAlign
_file.Write((ushort)16); // BitsPerSample _file.Write((ushort)16U); // BitsPerSample
_file.Write(Encoding.ASCII.GetBytes("data")); // SubchunkID _file.Write(Encoding.ASCII.GetBytes("data")); // SubchunkID
_file.Write((uint)0); // SubchunkSize _file.Write(0U); // SubchunkSize
} }
/// <summary> /// <summary>

View File

@ -59,7 +59,7 @@ namespace BizHawk.Client.EmuHawk
return _maxSize.Value; return _maxSize.Value;
} }
return ((long)1 << (4 * MaxLength)) - 1; return (1L << (4 * MaxLength)) - 1;
} }
public override void ResetText() public override void ResetText()

View File

@ -22,7 +22,7 @@ namespace BizHawk.Client.EmuHawk
private void StateHistorySettings_Load(object sender, EventArgs e) private void StateHistorySettings_Load(object sender, EventArgs e)
{ {
_stateSizeMb = Statable.SaveStateBinary().Length / (decimal)1024 / 1024; _stateSizeMb = Statable.SaveStateBinary().Length / 1048576.0M;
MemCapacityNumeric.Maximum = 1024 * 8; MemCapacityNumeric.Maximum = 1024 * 8;
MemCapacityNumeric.Minimum = _stateSizeMb + 1; MemCapacityNumeric.Minimum = _stateSizeMb + 1;

View File

@ -72,25 +72,25 @@ namespace BizHawk.Common
AddW<sbyte>(r => r.Write((sbyte)0)); AddW<sbyte>(r => r.Write((sbyte)0));
AddR<byte>(r => r.ReadByte()); AddR<byte>(r => r.ReadByte());
AddW<byte>(r => r.Write((byte)0)); AddW<byte>(r => r.Write((byte)0U));
AddR<short>(r => r.ReadInt16()); AddR<short>(r => r.ReadInt16());
AddW<short>(r => r.Write((short)0)); AddW<short>(r => r.Write((short)0));
AddR<ushort>(r => r.ReadUInt16()); AddR<ushort>(r => r.ReadUInt16());
AddW<ushort>(r => r.Write((ushort)0)); AddW<ushort>(r => r.Write((ushort)0U));
AddR<int>(r => r.ReadInt32()); AddR<int>(r => r.ReadInt32());
AddW<int>(r => r.Write((int)0)); AddW<int>(r => r.Write(0));
AddR<uint>(r => r.ReadUInt32()); AddR<uint>(r => r.ReadUInt32());
AddW<uint>(r => r.Write((uint)0)); AddW<uint>(r => r.Write(0U));
AddR<long>(r => r.ReadInt64()); AddR<long>(r => r.ReadInt64());
AddW<long>(r => r.Write((long)0)); AddW<long>(r => r.Write(0L));
AddR<ulong>(r => r.ReadUInt64()); AddR<ulong>(r => r.ReadUInt64());
AddW<ulong>(r => r.Write((ulong)0)); AddW<ulong>(r => r.Write(0UL));
} }
#endregion #endregion

View File

@ -210,9 +210,7 @@ namespace BizHawk.Emulation.Cores.Calculators
TIM_mult = ((value & 0x10) == 0x10) ? 1800 : 1620; TIM_mult = ((value & 0x10) == 0x10) ? 1800 : 1620;
TIM_hit = (int)Math.Floor((double)TIM_mult / (3 + TIM_frq * 2)); TIM_hit = (int) Math.Floor(6000000.0 / Math.Floor((double) TIM_mult / (2 * TIM_frq + 3)));
TIM_hit = (int)Math.Floor((double)6000000 / TIM_hit);
// Bit 0 is some form of memory mapping // Bit 0 is some form of memory mapping

View File

@ -430,7 +430,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
int end = _machine.TapeDevice.DataBlocks[_machine.TapeDevice.CurrentDataBlockIndex].DataPeriods.Count; int end = _machine.TapeDevice.DataBlocks[_machine.TapeDevice.CurrentDataBlockIndex].DataPeriods.Count;
double p = 0; double p = 0;
if (end != 0) if (end != 0)
p = ((double)pos / (double)end) * (double)100; p = ((double)pos / (double)end) * 100.0;
sb.Append(p.ToString("N0") + "%"); sb.Append(p.ToString("N0") + "%");
SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Tape); SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Tape);
@ -454,7 +454,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
} }
// work out overall position within the tape // work out overall position within the tape
p = 0; p = 0;
p = ((double)ourPos / (double)cnt) * (double)100; p = ((double)ourPos / (double)cnt) * 100.0;
sb.Append(p.ToString("N0") + "%"); sb.Append(p.ToString("N0") + "%");
SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Tape); SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Tape);
} }

View File

@ -74,7 +74,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
tb.MetaData = db.MetaData; tb.MetaData = db.MetaData;
tb.PauseInMS = db.PauseInMS; tb.PauseInMS = db.PauseInMS;
double multiplier = (double)4 / (double)3.5; double multiplier = 8.0 / 7.0;
//double cycleScale = ((40 << 16) / 35); //double cycleScale = ((40 << 16) / 35);
double origPeriods = db.DataPeriods.Count(); double origPeriods = db.DataPeriods.Count();

View File

@ -401,7 +401,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
int end = _machine.TapeDevice.DataBlocks[_machine.TapeDevice.CurrentDataBlockIndex].DataPeriods.Count; int end = _machine.TapeDevice.DataBlocks[_machine.TapeDevice.CurrentDataBlockIndex].DataPeriods.Count;
double p = 0; double p = 0;
if (end != 0) if (end != 0)
p = ((double)pos / (double)end) * (double)100; p = ((double)pos / (double)end) * 100.0;
sb.Append(p.ToString("N0") + "%"); sb.Append(p.ToString("N0") + "%");
SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Tape); SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Tape);
@ -425,7 +425,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
} }
// work out overall position within the tape // work out overall position within the tape
p = 0; p = 0;
p = ((double)ourPos / (double)cnt) * (double)100; p = ((double)ourPos / (double)cnt) * 100.0;
sb.Append(p.ToString("N0") + "%"); sb.Append(p.ToString("N0") + "%");
SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Tape); SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Tape);
} }

View File

@ -35,7 +35,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
private void SetupAudio() private void SetupAudio()
{ {
Period = (double)1 / SampleRate; Period = 1.0 / SampleRate;
SamplesPerFrame = (int)(SampleRate / refreshRate); SamplesPerFrame = (int)(SampleRate / refreshRate);
CyclesPerSample = (double)ClockPerFrame / (double)SamplesPerFrame; CyclesPerSample = (double)ClockPerFrame / (double)SamplesPerFrame;
SampleBuffer = new short[SamplesPerFrame]; SampleBuffer = new short[SamplesPerFrame];

View File

@ -232,7 +232,7 @@ namespace BizHawk.Emulation.Cores.Libretro
// todo: more precise? // todo: more precise?
uint spsnum = (uint)sps * 1000; uint spsnum = (uint)sps * 1000;
uint spsden = (uint)1000; uint spsden = 1000U;
resampler = new SpeexResampler(SpeexResampler.Quality.QUALITY_DESKTOP, 44100 * spsden, spsnum, (uint)sps, 44100, null, null); resampler = new SpeexResampler(SpeexResampler.Quality.QUALITY_DESKTOP, 44100 * spsden, spsnum, (uint)sps, 44100, null, null);
} }

View File

@ -157,9 +157,6 @@
<!-- Elements should have the same indentation --> <!-- Elements should have the same indentation -->
<Rule Id="SA1137" Action="Hidden" /> <Rule Id="SA1137" Action="Hidden" />
<!-- Use literal suffix notation instead of casting -->
<Rule Id="SA1139" Action="Hidden" />
</Rules> </Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.OrderingRules"> <Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.OrderingRules">