Skip to content

Commit

Permalink
Code style nitpicks
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshiRulz committed May 30, 2024
1 parent 1d84b5c commit 9ee3830
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 29 deletions.
5 changes: 3 additions & 2 deletions src/BizHawk.Client.Common/RomLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,9 @@ private void LoadOther(
);
return;
}

if (_config.PreferredCores[game.System] is CoreNames.Bsnes or CoreNames.Bsnes115 or CoreNames.SubBsnes115)
static bool IsPreferredCoreSGB(Config config)
=> config.PreferredCores[VSystemID.Raw.GB] is CoreNames.Bsnes or CoreNames.Bsnes115 or CoreNames.SubBsnes115;
if (IsPreferredCoreSGB(_config))
{
game.System = VSystemID.Raw.SGB;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ public enum ConsoleModeType
GB,
GBC,
GBA,
SGB2
SGB2,
}

[DisplayName("Console Mode")]
[Description("Pick which console to run, 'Auto' chooses from ROM header; 'GB', 'GBC', 'GBA', and 'SGB2' chooses the respective system.")]
[Description("Which console to emulate ('Auto' picks based on the rom header)")]
[DefaultValue(ConsoleModeType.Auto)]
public ConsoleModeType ConsoleMode { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,13 @@ public bool FrameAdvance(IController controller, bool render, bool rendersound =
}
if (IsAnySgb)
{
if (IsSgb(i)) // all SGB borders will be displayed when any of them has the option enabled
// all SGB borders will be displayed when any of them has the option enabled
if (IsSgb(i))
{
if (LibGambatte.gambatte_updatescreenborder(_linkedCores[i].GambatteState, svbuff + (i * 256), sgbPitch) != 0)
if (LibGambatte.gambatte_updatescreenborder(
_linkedCores[i].GambatteState,
svbuff + (i * 256),
sgbPitch) is not 0)
{
throw new InvalidOperationException($"{nameof(LibGambatte.gambatte_updatescreenborder)}() returned non-zero (border error???)");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
{
public partial class GambatteLink : IVideoProvider
{
public int VirtualWidth => (ShowAnyBorder() ? 256 : 160) * _numCores;
public int VirtualWidth
=> (ShowAnyBorder() ? 256 : 160) * _numCores;

public int VirtualHeight => ShowAnyBorder() ? 224 : 144;
public int VirtualHeight
=> ShowAnyBorder() ? 224 : 144;

public int BufferWidth => (ShowAnyBorder() ? 256 : 160) * _numCores;
public int BufferWidth
=> VirtualWidth;

public int BufferHeight => ShowAnyBorder() ? 224 : 144;
public int BufferHeight
=> VirtualHeight;

public int VsyncNumerator => _linkedCores[P1].VsyncNumerator;

Expand All @@ -21,9 +25,7 @@ public partial class GambatteLink : IVideoProvider
private readonly int[] FrameBuffer;

public int[] GetVideoBuffer()
{
return ShowAnyBorder() ? SgbVideoBuffer : VideoBuffer;
}
=> ShowAnyBorder() ? SgbVideoBuffer : VideoBuffer;

private readonly int[] VideoBuffer;

Expand All @@ -40,12 +42,6 @@ private int[] CreateVideoBuffer()
}

private int[] CreateSGBVideoBuffer()
{
if (IsAnySgb)
{
return new int[256 * _numCores * 224];
}
return null;
}
=> IsAnySgb ? new int[256 * _numCores * 224] : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public GambatteLink(CoreLoadParameters<GambatteLinkSettings, GambatteLinkSyncSet
_linkedCores[i] = new Gameboy(lp.Comm, lp.Roms[i].Game, lp.Roms[i].RomData, _settings._linkedSettings[i], _syncSettings._linkedSyncSettings[i], lp.DeterministicEmulationRequested);
_linkedCores[i].ConnectInputCallbackSystem(_inputCallbacks);
_linkedCores[i].ConnectMemoryCallbackSystem(_memoryCallbacks, i);
IsAnySgb = IsAnySgb || IsSgb(i);
IsAnySgb |= IsSgb(i);
_linkedConts[i] = new SaveController(Gameboy.CreateControllerDefinition(sgb: IsSgb(i), sub: false, tilt: false, rumble: false, remote: false));
_linkedBlips[i] = new BlipBuffer(1024);
_linkedBlips[i].SetRates(2097152 * 2, 44100);
Expand Down Expand Up @@ -174,20 +174,17 @@ static void AddGBButtonsForPlayer(int p, ControllerDefinition ret)
}

private bool IsSgb(int i)
{
return _linkedCores[i].IsSgb;
}
=> _linkedCores[i].IsSgb;

public bool IsAnySgb { get; set; }
public bool IsAnySgb { get; private set; }

private bool ShowBorder(int i)
{
return IsSgb(i) && _settings._linkedSettings[i].ShowBorder;
}
=> IsSgb(i) && _settings._linkedSettings[i].ShowBorder;

public bool ShowAnyBorder()
{
return Enumerable.Range(0, _numCores).Any(ShowBorder);
for (var i = 0; i < _numCores; i++) if (ShowBorder(i)) return true;
return false;
}

private const int P1 = 0;
Expand Down

0 comments on commit 9ee3830

Please sign in to comment.