Refactor `IGameboyCommon.IsCGBMode`
This commit is contained in:
parent
a54c94230f
commit
7703ee5f37
|
@ -253,10 +253,8 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (emulator is IGameboyCommon gb)
|
||||
{
|
||||
if (gb.IsCGBMode())
|
||||
{
|
||||
movie.HeaderEntries.Add(gb.IsCGBDMGMode() ? "IsCGBDMGMode" : "IsCGBMode", "1");
|
||||
}
|
||||
//TODO doesn't IsCGBDMGMode imply IsCGBMode?
|
||||
if (gb.IsCGBMode) movie.HeaderEntries.Add(gb.IsCGBDMGMode ? "IsCGBDMGMode" : "IsCGBMode", "1");
|
||||
}
|
||||
|
||||
if (emulator is SMS sms)
|
||||
|
|
|
@ -2065,7 +2065,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
case VSystemID.Raw.GBC:
|
||||
case VSystemID.Raw.SGB when Emulator is Gameboy:
|
||||
GBSubMenu.Visible = true;
|
||||
SameBoyColorChooserMenuItem.Visible = Emulator is Sameboy sameboy && !sameboy.IsCGBMode(); // palette config only works in DMG mode
|
||||
SameBoyColorChooserMenuItem.Visible = Emulator is Sameboy { IsCGBMode: false }; // palette config only works in DMG mode
|
||||
break;
|
||||
case VSystemID.Raw.SGB when Emulator is BsnesCore or SubBsnesCore:
|
||||
case VSystemID.Raw.SNES when Emulator is LibsnesCore { IsSGB: true }: // doesn't use "SGB" sysID
|
||||
|
|
|
@ -3,11 +3,6 @@ using BizHawk.Emulation.Cores.Atari.Jaguar;
|
|||
using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy;
|
||||
using BizHawk.Emulation.Cores.Consoles.Sega.gpgx;
|
||||
using BizHawk.Emulation.Cores.Consoles.Sega.PicoDrive;
|
||||
using BizHawk.Emulation.Cores.Nintendo.BSNES;
|
||||
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
|
||||
using BizHawk.Emulation.Cores.Nintendo.GBHawkLink;
|
||||
using BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x;
|
||||
using BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x;
|
||||
using BizHawk.Emulation.Cores.Nintendo.SNES;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
|
@ -114,19 +109,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
VSystemID.Raw.DEBUG => ConsoleID.UnknownConsoleID,
|
||||
VSystemID.Raw.Dreamcast => ConsoleID.Dreamcast,
|
||||
VSystemID.Raw.GameCube => ConsoleID.GameCube,
|
||||
VSystemID.Raw.GB when Emu is IGameboyCommon gb => gb.IsCGBMode() ? ConsoleID.GBC : ConsoleID.GB,
|
||||
VSystemID.Raw.GB when Emu is IGameboyCommon { IsCGBMode: true } => ConsoleID.GBC,
|
||||
VSystemID.Raw.GB => ConsoleID.GB,
|
||||
VSystemID.Raw.GBA => ConsoleID.GBA,
|
||||
VSystemID.Raw.GBC => ConsoleID.GBC, // Not actually used
|
||||
VSystemID.Raw.GBL => Emu switch // actually can be a mix of GB and GBC
|
||||
{
|
||||
// there's probably a better way for all this
|
||||
GambatteLink gb => gb.IsCGBMode(0) ? ConsoleID.GBC : ConsoleID.GB,
|
||||
// WHY ARE THESE PUBLIC???
|
||||
GBHawkLink gb => gb.L.IsCGBMode() ? ConsoleID.GBC : ConsoleID.GB,
|
||||
GBHawkLink3x gb => gb.L.IsCGBMode() ? ConsoleID.GBC : ConsoleID.GB,
|
||||
GBHawkLink4x gb => gb.A.IsCGBMode() ? ConsoleID.GBC : ConsoleID.GB,
|
||||
_ => ConsoleID.UnknownConsoleID,
|
||||
},
|
||||
VSystemID.Raw.GBL when Emu is ILinkedGameBoyCommon { First: { IsCGBMode: true } } => ConsoleID.GBC,
|
||||
VSystemID.Raw.GBL => ConsoleID.GB, // actually can be a mix of GB and GBC
|
||||
VSystemID.Raw.GEN when Emu is GPGX gpgx => gpgx.IsMegaCD ? ConsoleID.SegaCD : ConsoleID.MegaDrive,
|
||||
VSystemID.Raw.GEN when Emu is PicoDrive pico => pico.Is32XActive ? ConsoleID.Sega32X : ConsoleID.MegaDrive,
|
||||
VSystemID.Raw.GG => ConsoleID.GameGear,
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public override void Restart()
|
||||
{
|
||||
_cgb = Gb.IsCGBMode();
|
||||
_cgb = Gb.IsCGBMode;
|
||||
_lcdc = 0;
|
||||
|
||||
label4.Enabled = _cgb;
|
||||
|
|
|
@ -226,9 +226,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
DeterministicEmulation = true;
|
||||
}
|
||||
|
||||
public bool IsCGBMode() => is_GBC;
|
||||
public bool IsCGBMode
|
||||
=> is_GBC; //TODO inline
|
||||
|
||||
public bool IsCGBDMGMode() => is_GB_in_GBC;
|
||||
public bool IsCGBDMGMode
|
||||
=> is_GB_in_GBC; //TODO inline
|
||||
|
||||
/// <summary>
|
||||
/// Produces a palette in the form that certain frontend inspection tools.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy;
|
||||
using BizHawk.Emulation.Cores.Nintendo.GBHawk;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink
|
||||
|
@ -7,13 +8,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink
|
|||
[Core(CoreNames.GBHawkLink, "")]
|
||||
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
|
||||
public partial class GBHawkLink : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, ILinkable,
|
||||
ISettable<GBHawkLink.GBLinkSettings, GBHawkLink.GBLinkSyncSettings>
|
||||
ISettable<GBHawkLink.GBLinkSettings, GBHawkLink.GBLinkSyncSettings>,
|
||||
ILinkedGameBoyCommon
|
||||
{
|
||||
// we want to create two GBHawk instances that we will run concurrently
|
||||
// maybe up to 4 eventually?
|
||||
public GBHawk.GBHawk L;
|
||||
public GBHawk.GBHawk R;
|
||||
|
||||
public IGameboyCommon First
|
||||
=> L;
|
||||
|
||||
// if true, the link cable is currently connected
|
||||
private bool _cableconnected = true;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy;
|
||||
using BizHawk.Emulation.Cores.Nintendo.GBHawk;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
|
||||
|
@ -7,7 +8,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
|
|||
[Core(CoreNames.GBHawkLink3x, "")]
|
||||
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
|
||||
public partial class GBHawkLink3x : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable,
|
||||
ISettable<GBHawkLink3x.GBLink3xSettings, GBHawkLink3x.GBLink3xSyncSettings>
|
||||
ISettable<GBHawkLink3x.GBLink3xSettings, GBHawkLink3x.GBLink3xSyncSettings>,
|
||||
ILinkedGameBoyCommon
|
||||
{
|
||||
// we want to create two GBHawk instances that we will run concurrently
|
||||
// maybe up to 4 eventually?
|
||||
|
@ -15,6 +17,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
|
|||
public GBHawk.GBHawk C;
|
||||
public GBHawk.GBHawk R;
|
||||
|
||||
public IGameboyCommon First
|
||||
=> L;
|
||||
|
||||
// if true, the link cable is currently connected
|
||||
private bool _cableconnected_LC = false;
|
||||
private bool _cableconnected_CR = false;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy;
|
||||
using BizHawk.Emulation.Cores.Nintendo.GBHawk;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x
|
||||
|
@ -7,7 +8,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x
|
|||
[Core(CoreNames.GBHawkLink4x, "")]
|
||||
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
|
||||
public partial class GBHawkLink4x : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable,
|
||||
ISettable<GBHawkLink4x.GBLink4xSettings, GBHawkLink4x.GBLink4xSyncSettings>
|
||||
ISettable<GBHawkLink4x.GBLink4xSettings, GBHawkLink4x.GBLink4xSyncSettings>,
|
||||
ILinkedGameBoyCommon
|
||||
{
|
||||
// we want to create two GBHawk instances that we will run concurrently
|
||||
public GBHawk.GBHawk A;
|
||||
|
@ -15,6 +17,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x
|
|||
public GBHawk.GBHawk C;
|
||||
public GBHawk.GBHawk D;
|
||||
|
||||
public IGameboyCommon First
|
||||
=> A;
|
||||
|
||||
// if true, the link cable is currently connected
|
||||
private bool _cableconnected_LR = false;
|
||||
private bool _cableconnected_UD = false;
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
}
|
||||
else if (address < 0xA000u) // vram (may be banked on CGB in CGB enhanced mode)
|
||||
{
|
||||
if (IsCGBMode() && !IsCGBDMGMode())
|
||||
if (IsCGBMode && !IsCGBDMGMode)
|
||||
{
|
||||
address += (uint)(bank * 0x2000);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
}
|
||||
else if (address < 0xE000u) // wram bank x (always one for dmg/cgb in dmg mode)
|
||||
{
|
||||
if (IsCGBMode() && !IsCGBDMGMode())
|
||||
if (IsCGBMode && !IsCGBDMGMode)
|
||||
{
|
||||
address += (uint)(bank * 0x1000);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
{
|
||||
_settings = o;
|
||||
_disassembler.UseRGBDSSyntax = _settings.RgbdsSyntax;
|
||||
if (IsCGBMode() || IsSgb)
|
||||
if (IsCGBMode || IsSgb)
|
||||
{
|
||||
SetCGBColors(_settings.CGBColors);
|
||||
}
|
||||
|
|
|
@ -161,8 +161,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
"Disable BIOS in sync settings to boot this game");
|
||||
}
|
||||
|
||||
if (!_syncSettings.EnableBIOS && IsCgb && IsCGBDMGMode()) // without a bios, we need to set the palette for cgbdmg ourselves
|
||||
if (!_syncSettings.EnableBIOS && IsCGBMode && IsCGBDMGMode) //TODO doesn't IsCGBDMGMode imply IsCGBMode?
|
||||
{
|
||||
// without a bios, we need to set the palette for cgbdmg ourselves
|
||||
int[] cgbDmgColors = new int[] { 0xFFFFFF, 0x7BFF31, 0x0063C5, 0x000000, 0xFFFFFF, 0xFF8484, 0x943A3A, 0x000000, 0xFFFFFF, 0xFF8484, 0x943A3A, 0x000000 };
|
||||
if (file[0x14B] == 0x01 || (file[0x14B] == 0x33 && file[0x144] == '0' && file[0x145] == '1')) // Nintendo licencees get special palettes
|
||||
{
|
||||
|
@ -337,22 +338,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
return RemoteCommand;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// true if the emulator is currently emulating CGB
|
||||
/// </summary>
|
||||
public bool IsCGBMode()
|
||||
{
|
||||
//return LibGambatte.gambatte_iscgb(GambatteState);
|
||||
return IsCgb;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// true if the emulator is currently emulating CGB in DMG compatibility mode (NOTE: this mode does not take affect until the bootrom unmaps itself)
|
||||
/// </summary>
|
||||
public bool IsCGBDMGMode()
|
||||
{
|
||||
return LibGambatte.gambatte_iscgbdmg(GambatteState);
|
||||
}
|
||||
public bool IsCGBMode
|
||||
#if true
|
||||
=> IsCgb; //TODO inline
|
||||
#else
|
||||
=> LibGambatte.gambatte_iscgb(GambatteState);
|
||||
#endif
|
||||
|
||||
public bool IsCGBDMGMode
|
||||
=> LibGambatte.gambatte_iscgbdmg(GambatteState);
|
||||
|
||||
private InputCallbackSystem _inputCallbacks = new InputCallbackSystem();
|
||||
|
||||
|
|
|
@ -3,12 +3,13 @@ using System.Linq;
|
|||
|
||||
using BizHawk.Common.CollectionExtensions;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||
{
|
||||
[PortedCore(CoreNames.GambatteLink, "sinamas/natt")]
|
||||
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
|
||||
public partial class GambatteLink : ILinkable, IRomInfo
|
||||
public partial class GambatteLink : ILinkable, ILinkedGameBoyCommon, IRomInfo
|
||||
{
|
||||
[CoreConstructor(VSystemID.Raw.GBL)]
|
||||
public GambatteLink(CoreLoadParameters<GambatteLinkSettings, GambatteLinkSyncSettings> lp)
|
||||
|
@ -136,10 +137,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
|
||||
private readonly SaveController[] _linkedConts;
|
||||
|
||||
public bool IsCGBMode(int which)
|
||||
{
|
||||
return which < _numCores && _linkedCores[which].IsCGBMode();
|
||||
}
|
||||
public IGameboyCommon First
|
||||
=> _linkedCores[0];
|
||||
|
||||
private ControllerDefinition GBLinkController { get; }
|
||||
|
||||
|
|
|
@ -14,11 +14,20 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy
|
|||
/// <param name="exposure">The darkness/intensity of the print job. What the exact values mean is somewhat subjective but 127 is the most exposed/darkest value.</param>
|
||||
public delegate void PrinterCallback(IntPtr image, byte height, byte top_margin, byte bottom_margin, byte exposure);
|
||||
|
||||
public interface ILinkedGameBoyCommon : ISpecializedEmulatorService
|
||||
{
|
||||
/// <remarks>really just for RetroAchivements; can be changed to a list later</remarks>
|
||||
IGameboyCommon First { get; }
|
||||
}
|
||||
|
||||
public interface IGameboyCommon : ISpecializedEmulatorService
|
||||
{
|
||||
bool IsCGBMode();
|
||||
/// <value><see langword="true"/> iff the emulator is currently emulating CGB</value>
|
||||
bool IsCGBMode { get; }
|
||||
|
||||
bool IsCGBDMGMode();
|
||||
/// <value><see langword="true"/> iff the emulator is currently emulating CGB in DMG compatibility mode</value>
|
||||
/// <remarks>NOTE: this mode does not take affect until the bootrom unmaps itself</remarks>
|
||||
bool IsCGBDMGMode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Acquire GPU memory for inspection. The returned object must be disposed as soon as the frontend
|
||||
|
|
|
@ -36,9 +36,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
|
|||
|
||||
public bool IsCgb { get; set; }
|
||||
|
||||
public bool IsCGBMode() => IsCgb;
|
||||
public bool IsCGBMode
|
||||
=> IsCgb; //TODO inline
|
||||
|
||||
public bool IsCGBDMGMode() => LibSameboy.sameboy_iscgbdmg(SameboyState);
|
||||
public bool IsCGBDMGMode
|
||||
=> LibSameboy.sameboy_iscgbdmg(SameboyState);
|
||||
|
||||
private readonly LibSameboy.InputCallback _inputcb;
|
||||
|
||||
|
|
Loading…
Reference in New Issue