misc redundant code removal, empty argument in object intiializer, redundant elses

This commit is contained in:
adelikat 2020-02-25 13:23:46 -06:00
parent 35697aaefa
commit 185dbda19a
11 changed files with 82 additions and 105 deletions

View File

@ -57,7 +57,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
CoreComm.NominalHeight = 160;
PutSettings(_settings);
_tracer = new TraceBuffer()
_tracer = new TraceBuffer
{
Header = "ARM7: PC, machine code, mnemonic, operands, registers"
};

View File

@ -22,10 +22,10 @@
CDLog_MapResults MapMemoryCM(ushort address, bool write)
{
if (address < 0x4000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = address };
else if (address < 0x8000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank1 * BankSize) + (address & BankSizeMask) };
else if (address < 0xC000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank2 * BankSize) + (address & BankSizeMask) };
else return new CDLog_MapResults() { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
if (address < 0x4000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = address };
if (address < 0x8000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank1 * BankSize) + (address & BankSizeMask) };
if (address < 0xC000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank2 * BankSize) + (address & BankSizeMask) };
return new CDLog_MapResults { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
}
void WriteMemoryCM(ushort address, byte value)
@ -74,21 +74,22 @@
CDLog_MapResults MapMemoryCMRam(ushort address, bool write)
{
if (address < 0x4000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = address };
else if (address < 0x8000)
if (address < 0x4000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = address };
if (address < 0x8000)
{
if (address >= 0x6000 && RomBank3 == 1)
return new CDLog_MapResults() { Type = CDLog_AddrType.CartRAM, Address = address & 0x1FFF };
else
return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank1 * BankSize) + (address & BankSizeMask) };
return new CDLog_MapResults { Type = CDLog_AddrType.CartRAM, Address = address & 0x1FFF };
return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank1 * BankSize) + (address & BankSizeMask) };
}
else if (address < 0xC000)
if (address < 0xC000)
{
if (address >= 0xA000 && RomBank3 == 1)
return new CDLog_MapResults() { Type = CDLog_AddrType.CartRAM, Address = address & 0x1FFF };
return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank2 * BankSize) + (address & BankSizeMask) };
return new CDLog_MapResults { Type = CDLog_AddrType.CartRAM, Address = address & 0x1FFF };
return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank2 * BankSize) + (address & BankSizeMask) };
}
else return new CDLog_MapResults() { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
return new CDLog_MapResults { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
}
void WriteMemoryCMRam(ushort address, byte value)

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Cores.Sega.MasterSystem
using System;
namespace BizHawk.Emulation.Cores.Sega.MasterSystem
{
public partial class SMS
{
@ -59,30 +61,25 @@
{
if ((Port3E & 0x48) == 0x48) // cart and bios disabled, return empty bus
return new CDLog_MapResults();
else if (BiosMapped && BiosRom != null)
if (BiosMapped && BiosRom != null)
return new CDLog_MapResults(); //bios tracking of CDL is not supported
else if (address < 1024)
return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = address };
else if (address < 0x4000)
return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank0 * BankSize) + address };
else if (address < 0x8000)
return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank1 * BankSize) + (address & BankSizeMask) };
else
if (address < 1024)
return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = address };
if (address < 0x4000)
return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank0 * BankSize) + address };
if (address < 0x8000)
return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank1 * BankSize) + (address & BankSizeMask) };
switch (SaveRamBank)
{
switch (SaveRamBank)
{
case 0: return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank2 * BankSize) + (address & BankSizeMask) };
case 1: return new CDLog_MapResults(); // a serial IO port
case 2: return new CDLog_MapResults(); // a serial IO port
default:
return new CDLog_MapResults() { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
}
case 0: return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank2 * BankSize) + (address & BankSizeMask) };
case 1: return new CDLog_MapResults(); // a serial IO port
case 2: return new CDLog_MapResults(); // a serial IO port
default:
return new CDLog_MapResults { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
}
}
else
{
return new CDLog_MapResults() { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
}
return new CDLog_MapResults { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
}
void WriteMemoryEEPROM(ushort address, byte value)
@ -98,7 +95,8 @@
EEPROM.Write(value, SaveRAM);
return;
}
else System.Console.WriteLine("Game attempt to use SRAM but SRAM not present");
Console.WriteLine("Game attempt to use SRAM but SRAM not present");
}
if (address >= 0xFFFC)
@ -114,7 +112,6 @@
else if (address == 0xFFFD) RomBank0 = (byte)(value % RomBanks);
else if (address == 0xFFFE) RomBank1 = (byte)(value % RomBanks);
else if (address == 0xFFFF) RomBank2 = (byte)(value % RomBanks);
return;
}
}

View File

@ -5,7 +5,7 @@
byte[] ExtRam;
int ExtRamMask;
byte ReadMemoryExt(ushort address)
private byte ReadMemoryExt(ushort address)
{
byte ret;
@ -21,12 +21,12 @@
CDLog_MapResults MapMemoryExt(ushort address, bool write)
{
if (address < 0x8000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = address };
else if (address < 0xC000) return new CDLog_MapResults() { Type = CDLog_AddrType.CartRAM, Address = address & ExtRamMask };
else return new CDLog_MapResults() { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
if (address < 0x8000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = address };
if (address < 0xC000) return new CDLog_MapResults { Type = CDLog_AddrType.CartRAM, Address = address & ExtRamMask };
return new CDLog_MapResults { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
}
void WriteMemoryExt(ushort address, byte value)
private void WriteMemoryExt(ushort address, byte value)
{
if (address < 0xC000 && address >= 0x8000)
ExtRam[address & ExtRamMask] = value;

View File

@ -5,8 +5,7 @@
// Bank 0: Fixed - Maps $0000 - $3FFF
// Bank 1: Fixed - Maps $4000 - $7FFF
// Bank 2: Control Address $A000 - Maps $8000 - $BFFF
byte ReadMemoryKR(ushort address)
private byte ReadMemoryKR(ushort address)
{
if (address < 0xC000)
{
@ -19,31 +18,29 @@
{
return BiosRom[address];
}
else
{
return BiosRom[(Bios_bank * BankSize) + (address & BankSizeMask)];
}
return BiosRom[(Bios_bank * BankSize) + (address & BankSizeMask)];
}
else
if (address < 0x8000)
{
if (address < 0x8000) return RomData[address & 0x7FFF];
else return RomData[(RomBank2 * BankSize) + (address & BankSizeMask)];
return RomData[address & 0x7FFF];
}
return RomData[(RomBank2 * BankSize) + (address & BankSizeMask)];
}
else
{
return SystemRam[address & RamSizeMask];
}
return SystemRam[address & RamSizeMask];
}
CDLog_MapResults MapMemoryKR(ushort address, bool write)
{
if (address < 0x8000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = address & 0x7FFF };
else if (address < 0xC000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank2 * BankSize) + (address & BankSizeMask) };
else return new CDLog_MapResults() { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
if (address < 0x8000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = address & 0x7FFF };
if (address < 0xC000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank2 * BankSize) + (address & BankSizeMask) };
return new CDLog_MapResults { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
}
void WriteMemoryKR(ushort address, byte value)
private void WriteMemoryKR(ushort address, byte value)
{
if (address >= 0xC000)
SystemRam[address & RamSizeMask] = value;
@ -71,7 +68,7 @@
// MSX mapper & Nemesis mapper
// ======================================================================
byte ReadMemoryMSX(ushort address)
private byte ReadMemoryMSX(ushort address)
{
if (address < 0x4000) return RomData[address & 0x3FFF];
if (address < 0x6000) return RomData[(RomBank0 * 0x2000) + (address & 0x1FFF)];
@ -83,12 +80,12 @@
CDLog_MapResults MapMemoryMSX(ushort address, bool write)
{
if (address < 0x4000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = address & 0x3FFF };
if (address < 0x6000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank0 * 0x2000) + (address & 0x1FFF) };
if (address < 0x8000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank1 * 0x2000) + (address & 0x1FFF) };
if (address < 0xA000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank2 * 0x2000) + (address & 0x1FFF) };
if (address < 0xC000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank3 * 0x2000) + (address & 0x1FFF) };
else return new CDLog_MapResults() { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
if (address < 0x4000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = address & 0x3FFF };
if (address < 0x6000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank0 * 0x2000) + (address & 0x1FFF) };
if (address < 0x8000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank1 * 0x2000) + (address & 0x1FFF) };
if (address < 0xA000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank2 * 0x2000) + (address & 0x1FFF) };
if (address < 0xC000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank3 * 0x2000) + (address & 0x1FFF) };
return new CDLog_MapResults { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
}
byte ReadMemoryNemesis(ushort address)
@ -104,13 +101,13 @@
CDLog_MapResults MapMemoryNemesis(ushort address, bool write)
{
if (address < 0x2000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (15 * 0x2000) + (address & 0x1FFF) };
if (address < 0x4000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = address & 0x3FFF };
if (address < 0x6000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank0 * 0x2000) + (address & 0x1FFF) };
if (address < 0x8000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank1 * 0x2000) + (address & 0x1FFF) };
if (address < 0xA000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank2 * 0x2000) + (address & 0x1FFF) };
if (address < 0xC000) return new CDLog_MapResults() { Type = CDLog_AddrType.ROM, Address = (RomBank3 * 0x2000) + (address & 0x1FFF) };
else return new CDLog_MapResults() { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
if (address < 0x2000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (15 * 0x2000) + (address & 0x1FFF) };
if (address < 0x4000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = address & 0x3FFF };
if (address < 0x6000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank0 * 0x2000) + (address & 0x1FFF) };
if (address < 0x8000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank1 * 0x2000) + (address & 0x1FFF) };
if (address < 0xA000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank2 * 0x2000) + (address & 0x1FFF) };
if (address < 0xC000) return new CDLog_MapResults { Type = CDLog_AddrType.ROM, Address = (RomBank3 * 0x2000) + (address & 0x1FFF) };
return new CDLog_MapResults { Type = CDLog_AddrType.MainRAM, Address = address & RamSizeMask };
}
void WriteMemoryMSX(ushort address, byte value)

View File

@ -35,7 +35,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
private void ConnectTracer()
{
trace_cb = new OctoshockDll.ShockCallback_Trace(ShockTraceCallback);
Tracer = new TraceBuffer() { Header = TraceHeader };
Tracer = new TraceBuffer { Header = TraceHeader };
ServiceProvider = new BasicServiceProvider(this);
(ServiceProvider as BasicServiceProvider).Register<ITraceable>(Tracer);
}

View File

@ -1,10 +1,4 @@
using System;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections.Generic;
namespace BizHawk.Emulation.DiscSystem
namespace BizHawk.Emulation.DiscSystem
{
partial class DiscMountJob
{
@ -41,7 +35,7 @@ namespace BizHawk.Emulation.DiscSystem
//this is the sole sector synthesizer we'll need
var synth = new SS_MednaDisc();
OUT_Disc.SynthProvider = new SimpleSectorSynthProvider() { SS = synth };
OUT_Disc.SynthProvider = new SimpleSectorSynthProvider { SS = synth };
//ADR (q-Mode) is necessarily 0x01 for a RawTOCEntry
const int kADR = 1;
@ -87,7 +81,7 @@ namespace BizHawk.Emulation.DiscSystem
disc.RawTOCEntries.Add(new RawTOCEntry { QData = q });
}
//synth A0 and A1 entries (indicating first and last recorded tracks and also session type)
// synth A0 and A1 entries (indicating first and last recorded tracks and also session type)
var qA0 = new SubchannelQ
{
q_status = SubchannelQ.ComputeStatus(kADR, kUnknownControl),
@ -118,7 +112,6 @@ namespace BizHawk.Emulation.DiscSystem
q_crc = 0, //meaningless
};
disc.RawTOCEntries.Add(new RawTOCEntry { QData = qA1 });
}
}
}

View File

@ -1,9 +1,5 @@
using System;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections.Generic;
using BizHawk.Emulation.DiscSystem.CUE;
namespace BizHawk.Emulation.DiscSystem
@ -68,11 +64,11 @@ namespace BizHawk.Emulation.DiscSystem
//generate toc and structure:
//1. TOCRaw from RawTOCEntries
var tocSynth = new Synthesize_DiscTOC_From_RawTOCEntries_Job() { Entries = OUT_Disc.RawTOCEntries };
var tocSynth = new Synthesize_DiscTOC_From_RawTOCEntries_Job { Entries = OUT_Disc.RawTOCEntries };
tocSynth.Run();
OUT_Disc.TOC = tocSynth.Result;
//2. Structure from TOCRaw
var structureSynth = new Synthesize_DiscStructure_From_DiscTOC_Job() { IN_Disc = OUT_Disc, TOCRaw = OUT_Disc.TOC };
var structureSynth = new Synthesize_DiscStructure_From_DiscTOC_Job { IN_Disc = OUT_Disc, TOCRaw = OUT_Disc.TOC };
structureSynth.Run();
OUT_Disc.Structure = structureSynth.Result;
@ -80,7 +76,7 @@ namespace BizHawk.Emulation.DiscSystem
//currently, we let mednafen take care of its own leadout track (we'll make that controllable later)
if (IN_DiscInterface != DiscInterface.MednaDisc)
{
var ss_leadout = new SS_Leadout()
var ss_leadout = new SS_Leadout
{
SessionNumber = 1,
Policy = IN_DiscMountPolicy
@ -199,7 +195,7 @@ namespace BizHawk.Emulation.DiscSystem
//setup the lowest level synth provider
if (OUT_Disc != null)
{
var sssp = new ArraySectorSynthProvider()
var sssp = new ArraySectorSynthProvider
{
Sectors = OUT_Disc._Sectors,
FirstLBA = -150

View File

@ -1,11 +1,4 @@
using System;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections.Generic;
//TODO - generate correct Q subchannel CRC
// TODO - generate correct Q subchannel CRC
namespace BizHawk.Emulation.DiscSystem
{
class ApplySBIJob
@ -29,7 +22,7 @@ namespace BizHawk.Emulation.DiscSystem
int lba = sbi.ABAs[i] - 150;
//create a synthesizer which can return the patched data
var ss_patchq = new SS_PatchQ() { Original = disc._Sectors[lba + 150] };
var ss_patchq = new SS_PatchQ { Original = disc._Sectors[lba + 150] };
byte[] subQbuf = ss_patchq.Buffer_SubQ;
//read the old subcode

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
namespace BizHawk.Emulation.DiscSystem
{
@ -26,7 +25,7 @@ namespace BizHawk.Emulation.DiscSystem
throw new InvalidOperationException($"Unsupported: {nameof(TOCRaw.FirstRecordedTrackNumber)} != 1");
//add a lead-in track
session.Tracks.Add(new DiscStructure.Track()
session.Tracks.Add(new DiscStructure.Track
{
Number = 0,
Control = EControlQ.None, //we'll set this later
@ -37,7 +36,7 @@ namespace BizHawk.Emulation.DiscSystem
for (int i = 0; i < ntracks; i++)
{
var item = TOCRaw.TOCItems[i + 1];
var track = new DiscStructure.Track()
var track = new DiscStructure.Track
{
Number = i + 1,
Control = item.Control,
@ -61,7 +60,7 @@ namespace BizHawk.Emulation.DiscSystem
}
//add lead-out track
session.Tracks.Add(new DiscStructure.Track()
session.Tracks.Add(new DiscStructure.Track
{
Number = 0xA0, //right?
//kind of a guess, but not completely

View File

@ -326,6 +326,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mainform/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=mainmemory/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=mame/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=mednadisc/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mednafen/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mednafen_0027s/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=minipsf/@EntryIndexedValue">True</s:Boolean>