Misc. cleanup of testroms projects

This commit is contained in:
YoshiRulz 2022-01-28 08:25:20 +10:00
parent da06bd36d0
commit 7392df29d9
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
4 changed files with 18 additions and 22 deletions

View File

@ -139,7 +139,7 @@ namespace BizHawk.Tests.Testroms.GB.GambatteSuite
{
static bool GlyphMatches(Bitmap b, int xOffset, byte v)
{
// `(x, 0)` is the top-left of an 8x8 square of pixels to read from `b`, which is compared against the glyph for the nybble `v`
// `(xOffset, 0)` is the top-left of an 8x8 square of pixels to read from `b`, which is compared against the glyph for the nybble `v`
bool GlyphRowMatches(int y)
{
byte rowAsByte = 0;

View File

@ -37,17 +37,17 @@ namespace BizHawk.Tests.Testroms.GB
Variant = variant;
}
public override readonly string ToString()
public readonly override string ToString()
=> $"{Variant} in {CoreName}{(UseBIOS ? string.Empty : " (no BIOS)")}";
}
private static readonly GambatteSettings GambatteSettings = new() { CGBColors = GBColors.ColorType.vivid };
private static readonly GambatteSyncSettings GambatteSyncSettings_GB_NOBIOS = new() { ConsoleMode = GambatteSyncSettings.ConsoleModeType.GB, FrameLength = GambatteSyncSettings.FrameLengthType.EqualLengthFrames };
private static readonly GambatteSyncSettings GambatteSyncSettings_GB_NOBIOS = new() { ConsoleMode = GambatteSyncSettings.ConsoleModeType.GB, EnableBIOS = false, FrameLength = GambatteSyncSettings.FrameLengthType.EqualLengthFrames };
private static readonly GambatteSyncSettings GambatteSyncSettings_GB_USEBIOS = new() { ConsoleMode = GambatteSyncSettings.ConsoleModeType.GB, EnableBIOS = true, FrameLength = GambatteSyncSettings.FrameLengthType.EqualLengthFrames };
private static readonly GambatteSyncSettings GambatteSyncSettings_GBC_NOBIOS = new() { ConsoleMode = GambatteSyncSettings.ConsoleModeType.GBC, FrameLength = GambatteSyncSettings.FrameLengthType.EqualLengthFrames };
private static readonly GambatteSyncSettings GambatteSyncSettings_GBC_NOBIOS = new() { ConsoleMode = GambatteSyncSettings.ConsoleModeType.GBC, EnableBIOS = false, FrameLength = GambatteSyncSettings.FrameLengthType.EqualLengthFrames };
private static readonly GambatteSyncSettings GambatteSyncSettings_GBC_USEBIOS = new() { ConsoleMode = GambatteSyncSettings.ConsoleModeType.GBC, EnableBIOS = true, FrameLength = GambatteSyncSettings.FrameLengthType.EqualLengthFrames };
@ -117,13 +117,9 @@ namespace BizHawk.Tests.Testroms.GB
}
public static GambatteSyncSettings GetGambatteSyncSettings(ConsoleVariant variant, bool biosAvailable)
=> biosAvailable
? variant.IsColour()
? GambatteSyncSettings_GBC_USEBIOS
: GambatteSyncSettings_GB_USEBIOS
: variant.IsColour()
? GambatteSyncSettings_GBC_NOBIOS
: GambatteSyncSettings_GB_NOBIOS;
=> variant.IsColour()
? biosAvailable ? GambatteSyncSettings_GBC_USEBIOS : GambatteSyncSettings_GBC_NOBIOS
: biosAvailable ? GambatteSyncSettings_GB_USEBIOS : GambatteSyncSettings_GB_NOBIOS;
public static GBSyncSettings GetGBHawkSyncSettings(ConsoleVariant variant)
=> variant.IsColour()
@ -154,8 +150,10 @@ namespace BizHawk.Tests.Testroms.GB
/// <summary>converts Gambatte's GBC palette to GBHawk's; GB palette is the same</summary>
public static Image NormaliseGBScreenshot(Image img, CoreSetup setup)
=> setup.CoreName is CoreNames.Gambatte
? ImageUtils.PaletteSwap(img, setup.Variant.IsColour() ? UnVividGBCPaletteMap : UnVividGBPaletteMap)
: img;
=> setup.CoreName switch
{
CoreNames.Gambatte => ImageUtils.PaletteSwap(img, setup.Variant.IsColour() ? UnVividGBCPaletteMap : UnVividGBPaletteMap),
_ => img
};
}
}

View File

@ -7,7 +7,6 @@ using BizHawk.Common.IOExtensions;
using BizHawk.Common.StringExtensions;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores;
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Emulation.Cores.Nintendo.GBHawk;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@ -218,13 +217,12 @@ namespace BizHawk.Tests.Testroms.GB
fe.FrameAdvanceBy(5);
if (testCase.TestName is "m3_lcdc_win_map_change2") fe.FrameAdvance(); // just happens to be an outlier
}
var domain = fe.CoreAsMemDomains!.SystemBus;
Func<long> derefPC = fe.Core switch
Func<long> getPC = fe.Core switch
{
Gameboy => () => domain.PeekByte((long) fe.CoreAsDebuggable!.GetCpuFlagsAndRegisters()["PC"].Value),
GBHawk gbHawk => () => domain.PeekByte(gbHawk.cpu.RegPC),
_ => throw new Exception()
GBHawk gbHawk => () => gbHawk.cpu.RegPC,
_ => () => (long) fe.CoreAsDebuggable!.GetCpuFlagsAndRegisters()["PC"].Value
};
var domain = fe.CoreAsMemDomains!.SystemBus;
var finished = false;
fe.CoreAsDebuggable!.MemoryCallbacks.Add(new MemoryCallback(
domain.Name,
@ -232,7 +230,7 @@ namespace BizHawk.Tests.Testroms.GB
"breakpoint",
(_, _, _) =>
{
if (!finished && derefPC() is 0x40) finished = true;
if (!finished && domain.PeekByte(getPC()) is 0x40) finished = true;
},
address: null, // all addresses
mask: null));

View File

@ -21,7 +21,7 @@ namespace BizHawk.Tests.Testroms.GB
private static (string Expect, string Actual, string Glob) GenFilenames((string Suite, string Case) id, string fileExt = "png")
{
var prefix = $"{id.Suite}/{id.Case.GetHashCode():X8}"; // hashcode of string sadly not stable
var suffix = $"{id.Case.RemoveInvalidFileSystemChars().Replace(' ', '_')}.{fileExt}";
var suffix = $"{id.Case.RemoveInvalidFileSystemChars().Replace(' ', '_').Replace("(no BIOS)", "noBIOS")}.{fileExt}";
return ($"{prefix}_expect_{suffix}", $"{prefix}_actual_{suffix}", $"{prefix}_*_{suffix}");
}