Merge branch 'master' into winhacksbgone

This commit is contained in:
James Groom 2019-12-22 17:01:10 +00:00 committed by GitHub
commit 78fcde9480
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
78 changed files with 2988 additions and 3358 deletions

View File

@ -4,5 +4,7 @@ SHA1:38D4AAB263E10B1DAC3410C120536EE079826BCB Fatso 2 O2
SHA1:3720DD6B5EE3DC62C5AF2EA9D915A2B83DE9463D Chief Chef O2 SHA1:3720DD6B5EE3DC62C5AF2EA9D915A2B83DE9463D Chief Chef O2
SHA1:FEB358E28587DE70D1E89BF0F9A3209CE0B67C57 Haunted House O2 SHA1:FEB358E28587DE70D1E89BF0F9A3209CE0B67C57 Haunted House O2
SHA1:B1D65BEDB56FE7A9CF60AA054A9FD9BB7F65B77C 3D Box O2 SHA1:B1D65BEDB56FE7A9CF60AA054A9FD9BB7F65B77C 3D Box O2
SHA1:0270047E2B1FC07581BF0FF9E55035925CF0EFF0 Guiseppe apr14 O2

View File

@ -2703,3 +2703,5 @@ sha1:341BB93E67C21063F3910845D1AF59FEA129FF21 Bang! A26 m=F4SC
sha1:62E7A3CE40BE1C29870D892639FBD394977281F5 DHmoveValues(rev2) A26 m=F6SC sha1:62E7A3CE40BE1C29870D892639FBD394977281F5 DHmoveValues(rev2) A26 m=F6SC
sha1:FBB0FE0A859BF764D060E264561734B8F7CFC9D7 REF A26 m=4K;NTSC=true sha1:FBB0FE0A859BF764D060E264561734B8F7CFC9D7 REF A26 m=4K;NTSC=true
sha1:58AA6BBA1D0D26C1287135FC9237B684A984B6BE Princess Rescue A26 m=F4;NTSC=true sha1:58AA6BBA1D0D26C1287135FC9237B684A984B6BE Princess Rescue A26 m=F4;NTSC=true
sha1:29404640B4579938057969D93A77C9A676AF9965 Crazy Balloon A26 m=4K;NTSC=true

View File

@ -15,13 +15,13 @@ namespace BizHawk.Client.Common
private readonly Action<string> LogCallback; private readonly Action<string> LogCallback;
public bool StartsFromSavestate() => Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.StartsFromSavestate; public bool StartsFromSavestate() => Global.MovieSession.Movie.IsActive() && Global.MovieSession.Movie.StartsFromSavestate;
public bool StartsFromSaveram() => Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.StartsFromSaveRam; public bool StartsFromSaveram() => Global.MovieSession.Movie.IsActive() && Global.MovieSession.Movie.StartsFromSaveRam;
public Dictionary<string, dynamic> GetInput(int frame) public Dictionary<string, dynamic> GetInput(int frame)
{ {
if (!Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.NotActive())
{ {
LogCallback("No movie loaded"); LogCallback("No movie loaded");
return null; return null;
@ -40,7 +40,10 @@ namespace BizHawk.Client.Common
public string GetInputAsMnemonic(int frame) public string GetInputAsMnemonic(int frame)
{ {
if (!Global.MovieSession.Movie.IsActive || frame >= Global.MovieSession.Movie.InputLogLength) return string.Empty; if (Global.MovieSession.Movie.NotActive() || frame >= Global.MovieSession.Movie.InputLogLength)
{
return string.Empty;
}
var lg = Global.MovieSession.LogGeneratorInstance(); var lg = Global.MovieSession.LogGeneratorInstance();
lg.SetSource(Global.MovieSession.Movie.GetInputState(frame)); lg.SetSource(Global.MovieSession.Movie.GetInputState(frame));
return lg.GenerateLogEntry(); return lg.GenerateLogEntry();
@ -48,7 +51,11 @@ namespace BizHawk.Client.Common
public void Save(string filename = null) public void Save(string filename = null)
{ {
if (!Global.MovieSession.Movie.IsActive) return; if (Global.MovieSession.Movie.NotActive())
{
return;
}
if (!string.IsNullOrEmpty(filename)) if (!string.IsNullOrEmpty(filename))
{ {
filename += $".{Global.MovieSession.Movie.PreferredExtension}"; filename += $".{Global.MovieSession.Movie.PreferredExtension}";
@ -65,7 +72,10 @@ namespace BizHawk.Client.Common
public Dictionary<string, string> GetHeader() public Dictionary<string, string> GetHeader()
{ {
var table = new Dictionary<string, string>(); var table = new Dictionary<string, string>();
if (!Global.MovieSession.Movie.IsActive) return table; if (Global.MovieSession.Movie.NotActive())
{
return table;
}
foreach (var kvp in Global.MovieSession.Movie.HeaderEntries) table[kvp.Key] = kvp.Value; foreach (var kvp in Global.MovieSession.Movie.HeaderEntries) table[kvp.Key] = kvp.Value;
return table; return table;
} }
@ -73,7 +83,11 @@ namespace BizHawk.Client.Common
public List<string> GetComments() public List<string> GetComments()
{ {
var list = new List<string>(Global.MovieSession.Movie.Comments.Count); var list = new List<string>(Global.MovieSession.Movie.Comments.Count);
if (!Global.MovieSession.Movie.IsActive) return list; if (Global.MovieSession.Movie.NotActive())
{
return list;
}
for (var i = 0; i < Global.MovieSession.Movie.Comments.Count; i++) list[i] = Global.MovieSession.Movie.Comments[i]; for (var i = 0; i < Global.MovieSession.Movie.Comments.Count; i++) list[i] = Global.MovieSession.Movie.Comments[i];
return list; return list;
} }
@ -81,7 +95,11 @@ namespace BizHawk.Client.Common
public List<string> GetSubtitles() public List<string> GetSubtitles()
{ {
var list = new List<string>(Global.MovieSession.Movie.Subtitles.Count); var list = new List<string>(Global.MovieSession.Movie.Subtitles.Count);
if (!Global.MovieSession.Movie.IsActive) return list; if (Global.MovieSession.Movie.NotActive())
{
return list;
}
for (var i = 0; i < Global.MovieSession.Movie.Subtitles.Count; i++) list[i] = Global.MovieSession.Movie.Subtitles[i].ToString(); for (var i = 0; i < Global.MovieSession.Movie.Subtitles.Count; i++) list[i] = Global.MovieSession.Movie.Subtitles[i].ToString();
return list; return list;
} }
@ -94,17 +112,11 @@ namespace BizHawk.Client.Common
public bool GetRerecordCounting() => Global.MovieSession.Movie.IsCountingRerecords; public bool GetRerecordCounting() => Global.MovieSession.Movie.IsCountingRerecords;
public bool IsLoaded() => Global.MovieSession.Movie.IsActive; public bool IsLoaded() => Global.MovieSession.Movie.IsActive();
public double Length() => Global.MovieSession.Movie.FrameCount; public double Length() => Global.MovieSession.Movie.FrameCount;
public string Mode() => Global.MovieSession.Movie.IsFinished public string Mode() => Global.MovieSession.Movie.Mode.ToString().ToUpper();
? "FINISHED"
: Global.MovieSession.Movie.IsPlaying
? "PLAY"
: Global.MovieSession.Movie.IsRecording
? "RECORD"
: "INACTIVE";
public void SetReadOnly(bool readOnly) => Global.MovieSession.ReadOnly = readOnly; public void SetReadOnly(bool readOnly) => Global.MovieSession.ReadOnly = readOnly;
@ -117,7 +129,11 @@ namespace BizHawk.Client.Common
public double GetFps() public double GetFps()
{ {
var movie = Global.MovieSession.Movie; var movie = Global.MovieSession.Movie;
if (!movie.IsActive) return default; if (movie.NotActive())
{
return default;
}
return new PlatformFrameRates()[ return new PlatformFrameRates()[
movie.HeaderEntries[HeaderKeys.PLATFORM], movie.HeaderEntries[HeaderKeys.PLATFORM],
movie.HeaderEntries.TryGetValue(HeaderKeys.PAL, out var isPal) && isPal == "1" movie.HeaderEntries.TryGetValue(HeaderKeys.PAL, out var isPal) && isPal == "1"

View File

@ -120,6 +120,7 @@
<Compile Include="config\Config.cs" /> <Compile Include="config\Config.cs" />
<Compile Include="config\ConfigPersistAttribute.cs" /> <Compile Include="config\ConfigPersistAttribute.cs" />
<Compile Include="config\ConfigService.cs" /> <Compile Include="config\ConfigService.cs" />
<Compile Include="config\DefaultMessageOptions.cs" />
<Compile Include="config\PathEntry.cs" /> <Compile Include="config\PathEntry.cs" />
<Compile Include="config\RestoreDefaultsAttribute.cs" /> <Compile Include="config\RestoreDefaultsAttribute.cs" />
<Compile Include="config\ToolDialogSettings.cs" /> <Compile Include="config\ToolDialogSettings.cs" />
@ -208,10 +209,10 @@
<Compile Include="movie\bk2\Bk2Movie.ModeApi.cs"> <Compile Include="movie\bk2\Bk2Movie.ModeApi.cs">
<DependentUpon>Bk2Movie.cs</DependentUpon> <DependentUpon>Bk2Movie.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="movie\bkm\BkmControllerAdapter.cs" /> <Compile Include="movie\import\bkm\BkmControllerAdapter.cs" />
<Compile Include="movie\bkm\BkmHeader.cs" /> <Compile Include="movie\import\bkm\BkmHeader.cs" />
<Compile Include="movie\bkm\BkmMnemonicConstants.cs" /> <Compile Include="movie\import\bkm\BkmMnemonicConstants.cs" />
<Compile Include="movie\bkm\BkmMovie.cs" /> <Compile Include="movie\import\bkm\BkmMovie.cs" />
<Compile Include="movie\conversions\MovieConversionExtensions.cs" /> <Compile Include="movie\conversions\MovieConversionExtensions.cs" />
<Compile Include="movie\HeaderKeys.cs" /> <Compile Include="movie\HeaderKeys.cs" />
<Compile Include="movie\import\Fm2Import.cs" /> <Compile Include="movie\import\Fm2Import.cs" />

View File

@ -1,6 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Sega.MasterSystem;
// ReSharper disable StyleCop.SA1401 // ReSharper disable StyleCop.SA1401
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
@ -70,103 +69,6 @@ namespace BizHawk.Client.Common
// This relies on a client specific implementation! // This relies on a client specific implementation!
public static SimpleController ControllerInputCoalescer; public static SimpleController ControllerInputCoalescer;
public static SystemInfo SystemInfo
{
get
{
switch (Emulator.SystemId)
{
default:
case "NULL":
return SystemInfo.Null;
case "NES":
return SystemInfo.Nes;
case "INTV":
return SystemInfo.Intellivision;
case "SG":
return SystemInfo.SG;
case "SMS":
if (Emulator is SMS gg && gg.IsGameGear)
{
return SystemInfo.GG;
}
if (Emulator is SMS sg && sg.IsSG1000)
{
return SystemInfo.SG;
}
return SystemInfo.SMS;
case "PCECD":
return SystemInfo.PCECD;
case "PCE":
return SystemInfo.PCE;
case "SGX":
return SystemInfo.SGX;
case "GEN":
return SystemInfo.Genesis;
case "TI83":
return SystemInfo.TI83;
case "SNES":
return SystemInfo.SNES;
case "GB":
/*
if ((Emulator as IGameboyCommon).IsCGBMode())
{
return SystemInfo.GBC;
}
*/
return SystemInfo.GB;
case "A26":
return SystemInfo.Atari2600;
case "A78":
return SystemInfo.Atari7800;
case "C64":
return SystemInfo.C64;
case "Coleco":
return SystemInfo.Coleco;
case "GBA":
return SystemInfo.GBA;
case "N64":
return SystemInfo.N64;
case "SAT":
return SystemInfo.Saturn;
case "DGB":
return SystemInfo.DualGB;
case "GB3x":
return SystemInfo.GB3x;
case "GB4x":
return SystemInfo.GB4x;
case "WSWAN":
return SystemInfo.WonderSwan;
case "Lynx":
return SystemInfo.Lynx;
case "PSX":
return SystemInfo.PSX;
case "AppleII":
return SystemInfo.AppleII;
case "Libretro":
return SystemInfo.Libretro;
case "VB":
return SystemInfo.VirtualBoy;
case "VEC":
return SystemInfo.Vectrex;
case "NGP":
return SystemInfo.NeoGeoPocket;
case "ZXSpectrum":
return SystemInfo.ZXSpectrum;
case "AmstradCPC":
return SystemInfo.AmstradCPC;
case "ChannelF":
return SystemInfo.ChannelF;
case "O2":
return SystemInfo.O2;
case "MAME":
return SystemInfo.MAME;
}
}
}
public static Dictionary<string, object> UserBag = new Dictionary<string, object>(); public static Dictionary<string, object> UserBag = new Dictionary<string, object>();
} }
} }

View File

@ -261,7 +261,7 @@ namespace BizHawk.Client.Common
public static string SaveRamPath(GameInfo game) public static string SaveRamPath(GameInfo game)
{ {
var name = FilesystemSafeName(game); var name = FilesystemSafeName(game);
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive())
{ {
name += $".{Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)}"; name += $".{Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)}";
} }
@ -288,7 +288,7 @@ namespace BizHawk.Client.Common
name = FilesystemSafeName(game); name = FilesystemSafeName(game);
} }
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive())
{ {
name = Path.Combine(name, $"movie-{Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)}"); name = Path.Combine(name, $"movie-{Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)}");
} }
@ -363,7 +363,7 @@ namespace BizHawk.Client.Common
name += $".{Global.Emulator.Attributes().CoreName}"; name += $".{Global.Emulator.Attributes().CoreName}";
} }
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive())
{ {
name += $".{Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)}"; name += $".{Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)}";
} }

View File

@ -65,7 +65,7 @@ namespace BizHawk.Client.Common
} }
} }
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive())
{ {
bs.PutLump(BinaryStateLump.Input, bs.PutLump(BinaryStateLump.Input,
delegate(TextWriter tw) delegate(TextWriter tw)
@ -86,7 +86,7 @@ namespace BizHawk.Client.Common
}); });
} }
if (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie is TasMovie) if (Global.MovieSession.Movie.IsActive() && Global.MovieSession.Movie is TasMovie)
{ {
bs.PutLump(BinaryStateLump.LagLog, bs.PutLump(BinaryStateLump.LagLog,
delegate(TextWriter tw) delegate(TextWriter tw)
@ -139,7 +139,7 @@ namespace BizHawk.Client.Common
{ {
var succeed = false; var succeed = false;
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive())
{ {
bl.GetLump(BinaryStateLump.Input, true, tr => succeed = Global.MovieSession.HandleMovieLoadState_HackyStep1(tr)); bl.GetLump(BinaryStateLump.Input, true, tr => succeed = Global.MovieSession.HandleMovieLoadState_HackyStep1(tr));
if (!succeed) if (!succeed)
@ -179,7 +179,7 @@ namespace BizHawk.Client.Common
Global.UserBag = (Dictionary<string, object>)ConfigService.LoadWithType(userData); Global.UserBag = (Dictionary<string, object>)ConfigService.LoadWithType(userData);
} }
if (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie is TasMovie) if (Global.MovieSession.Movie.IsActive() && Global.MovieSession.Movie is TasMovie)
{ {
bl.GetLump(BinaryStateLump.LagLog, false, delegate(TextReader tr) bl.GetLump(BinaryStateLump.LagLog, false, delegate(TextReader tr)
{ {

View File

@ -14,7 +14,7 @@ namespace BizHawk.Client.Common
private const JoypadButton UpDownLeftRight = JoypadButton.Up | JoypadButton.Down | JoypadButton.Left | JoypadButton.Right; private const JoypadButton UpDownLeftRight = JoypadButton.Up | JoypadButton.Down | JoypadButton.Left | JoypadButton.Right;
private const JoypadButton StandardButtons = JoypadButton.A | JoypadButton.B | JoypadButton.Start | JoypadButton.Select | UpDownLeftRight; private const JoypadButton StandardButtons = JoypadButton.A | JoypadButton.B | JoypadButton.Start | JoypadButton.Select | UpDownLeftRight;
private static readonly List<SystemInfo> _allSystemInfos = new List<SystemInfo>(); private static readonly List<SystemInfo> AllSystemInfos = new List<SystemInfo>();
#endregion #endregion
@ -34,7 +34,7 @@ namespace BizHawk.Client.Common
MaxControllers = maxControllers; MaxControllers = maxControllers;
AvailableButtons = availableButtons; AvailableButtons = availableButtons;
_allSystemInfos.Add(this); AllSystemInfos.Add(this);
} }
#endregion #endregion
@ -184,7 +184,7 @@ namespace BizHawk.Client.Common
public static SystemInfo TI83 { get; } = new SystemInfo("TI - 83", CoreSystem.TI83, 1); public static SystemInfo TI83 { get; } = new SystemInfo("TI - 83", CoreSystem.TI83, 1);
/// <summary> /// <summary>
/// Gets the <see cref="SystemInfo"/> instance for Wonderswan /// Gets the <see cref="SystemInfo"/> instance for WonderSwan
/// </summary> /// </summary>
public static SystemInfo WonderSwan { get; } = new SystemInfo("WonderSwan", CoreSystem.WonderSwan, 1); public static SystemInfo WonderSwan { get; } = new SystemInfo("WonderSwan", CoreSystem.WonderSwan, 1);
@ -196,7 +196,7 @@ namespace BizHawk.Client.Common
/// <summary> /// <summary>
/// Gets the <see cref="SystemInfo"/> instance for Vectrex /// Gets the <see cref="SystemInfo"/> instance for Vectrex
/// </summary> /// </summary>
public static SystemInfo Vectrex { get; } = new SystemInfo("Vextrex", CoreSystem.Vectrex, 2); public static SystemInfo Vectrex { get; } = new SystemInfo("Vectrex", CoreSystem.Vectrex, 2);
/// <summary> /// <summary>
/// Gets the <see cref="SystemInfo"/> instance for TI-83 /// Gets the <see cref="SystemInfo"/> instance for TI-83
@ -206,12 +206,12 @@ namespace BizHawk.Client.Common
/// <summary> /// <summary>
/// Gets the <see cref="SystemInfo"/> instance for ZXSpectrum /// Gets the <see cref="SystemInfo"/> instance for ZXSpectrum
/// </summary> /// </summary>
public static SystemInfo ZXSpectrum { get; } = new SystemInfo("ZX Spectrum", CoreSystem.ZXSpectrum, 2); public static SystemInfo ZxSpectrum { get; } = new SystemInfo("ZX Spectrum", CoreSystem.ZXSpectrum, 2);
/// <summary> /// <summary>
/// Gets the <see cref="SystemInfo"/> instance for AmstradCPC /// Gets the <see cref="SystemInfo"/> instance for AmstradCPC
/// </summary> /// </summary>
public static SystemInfo AmstradCPC { get; } = new SystemInfo("Amstrad CPC", CoreSystem.AmstradCPC, 2); public static SystemInfo AmstradCpc { get; } = new SystemInfo("Amstrad CPC", CoreSystem.AmstradCPC, 2);
/// <summary> /// <summary>
/// Gets the <see cref="SystemInfo"/> instance for GGL /// Gets the <see cref="SystemInfo"/> instance for GGL
@ -231,7 +231,7 @@ namespace BizHawk.Client.Common
/// <summary> /// <summary>
/// Gets the <see cref="SystemInfo"/> instance for MAME /// Gets the <see cref="SystemInfo"/> instance for MAME
/// </summary> /// </summary>
public static SystemInfo MAME { get; } = new SystemInfo("MAME", CoreSystem.MAME, 4); public static SystemInfo Mame { get; } = new SystemInfo("MAME", CoreSystem.MAME, 4);
#endregion Get SystemInfo #endregion Get SystemInfo
@ -242,7 +242,7 @@ namespace BizHawk.Client.Common
/// <returns><see cref="SystemInfo"/></returns> /// <returns><see cref="SystemInfo"/></returns>
public static SystemInfo FindByCoreSystem(CoreSystem system) public static SystemInfo FindByCoreSystem(CoreSystem system)
{ {
return _allSystemInfos.Find(s => s.System == system); return AllSystemInfos.Find(s => s.System == system);
} }
/// <summary> /// <summary>
@ -252,16 +252,16 @@ namespace BizHawk.Client.Common
/// <returns>True if object is equal to this instance; otherwise, false</returns> /// <returns>True if object is equal to this instance; otherwise, false</returns>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (obj is SystemInfo) if (obj is SystemInfo info)
{ {
return this == (SystemInfo)obj; return this == info;
} }
return base.Equals(obj); return base.Equals(obj);
} }
/// <summary> /// <summary>
/// Gets the haschode for current instance /// Gets the hashcode for current instance
/// </summary> /// </summary>
/// <returns>This instance hashcode</returns> /// <returns>This instance hashcode</returns>
public override int GetHashCode() public override int GetHashCode()

View File

@ -239,44 +239,6 @@ namespace BizHawk.Client.Common
/// </summary> /// </summary>
public bool DispAlternateVsync = false; public bool DispAlternateVsync = false;
public static class DefaultMessageOptions
{
public const int
DispFPSx = 0,
DispFPSy = 0,
DispFrameCx = 0,
DispFrameCy = 14,
DispLagx = 0,
DispLagy = 42,
DispInpx = 0,
DispInpy = 28,
DispRecx = 0,
DispRecy = 56,
DispMultix = 0,
DispMultiy = 14,
DispMessagex = 3,
DispMessagey = 0,
DispAutoholdx = 0,
DispAutoholdy = 0,
DispRamWatchx = 0,
DispRamWatchy = 70,
MessagesColor = -1,
AlertMessageColor = -65536,
LastInputColor = -23296,
MovieInput = -8355712,
DispFPSanchor = 0, // 0 = UL, 1 = UR, 2 = DL, 3 = DR
DispFrameanchor = 0,
DispLaganchor = 0,
DispInpanchor = 0,
DispWatchAnchor = 0,
DispRecanchor = 0,
DispMultianchor = 1,
DispMessageanchor = 2,
DispAutoholdanchor = 1;
}
// Display options // Display options
public bool DisplayFPS = false; public bool DisplayFPS = false;
public bool DisplayFrameCounter = false; public bool DisplayFrameCounter = false;
@ -291,39 +253,20 @@ namespace BizHawk.Client.Common
public bool DispAutoPrescale = true; public bool DispAutoPrescale = true;
public int DispSpeedupFeatures = 2; public int DispSpeedupFeatures = 2;
public int DispFPSx = DefaultMessageOptions.DispFPSx; public MessagePosition Fps = DefaultMessagePositions.Fps.Clone();
public int DispFPSy = DefaultMessageOptions.DispFPSy; public MessagePosition FrameCounter = DefaultMessagePositions.FrameCounter.Clone();
public int DispFrameCx = DefaultMessageOptions.DispFrameCx; public MessagePosition LagCounter = DefaultMessagePositions.LagCounter.Clone();
public int DispFrameCy = DefaultMessageOptions.DispFrameCy; public MessagePosition InputDisplay = DefaultMessagePositions.InputDisplay.Clone();
public int DispLagx = DefaultMessageOptions.DispLagx; public MessagePosition ReRecordCounter = DefaultMessagePositions.ReRecordCounter.Clone();
public int DispLagy = DefaultMessageOptions.DispLagy; public MessagePosition MultitrackRecorder = DefaultMessagePositions.MultitrackRecorder.Clone();
public int DispInpx = DefaultMessageOptions.DispInpx; public MessagePosition Messages = DefaultMessagePositions.Messages.Clone();
public int DispInpy = DefaultMessageOptions.DispInpy; public MessagePosition Autohold = DefaultMessagePositions.Autohold.Clone();
public int DispRecx = DefaultMessageOptions.DispRecx; public MessagePosition RamWatches = DefaultMessagePositions.RamWatches.Clone();
public int DispRecy = DefaultMessageOptions.DispRecy;
public int DispMultix = DefaultMessageOptions.DispMultix;
public int DispMultiy = DefaultMessageOptions.DispMultiy;
public int DispRamWatchx = DefaultMessageOptions.DispRamWatchx;
public int DispRamWatchy = DefaultMessageOptions.DispRamWatchy;
public int DispMessagex = DefaultMessageOptions.DispMessagex;
public int DispMessagey = DefaultMessageOptions.DispMessagey;
public int DispAutoholdx = DefaultMessageOptions.DispAutoholdx;
public int DispAutoholdy = DefaultMessageOptions.DispAutoholdy;
public int DispFPSanchor = DefaultMessageOptions.DispFPSanchor; // 0 = UL, 1 = UR, 2 = DL, 3 = DR public int MessagesColor = DefaultMessagePositions.MessagesColor;
public int DispFrameanchor = DefaultMessageOptions.DispFrameanchor; public int AlertMessageColor = DefaultMessagePositions.AlertMessageColor;
public int DispLaganchor = DefaultMessageOptions.DispLaganchor; public int LastInputColor = DefaultMessagePositions.LastInputColor;
public int DispInpanchor = DefaultMessageOptions.DispInpanchor; public int MovieInput = DefaultMessagePositions.MovieInput;
public int DispWatchesanchor = DefaultMessageOptions.DispWatchAnchor;
public int DispRecanchor = DefaultMessageOptions.DispRecanchor;
public int DispMultianchor = DefaultMessageOptions.DispMultianchor;
public int DispMessageanchor = DefaultMessageOptions.DispMessageanchor;
public int DispAutoholdanchor = DefaultMessageOptions.DispAutoholdanchor;
public int MessagesColor = DefaultMessageOptions.MessagesColor;
public int AlertMessageColor = DefaultMessageOptions.AlertMessageColor;
public int LastInputColor = DefaultMessageOptions.LastInputColor;
public int MovieInput = DefaultMessageOptions.MovieInput;
public int DispPrescale = 1; public int DispPrescale = 1;

View File

@ -0,0 +1,56 @@
namespace BizHawk.Client.Common
{
public class MessagePosition
{
public int X { get; set; }
public int Y { get; set; }
public AnchorType Anchor { get; set; }
public enum AnchorType
{
TopLeft = 0,
TopRight = 1,
BottomLeft = 2,
BottomRight = 3
}
public MessagePosition Clone()
{
return (MessagePosition)MemberwiseClone();
}
}
public static class MessageOptionExtensions
{
public static bool IsTop(this MessagePosition.AnchorType type)
{
return type == MessagePosition.AnchorType.TopLeft
|| type == MessagePosition.AnchorType.TopRight;
}
public static bool IsLeft(this MessagePosition.AnchorType type)
{
return type == MessagePosition.AnchorType.TopLeft
|| type == MessagePosition.AnchorType.BottomLeft;
}
}
public static class DefaultMessagePositions
{
public static MessagePosition Fps = new MessagePosition { X = 0, Y = 0 };
public static MessagePosition FrameCounter = new MessagePosition { X = 0, Y = 14 };
public static MessagePosition LagCounter = new MessagePosition { X = 0, Y = 42 };
public static MessagePosition InputDisplay = new MessagePosition { X = 0, Y = 28 };
public static MessagePosition ReRecordCounter = new MessagePosition { X = 0, Y = 56 };
public static MessagePosition MultitrackRecorder = new MessagePosition { X = 0, Y = 14, Anchor = MessagePosition.AnchorType.TopRight };
public static MessagePosition Messages = new MessagePosition { X = 0, Y = 0, Anchor = MessagePosition.AnchorType.BottomLeft };
public static MessagePosition Autohold = new MessagePosition { X = 0, Y = 0, Anchor = MessagePosition.AnchorType.TopRight };
public static MessagePosition RamWatches = new MessagePosition { X = 0, Y = 70 };
public const int
MessagesColor = -1,
AlertMessageColor = -65536,
LastInputColor = -23296,
MovieInput = -8355712;
}
}

View File

@ -37,7 +37,7 @@ namespace BizHawk.Client.Common
} }
} }
public void ClearAll() public new void Clear()
{ {
if (Global.Emulator.InputCallbacksAvailable()) if (Global.Emulator.InputCallbacksAvailable())
{ {
@ -50,7 +50,7 @@ namespace BizHawk.Client.Common
memoryCallbacks.RemoveAll(this.Select(w => w.MemCallback)); memoryCallbacks.RemoveAll(this.Select(w => w.MemCallback));
} }
Clear(); base.Clear();
} }
} }

View File

@ -64,7 +64,7 @@ namespace BizHawk.Client.Common
{ {
get get
{ {
if (Movie.IsActive && !Movie.IsFinished && Global.Emulator.Frame > 0) if (Movie.IsPlayingOrRecording() && Global.Emulator.Frame > 0)
{ {
return Movie.GetInputState(Global.Emulator.Frame - 1); return Movie.GetInputState(Global.Emulator.Frame - 1);
} }
@ -77,7 +77,7 @@ namespace BizHawk.Client.Common
{ {
get get
{ {
if (Movie.IsActive && !Movie.IsFinished && Global.Emulator.Frame > 1) if (Movie.IsPlayingOrRecording() && Global.Emulator.Frame > 1)
{ {
return Movie.GetInputState(Global.Emulator.Frame - 2); return Movie.GetInputState(Global.Emulator.Frame - 2);
} }
@ -170,18 +170,18 @@ namespace BizHawk.Client.Common
public void StopMovie(bool saveChanges = true) public void StopMovie(bool saveChanges = true)
{ {
var message = "Movie "; var message = "Movie ";
if (Movie.IsRecording) if (Movie.IsRecording())
{ {
message += "recording "; message += "recording ";
} }
else if (Movie.IsPlaying) else if (Movie.IsPlaying())
{ {
message += "playback "; message += "playback ";
} }
message += "stopped."; message += "stopped.";
if (Movie.IsActive) if (Movie.IsActive())
{ {
var result = Movie.Stop(saveChanges); var result = Movie.Stop(saveChanges);
if (result) if (result)
@ -199,7 +199,7 @@ namespace BizHawk.Client.Common
public void HandleMovieSaveState(TextWriter writer) public void HandleMovieSaveState(TextWriter writer)
{ {
if (Movie.IsActive) if (Movie.IsActive())
{ {
Movie.WriteInputLog(writer); Movie.WriteInputLog(writer);
} }
@ -207,7 +207,7 @@ namespace BizHawk.Client.Common
public void ClearFrame() public void ClearFrame()
{ {
if (Movie.IsPlaying) if (Movie.IsPlaying())
{ {
Movie.ClearFrame(Global.Emulator.Frame); Movie.ClearFrame(Global.Emulator.Frame);
Output($"Scrubbed input at frame {Global.Emulator.Frame}"); Output($"Scrubbed input at frame {Global.Emulator.Frame}");
@ -216,11 +216,11 @@ namespace BizHawk.Client.Common
public void HandleMovieOnFrameLoop() public void HandleMovieOnFrameLoop()
{ {
if (!Movie.IsActive) if (!Movie.IsActive())
{ {
LatchInputFromPlayer(Global.MovieInputSourceAdapter); LatchInputFromPlayer(Global.MovieInputSourceAdapter);
} }
else if (Movie.IsFinished) else if (Movie.IsFinished())
{ {
if (Global.Emulator.Frame < Movie.FrameCount) // This scenario can happen from rewinding (suddenly we are back in the movie, so hook back up to the movie if (Global.Emulator.Frame < Movie.FrameCount) // This scenario can happen from rewinding (suddenly we are back in the movie, so hook back up to the movie
{ {
@ -232,18 +232,18 @@ namespace BizHawk.Client.Common
LatchInputFromPlayer(Global.MovieInputSourceAdapter); LatchInputFromPlayer(Global.MovieInputSourceAdapter);
} }
} }
else if (Movie.IsPlaying) else if (Movie.IsPlaying())
{ {
LatchInputFromLog(); LatchInputFromLog();
if (Movie.IsRecording) // The movie end situation can cause the switch to record mode, in that case we need to capture some input for this frame if (Movie.IsRecording()) // The movie end situation can cause the switch to record mode, in that case we need to capture some input for this frame
{ {
HandleFrameLoopForRecordMode(); HandleFrameLoopForRecordMode();
} }
else else
{ {
// Movie may go into finished mode as a result from latching // Movie may go into finished mode as a result from latching
if (!Movie.IsFinished) if (!Movie.IsFinished())
{ {
if (Global.ClientControls.IsPressed("Scrub Input")) if (Global.ClientControls.IsPressed("Scrub Input"))
{ {
@ -269,7 +269,7 @@ namespace BizHawk.Client.Common
} }
} }
} }
else if (Movie.IsRecording) else if (Movie.IsRecording())
{ {
HandleFrameLoopForRecordMode(); HandleFrameLoopForRecordMode();
} }
@ -278,7 +278,7 @@ namespace BizHawk.Client.Common
private void HandleFrameLoopForRecordMode() private void HandleFrameLoopForRecordMode()
{ {
// we don't want TasMovie to latch user input outside its internal recording mode, so limit it to autohold // we don't want TasMovie to latch user input outside its internal recording mode, so limit it to autohold
if (Movie is TasMovie && Movie.IsPlaying) if (Movie is TasMovie && Movie.IsPlaying())
{ {
MovieControllerAdapter.LatchSticky(); MovieControllerAdapter.LatchSticky();
} }
@ -304,12 +304,12 @@ namespace BizHawk.Client.Common
if (Movie is TasMovie tasMovie) if (Movie is TasMovie tasMovie)
{ {
tasMovie.GreenzoneCurrentFrame(); tasMovie.GreenzoneCurrentFrame();
if (tasMovie.IsPlaying && Global.Emulator.Frame >= tasMovie.InputLogLength) if (tasMovie.IsPlaying() && Global.Emulator.Frame >= tasMovie.InputLogLength)
{ {
HandleFrameLoopForRecordMode(); HandleFrameLoopForRecordMode();
} }
} }
else if (Movie.IsPlaying && !Movie.IsFinished && Global.Emulator.Frame >= Movie.InputLogLength) else if (Movie.Mode == MovieMode.Play && Global.Emulator.Frame >= Movie.InputLogLength)
{ {
HandlePlaybackEnd(); HandlePlaybackEnd();
} }
@ -324,7 +324,7 @@ namespace BizHawk.Client.Common
// TODO: maybe someone who understands more about what's going on here could rename these step1 and step2 into something more descriptive // TODO: maybe someone who understands more about what's going on here could rename these step1 and step2 into something more descriptive
public bool HandleMovieLoadState_HackyStep2(TextReader reader) public bool HandleMovieLoadState_HackyStep2(TextReader reader)
{ {
if (!Movie.IsActive) if (Movie.NotActive())
{ {
return true; return true;
} }
@ -361,7 +361,7 @@ namespace BizHawk.Client.Common
public bool HandleMovieLoadState_HackyStep1(TextReader reader) public bool HandleMovieLoadState_HackyStep1(TextReader reader)
{ {
if (!Movie.IsActive) if (!Movie.IsActive())
{ {
return true; return true;
} }
@ -375,22 +375,22 @@ namespace BizHawk.Client.Common
return false; return false;
} }
if (Movie.IsRecording) if (Movie.IsRecording())
{ {
Movie.SwitchToPlay(); Movie.SwitchToPlay();
} }
else if (Movie.IsFinished) else if (Movie.IsFinished())
{ {
LatchInputFromPlayer(Global.MovieInputSourceAdapter); LatchInputFromPlayer(Global.MovieInputSourceAdapter);
} }
} }
else else
{ {
if (Movie.IsFinished) if (Movie.IsFinished())
{ {
Movie.StartNewRecording(); Movie.StartNewRecording();
} }
else if (Movie.IsPlaying) else if (Movie.IsPlaying())
{ {
Movie.SwitchToRecord(); Movie.SwitchToRecord();
} }
@ -401,7 +401,7 @@ namespace BizHawk.Client.Common
public void ToggleMultitrack() public void ToggleMultitrack()
{ {
if (Movie.IsActive) if (Movie.IsActive())
{ {
if (Global.Config.VBAStyleMovieLoadState) if (Global.Config.VBAStyleMovieLoadState)
{ {

View File

@ -176,7 +176,7 @@ namespace BizHawk.Client.Common
Truncate(Log.Count); Truncate(Log.Count);
} }
Mode = Moviemode.Finished; Mode = MovieMode.Finished;
} }
if (IsCountingRerecords) if (IsCountingRerecords)
@ -245,7 +245,7 @@ namespace BizHawk.Client.Common
if (Log.Count < stateFrame) if (Log.Count < stateFrame)
{ {
if (IsFinished) if (this.IsFinished())
{ {
return true; return true;
} }
@ -267,18 +267,18 @@ namespace BizHawk.Client.Common
if (stateFrame > newLog.Count) // stateFrame is greater than state input log, so movie finished mode if (stateFrame > newLog.Count) // stateFrame is greater than state input log, so movie finished mode
{ {
if (Mode == Moviemode.Play || Mode == Moviemode.Finished) if (Mode == MovieMode.Play || Mode == MovieMode.Finished)
{ {
Mode = Moviemode.Finished; Mode = MovieMode.Finished;
return true; return true;
} }
return false; return false;
} }
if (Mode == Moviemode.Finished) if (Mode == MovieMode.Finished)
{ {
Mode = Moviemode.Play; Mode = MovieMode.Play;
} }
return true; return true;

View File

@ -4,24 +4,11 @@ namespace BizHawk.Client.Common
{ {
public partial class Bk2Movie public partial class Bk2Movie
{ {
protected enum Moviemode public MovieMode Mode { get; protected set; } = MovieMode.Inactive;
{
Inactive, Play, Record, Finished
}
protected Moviemode Mode { get; set; } = Moviemode.Inactive;
public bool IsActive => Mode != Moviemode.Inactive;
public bool IsPlaying => Mode == Moviemode.Play || Mode == Moviemode.Finished;
public bool IsRecording => Mode == Moviemode.Record;
public bool IsFinished => Mode == Moviemode.Finished;
public virtual void StartNewRecording() public virtual void StartNewRecording()
{ {
Mode = Moviemode.Record; Mode = MovieMode.Record;
if (Global.Config.EnableBackupMovies && MakeBackup && Log.Any()) if (Global.Config.EnableBackupMovies && MakeBackup && Log.Any())
{ {
SaveBackup(); SaveBackup();
@ -33,17 +20,17 @@ namespace BizHawk.Client.Common
public virtual void StartNewPlayback() public virtual void StartNewPlayback()
{ {
Mode = Moviemode.Play; Mode = MovieMode.Play;
} }
public virtual void SwitchToRecord() public virtual void SwitchToRecord()
{ {
Mode = Moviemode.Record; Mode = MovieMode.Record;
} }
public virtual void SwitchToPlay() public virtual void SwitchToPlay()
{ {
Mode = Moviemode.Play; Mode = MovieMode.Play;
} }
public virtual bool Stop(bool saveChanges = true) public virtual bool Stop(bool saveChanges = true)
@ -51,7 +38,7 @@ namespace BizHawk.Client.Common
bool saved = false; bool saved = false;
if (saveChanges) if (saveChanges)
{ {
if (Mode == Moviemode.Record || (IsActive && Changes)) if (Mode == MovieMode.Record || (this.IsActive() && Changes))
{ {
Save(); Save();
saved = true; saved = true;
@ -59,14 +46,14 @@ namespace BizHawk.Client.Common
} }
Changes = false; Changes = false;
Mode = Moviemode.Inactive; Mode = MovieMode.Inactive;
return saved; return saved;
} }
public void FinishedMode() public void FinishedMode()
{ {
Mode = Moviemode.Finished; Mode = MovieMode.Finished;
} }
} }
} }

View File

@ -23,7 +23,7 @@ namespace BizHawk.Client.Common
Filename = ""; Filename = "";
IsCountingRerecords = true; IsCountingRerecords = true;
Mode = Moviemode.Inactive; Mode = MovieMode.Inactive;
MakeBackup = true; MakeBackup = true;
Header[HeaderKeys.MOVIEVERSION] = "BizHawk v2.0.0"; Header[HeaderKeys.MOVIEVERSION] = "BizHawk v2.0.0";

View File

@ -1,118 +1,118 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
internal class BkmHeader : Dictionary<string, string> internal class BkmHeader : Dictionary<string, string>
{ {
public BkmHeader() public BkmHeader()
{ {
Comments = new List<string>(); Comments = new List<string>();
Subtitles = new SubtitleList(); Subtitles = new SubtitleList();
this[HeaderKeys.EMULATIONVERSION] = VersionInfo.GetEmuVersion(); this[HeaderKeys.EMULATIONVERSION] = VersionInfo.GetEmuVersion();
this[HeaderKeys.PLATFORM] = Global.Emulator != null ? Global.Emulator.SystemId : ""; this[HeaderKeys.PLATFORM] = Global.Emulator != null ? Global.Emulator.SystemId : "";
this[HeaderKeys.GAMENAME] = ""; this[HeaderKeys.GAMENAME] = "";
this[HeaderKeys.AUTHOR] = ""; this[HeaderKeys.AUTHOR] = "";
this[HeaderKeys.RERECORDS] = "0"; this[HeaderKeys.RERECORDS] = "0";
} }
public List<string> Comments { get; } public List<string> Comments { get; }
public SubtitleList Subtitles { get; } public SubtitleList Subtitles { get; }
public string SavestateBinaryBase64Blob public string SavestateBinaryBase64Blob
{ {
get get
{ {
if (ContainsKey(HeaderKeys.SAVESTATEBINARYBASE64BLOB)) if (ContainsKey(HeaderKeys.SAVESTATEBINARYBASE64BLOB))
{ {
return this[HeaderKeys.SAVESTATEBINARYBASE64BLOB]; return this[HeaderKeys.SAVESTATEBINARYBASE64BLOB];
} }
return null; return null;
} }
set set
{ {
if (value == null) if (value == null)
{ {
Remove(HeaderKeys.SAVESTATEBINARYBASE64BLOB); Remove(HeaderKeys.SAVESTATEBINARYBASE64BLOB);
} }
else else
{ {
Add(HeaderKeys.SAVESTATEBINARYBASE64BLOB, value); Add(HeaderKeys.SAVESTATEBINARYBASE64BLOB, value);
} }
} }
} }
public new string this[string key] public new string this[string key]
{ {
get => ContainsKey(key) ? base[key] : ""; get => ContainsKey(key) ? base[key] : "";
set set
{ {
if (ContainsKey(key)) if (ContainsKey(key))
{ {
base[key] = value; base[key] = value;
} }
else else
{ {
Add(key, value); Add(key, value);
} }
} }
} }
public new void Clear() public new void Clear()
{ {
Comments.Clear(); Comments.Clear();
Subtitles.Clear(); Subtitles.Clear();
base.Clear(); base.Clear();
} }
public override string ToString() public override string ToString()
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
foreach (var kvp in this) foreach (var kvp in this)
{ {
sb sb
.Append(kvp.Key) .Append(kvp.Key)
.Append(' ') .Append(' ')
.Append(kvp.Value) .Append(kvp.Value)
.AppendLine(); .AppendLine();
} }
sb.Append(Subtitles); sb.Append(Subtitles);
Comments.ForEach(comment => sb.AppendLine(comment)); Comments.ForEach(comment => sb.AppendLine(comment));
return sb.ToString(); return sb.ToString();
} }
public bool ParseLineFromFile(string line) public bool ParseLineFromFile(string line)
{ {
if (!string.IsNullOrWhiteSpace(line)) if (!string.IsNullOrWhiteSpace(line))
{ {
var splitLine = line.Split(new[] { ' ' }, 2); var splitLine = line.Split(new[] { ' ' }, 2);
if (HeaderKeys.Contains(splitLine[0]) && !ContainsKey(splitLine[0])) if (HeaderKeys.Contains(splitLine[0]) && !ContainsKey(splitLine[0]))
{ {
Add(splitLine[0], splitLine[1]); Add(splitLine[0], splitLine[1]);
} }
else if (line.StartsWith("subtitle") || line.StartsWith("sub")) else if (line.StartsWith("subtitle") || line.StartsWith("sub"))
{ {
Subtitles.AddFromString(line); Subtitles.AddFromString(line);
} }
else if (line.StartsWith("comment")) else if (line.StartsWith("comment"))
{ {
Comments.Add(line.Substring(8, line.Length - 8)); Comments.Add(line.Substring(8, line.Length - 8));
} }
else if (line.StartsWith("|")) else if (line.StartsWith("|"))
{ {
return false; return false;
} }
} }
return true; return true;
} }
} }
} }

View File

@ -1,237 +1,237 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
internal static class BkmMnemonicConstants internal static class BkmMnemonicConstants
{ {
public static readonly Dictionary<string, Dictionary<string, string>> Buttons = new Dictionary<string, Dictionary<string, string>> public static readonly Dictionary<string, Dictionary<string, string>> Buttons = new Dictionary<string, Dictionary<string, string>>
{ {
{ {
"Gameboy Controller", new Dictionary<string, string> "Gameboy Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "A", "A" } { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "A", "A" }
} }
}, },
{ {
"Lynx Controller", new Dictionary<string, string> "Lynx Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "A", "A" } { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "A", "A" }
} }
}, },
{ {
"GBA Controller", new Dictionary<string, string> "GBA Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" },
{ "A", "A" }, { "L", "L" }, { "R", "R" } { "A", "A" }, { "L", "L" }, { "R", "R" }
} }
}, },
{ {
"Genesis 3-Button Controller", new Dictionary<string, string> "Genesis 3-Button Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Start", "S" }, { "A", "A" }, { "B", "B" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Start", "S" }, { "A", "A" }, { "B", "B" },
{ "C", "C" } { "C", "C" }
} }
}, },
{ {
"GPGX Genesis Controller", new Dictionary<string, string> "GPGX Genesis Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "A", "A" }, { "B", "B" }, { "C", "C" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "A", "A" }, { "B", "B" }, { "C", "C" },
{ "Start", "S" }, { "X", "X" }, { "Y", "Y" }, { "Z", "Z" }, { "Mode", "M" } { "Start", "S" }, { "X", "X" }, { "Y", "Y" }, { "Z", "Z" }, { "Mode", "M" }
} }
}, },
{ {
"GPGX 3-Button Controller", new Dictionary<string, string> "GPGX 3-Button Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "A", "A" }, { "B", "B" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "A", "A" }, { "B", "B" },
{ "C", "C" }, { "Start", "S" }, { "C", "C" }, { "Start", "S" },
} }
}, },
{ {
"NES Controller", new Dictionary<string, string> "NES Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" },
{ "A", "A" } { "A", "A" }
} }
}, },
{ {
"SNES Controller", new Dictionary<string, string> "SNES Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" },
{ "A", "A" }, { "X", "X" }, { "Y", "Y" }, { "L", "L" }, { "R", "R" } { "A", "A" }, { "X", "X" }, { "Y", "Y" }, { "L", "L" }, { "R", "R" }
} }
}, },
{ {
"PC Engine Controller", new Dictionary<string, string> "PC Engine Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Run", "r" }, { "B2", "2" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Run", "r" }, { "B2", "2" },
{ "B1", "1" } { "B1", "1" }
} }
}, },
{ {
"SMS Controller", new Dictionary<string, string> "SMS Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "B1", "1" }, { "B2", "2" } { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "B1", "1" }, { "B2", "2" }
} }
}, },
{ {
"TI83 Controller", new Dictionary<string, string> "TI83 Controller", new Dictionary<string, string>
{ {
{ "0", "0" }, { "1", "1" }, { "2", "2" }, { "3", "3" }, { "4", "4" }, { "5", "5" }, { "6", "6" }, { "7", "7" }, { "0", "0" }, { "1", "1" }, { "2", "2" }, { "3", "3" }, { "4", "4" }, { "5", "5" }, { "6", "6" }, { "7", "7" },
{ "8", "8" }, { "9", "9" }, { "DOT", "`" }, { "ON", "O" }, { "ENTER", "=" }, { "UP", "U" }, { "DOWN", "D" }, { "8", "8" }, { "9", "9" }, { "DOT", "`" }, { "ON", "O" }, { "ENTER", "=" }, { "UP", "U" }, { "DOWN", "D" },
{ "LEFT", "L" }, { "RIGHT", "R" }, { "PLUS", "+" }, { "MINUS", "_" }, { "MULTIPLY", "*" }, { "DIVIDE", "/" }, { "LEFT", "L" }, { "RIGHT", "R" }, { "PLUS", "+" }, { "MINUS", "_" }, { "MULTIPLY", "*" }, { "DIVIDE", "/" },
{ "CLEAR", "c" }, { "EXP", "^" }, { "DASH", "-" }, { "PARAOPEN", "(" }, { "PARACLOSE", ")" }, { "TAN", "T" }, { "CLEAR", "c" }, { "EXP", "^" }, { "DASH", "-" }, { "PARAOPEN", "(" }, { "PARACLOSE", ")" }, { "TAN", "T" },
{ "VARS", "V" }, { "COS", "C" }, { "PRGM", "P" }, { "STAT", "s" }, { "MATRIX", "m" }, { "X", "X" }, { "STO", ">" }, { "VARS", "V" }, { "COS", "C" }, { "PRGM", "P" }, { "STAT", "s" }, { "MATRIX", "m" }, { "X", "X" }, { "STO", ">" },
{ "LN", "n" }, { "LOG", "L" }, { "SQUARED", "2" }, { "NEG1", "1" }, { "MATH", "H" }, { "ALPHA", "A" }, { "LN", "n" }, { "LOG", "L" }, { "SQUARED", "2" }, { "NEG1", "1" }, { "MATH", "H" }, { "ALPHA", "A" },
{ "GRAPH", "G" }, { "TRACE", "t" }, { "ZOOM", "Z" }, { "WINDOW", "W" }, { "Y", "Y" }, { "2ND", "&" }, { "MODE", "O" }, { "GRAPH", "G" }, { "TRACE", "t" }, { "ZOOM", "Z" }, { "WINDOW", "W" }, { "Y", "Y" }, { "2ND", "&" }, { "MODE", "O" },
{ "DEL", "D" }, { "COMMA", "," }, { "SIN", "S" } { "DEL", "D" }, { "COMMA", "," }, { "SIN", "S" }
} }
}, },
{ {
"Atari 2600 Basic Controller", new Dictionary<string, string> "Atari 2600 Basic Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Button", "B" } { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Button", "B" }
} }
}, },
{ {
"Atari 7800 ProLine Joystick Controller", new Dictionary<string, string> "Atari 7800 ProLine Joystick Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Trigger", "1" }, { "Trigger 2", "2" } { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Trigger", "1" }, { "Trigger 2", "2" }
} }
}, },
{ {
"Commodore 64 Controller", new Dictionary<string, string> "Commodore 64 Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Button", "B" } { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Button", "B" }
} }
}, },
{ {
"Commodore 64 Keyboard", new Dictionary<string, string> "Commodore 64 Keyboard", new Dictionary<string, string>
{ {
{ "Key F1", "1" }, { "Key F3", "3" }, { "Key F5", "5" }, { "Key F7", "7" }, { "Key F1", "1" }, { "Key F3", "3" }, { "Key F5", "5" }, { "Key F7", "7" },
{ "Key Left Arrow", "l" }, { "Key 1", "1" }, { "Key 2", "2" }, { "Key 3", "3" }, { "Key 4", "4" }, { "Key 5", "5" }, { "Key 6", "6" }, { "Key 7", "7" }, { "Key 8", "8" }, { "Key 9", "9" }, { "Key 0", "0" }, { "Key Plus", "+" }, { "Key Minus", "-" }, { "Key Pound", "l" }, { "Key Clear/Home", "c" }, { "Key Insert/Delete", "i" }, { "Key Left Arrow", "l" }, { "Key 1", "1" }, { "Key 2", "2" }, { "Key 3", "3" }, { "Key 4", "4" }, { "Key 5", "5" }, { "Key 6", "6" }, { "Key 7", "7" }, { "Key 8", "8" }, { "Key 9", "9" }, { "Key 0", "0" }, { "Key Plus", "+" }, { "Key Minus", "-" }, { "Key Pound", "l" }, { "Key Clear/Home", "c" }, { "Key Insert/Delete", "i" },
{ "Key Control", "c" }, { "Key Q", "Q" }, { "Key W", "W" }, { "Key E", "E" }, { "Key R", "R" }, { "Key T", "T" }, { "Key Y", "Y" }, { "Key U", "U" }, { "Key I", "I" }, { "Key O", "O" }, { "Key P", "P" }, { "Key At", "@" }, { "Key Asterisk", "*" }, { "Key Up Arrow", "u" }, { "Key Restore", "r" }, { "Key Control", "c" }, { "Key Q", "Q" }, { "Key W", "W" }, { "Key E", "E" }, { "Key R", "R" }, { "Key T", "T" }, { "Key Y", "Y" }, { "Key U", "U" }, { "Key I", "I" }, { "Key O", "O" }, { "Key P", "P" }, { "Key At", "@" }, { "Key Asterisk", "*" }, { "Key Up Arrow", "u" }, { "Key Restore", "r" },
{ "Key Run/Stop", "s" }, { "Key Lck", "k" }, { "Key A", "A" }, { "Key S", "S" }, { "Key D", "D" }, { "Key F", "F" }, { "Key G", "G" }, { "Key H", "H" }, { "Key J", "J" }, { "Key K", "K" }, { "Key L", "L" }, { "Key Colon", ":" }, { "Key Semicolon", ";" }, { "Key Equal", "=" }, { "Key Return", "e" }, { "Key Run/Stop", "s" }, { "Key Lck", "k" }, { "Key A", "A" }, { "Key S", "S" }, { "Key D", "D" }, { "Key F", "F" }, { "Key G", "G" }, { "Key H", "H" }, { "Key J", "J" }, { "Key K", "K" }, { "Key L", "L" }, { "Key Colon", ":" }, { "Key Semicolon", ";" }, { "Key Equal", "=" }, { "Key Return", "e" },
{ "Key Commodore", "o" }, { "Key Left Shift", "s" }, { "Key Z", "Z" }, { "Key X", "X" }, { "Key C", "C" }, { "Key V", "V" }, { "Key B", "B" }, { "Key N", "N" }, { "Key M", "M" }, { "Key Comma", "," }, { "Key Period", ">" }, { "Key Slash", "/" }, { "Key Right Shift", "s" }, { "Key Cursor Up/Down", "u" }, { "Key Cursor Left/Right", "l" }, { "Key Commodore", "o" }, { "Key Left Shift", "s" }, { "Key Z", "Z" }, { "Key X", "X" }, { "Key C", "C" }, { "Key V", "V" }, { "Key B", "B" }, { "Key N", "N" }, { "Key M", "M" }, { "Key Comma", "," }, { "Key Period", ">" }, { "Key Slash", "/" }, { "Key Right Shift", "s" }, { "Key Cursor Up/Down", "u" }, { "Key Cursor Left/Right", "l" },
{ "Key Space", "_" } { "Key Space", "_" }
} }
}, },
{ {
"ColecoVision Basic Controller", new Dictionary<string, string> "ColecoVision Basic Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "L", "l" }, { "R", "r" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "L", "l" }, { "R", "r" },
{ "Key1", "1" }, { "Key2", "2" }, { "Key3", "3" }, { "Key4", "4" }, { "Key5", "5" }, { "Key6", "6" }, { "Key1", "1" }, { "Key2", "2" }, { "Key3", "3" }, { "Key4", "4" }, { "Key5", "5" }, { "Key6", "6" },
{ "Key7", "7" }, { "Key8", "8" }, { "Key9", "9" }, { "Star", "*" }, { "Key0", "0" }, { "Pound", "#" } { "Key7", "7" }, { "Key8", "8" }, { "Key9", "9" }, { "Star", "*" }, { "Key0", "0" }, { "Pound", "#" }
} }
}, },
{ {
"Nintendo 64 Controller", new Dictionary<string, string> "Nintendo 64 Controller", new Dictionary<string, string>
{ {
{ "DPad U", "U" }, { "DPad D", "D" }, { "DPad L", "L" }, { "DPad R", "R" }, { "DPad U", "U" }, { "DPad D", "D" }, { "DPad L", "L" }, { "DPad R", "R" },
{ "B", "B" }, { "A", "A" }, { "Z", "Z" }, { "Start", "S" }, { "L", "L" }, { "R", "R" }, { "B", "B" }, { "A", "A" }, { "Z", "Z" }, { "Start", "S" }, { "L", "L" }, { "R", "R" },
{ "C Up", "u" }, { "C Down", "d" }, { "C Left", "l" }, { "C Right", "r" } { "C Up", "u" }, { "C Down", "d" }, { "C Left", "l" }, { "C Right", "r" }
} }
}, },
{ {
"Saturn Controller", new Dictionary<string, string> "Saturn Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" },
{ "Start", "S" }, { "X", "X" }, { "Y", "Y" }, { "Z", "Z" }, { "A", "A" }, { "B", "B" }, { "C", "C" }, { "Start", "S" }, { "X", "X" }, { "Y", "Y" }, { "Z", "Z" }, { "A", "A" }, { "B", "B" }, { "C", "C" },
{ "L", "l" }, { "R", "r" }, { "L", "l" }, { "R", "r" },
} }
} }
}; };
public static readonly Dictionary<string, Dictionary<string, string>> Analogs = new Dictionary<string, Dictionary<string, string>> public static readonly Dictionary<string, Dictionary<string, string>> Analogs = new Dictionary<string, Dictionary<string, string>>
{ {
{ "Nintendo 64 Controller", new Dictionary<string, string> { { "X Axis", "X" }, { "Y Axis", "Y" } } } { "Nintendo 64 Controller", new Dictionary<string, string> { { "X Axis", "X" }, { "Y Axis", "Y" } } }
}; };
public static readonly Dictionary<string, Dictionary<string, string>> Commands = new Dictionary<string, Dictionary<string, string>> public static readonly Dictionary<string, Dictionary<string, string>> Commands = new Dictionary<string, Dictionary<string, string>>
{ {
{ "Atari 2600 Basic Controller", new Dictionary<string, string> { { "Reset", "r" }, { "Select", "s" } } }, { "Atari 2600 Basic Controller", new Dictionary<string, string> { { "Reset", "r" }, { "Select", "s" } } },
{ "Atari 7800 ProLine Joystick Controller", new Dictionary<string, string> { { "Reset", "r" }, { "Select", "s" } } }, { "Atari 7800 ProLine Joystick Controller", new Dictionary<string, string> { { "Reset", "r" }, { "Select", "s" } } },
{ "Gameboy Controller", new Dictionary<string, string> { { "Power", "P" } } }, { "Gameboy Controller", new Dictionary<string, string> { { "Power", "P" } } },
{ "GBA Controller", new Dictionary<string, string> { { "Power", "P" } } }, { "GBA Controller", new Dictionary<string, string> { { "Power", "P" } } },
{ "Genesis 3-Button Controller", new Dictionary<string, string> { { "Reset", "r" } } }, { "Genesis 3-Button Controller", new Dictionary<string, string> { { "Reset", "r" } } },
{ "GPGX Genesis Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } }, { "GPGX Genesis Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } },
{ "NES Controller", new Dictionary<string, string> { { "Reset", "r" }, { "Power", "P" }, { "FDS Eject", "E" }, { "FDS Insert 0", "0" }, { "FDS Insert 1", "1" }, { "VS Coin 1", "c" }, { "VS Coin 2", "C" } } }, { "NES Controller", new Dictionary<string, string> { { "Reset", "r" }, { "Power", "P" }, { "FDS Eject", "E" }, { "FDS Insert 0", "0" }, { "FDS Insert 1", "1" }, { "VS Coin 1", "c" }, { "VS Coin 2", "C" } } },
{ "SNES Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } }, { "SNES Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } },
{ "PC Engine Controller", new Dictionary<string, string>() }, { "PC Engine Controller", new Dictionary<string, string>() },
{ "SMS Controller", new Dictionary<string, string> { { "Pause", "p" }, { "Reset", "r" } } }, { "SMS Controller", new Dictionary<string, string> { { "Pause", "p" }, { "Reset", "r" } } },
{ "TI83 Controller", new Dictionary<string, string>() }, { "TI83 Controller", new Dictionary<string, string>() },
{ "Nintendo 64 Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } }, { "Nintendo 64 Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } },
{ "Saturn Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } }, { "Saturn Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } },
{ "GPGX 3-Button Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } } { "GPGX 3-Button Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } }
}; };
public static readonly Dictionary<string, int> Players = new Dictionary<string, int> public static readonly Dictionary<string, int> Players = new Dictionary<string, int>
{ {
{ "Gameboy Controller", 1 }, { "GBA Controller", 1 }, { "Genesis 3-Button Controller", 2 }, { "GPGX Genesis Controller", 2 }, { "NES Controller", 4 }, { "Gameboy Controller", 1 }, { "GBA Controller", 1 }, { "Genesis 3-Button Controller", 2 }, { "GPGX Genesis Controller", 2 }, { "NES Controller", 4 },
{ "SNES Controller", 4 }, { "PC Engine Controller", 5 }, { "SMS Controller", 2 }, { "TI83 Controller", 1 }, { "Atari 2600 Basic Controller", 2 }, { "Atari 7800 ProLine Joystick Controller", 2 }, { "SNES Controller", 4 }, { "PC Engine Controller", 5 }, { "SMS Controller", 2 }, { "TI83 Controller", 1 }, { "Atari 2600 Basic Controller", 2 }, { "Atari 7800 ProLine Joystick Controller", 2 },
{ "ColecoVision Basic Controller", 2 }, { "Commodore 64 Controller", 2 }, { "Nintendo 64 Controller", 4 }, { "Saturn Controller", 2 }, { "ColecoVision Basic Controller", 2 }, { "Commodore 64 Controller", 2 }, { "Nintendo 64 Controller", 4 }, { "Saturn Controller", 2 },
{ "GPGX 3-Button Controller", 2 }, { "Lynx Controller", 1 } { "GPGX 3-Button Controller", 2 }, { "Lynx Controller", 1 }
}; };
// just experimenting with different possibly more painful ways to handle mnemonics // just experimenting with different possibly more painful ways to handle mnemonics
// |P|UDLRsSBA| // |P|UDLRsSBA|
public static readonly Tuple<string, char>[] DgbMnemonic = public static readonly Tuple<string, char>[] DgbMnemonic =
{ {
new Tuple<string, char>(null, '|'), new Tuple<string, char>(null, '|'),
new Tuple<string, char>("P1 Power", 'P'), new Tuple<string, char>("P1 Power", 'P'),
new Tuple<string, char>(null, '|'), new Tuple<string, char>(null, '|'),
new Tuple<string, char>("P1 Up", 'U'), new Tuple<string, char>("P1 Up", 'U'),
new Tuple<string, char>("P1 Down", 'D'), new Tuple<string, char>("P1 Down", 'D'),
new Tuple<string, char>("P1 Left", 'L'), new Tuple<string, char>("P1 Left", 'L'),
new Tuple<string, char>("P1 Right", 'R'), new Tuple<string, char>("P1 Right", 'R'),
new Tuple<string, char>("P1 Select", 's'), new Tuple<string, char>("P1 Select", 's'),
new Tuple<string, char>("P1 Start", 'S'), new Tuple<string, char>("P1 Start", 'S'),
new Tuple<string, char>("P1 B", 'B'), new Tuple<string, char>("P1 B", 'B'),
new Tuple<string, char>("P1 A", 'A'), new Tuple<string, char>("P1 A", 'A'),
new Tuple<string, char>(null, '|'), new Tuple<string, char>(null, '|'),
new Tuple<string, char>("P2 Power", 'P'), new Tuple<string, char>("P2 Power", 'P'),
new Tuple<string, char>(null, '|'), new Tuple<string, char>(null, '|'),
new Tuple<string, char>("P2 Up", 'U'), new Tuple<string, char>("P2 Up", 'U'),
new Tuple<string, char>("P2 Down", 'D'), new Tuple<string, char>("P2 Down", 'D'),
new Tuple<string, char>("P2 Left", 'L'), new Tuple<string, char>("P2 Left", 'L'),
new Tuple<string, char>("P2 Right", 'R'), new Tuple<string, char>("P2 Right", 'R'),
new Tuple<string, char>("P2 Select", 's'), new Tuple<string, char>("P2 Select", 's'),
new Tuple<string, char>("P2 Start", 'S'), new Tuple<string, char>("P2 Start", 'S'),
new Tuple<string, char>("P2 B", 'B'), new Tuple<string, char>("P2 B", 'B'),
new Tuple<string, char>("P2 A", 'A'), new Tuple<string, char>("P2 A", 'A'),
new Tuple<string, char>(null, '|') new Tuple<string, char>(null, '|')
}; };
public static readonly Tuple<string, char>[] WsMnemonic = public static readonly Tuple<string, char>[] WsMnemonic =
{ {
new Tuple<string, char>(null, '|'), new Tuple<string, char>(null, '|'),
new Tuple<string, char>("P1 X1", '1'), new Tuple<string, char>("P1 X1", '1'),
new Tuple<string, char>("P1 X3", '3'), new Tuple<string, char>("P1 X3", '3'),
new Tuple<string, char>("P1 X4", '4'), new Tuple<string, char>("P1 X4", '4'),
new Tuple<string, char>("P1 X2", '2'), new Tuple<string, char>("P1 X2", '2'),
new Tuple<string, char>("P1 Y1", '1'), new Tuple<string, char>("P1 Y1", '1'),
new Tuple<string, char>("P1 Y3", '3'), new Tuple<string, char>("P1 Y3", '3'),
new Tuple<string, char>("P1 Y4", '4'), new Tuple<string, char>("P1 Y4", '4'),
new Tuple<string, char>("P1 Y2", '2'), new Tuple<string, char>("P1 Y2", '2'),
new Tuple<string, char>("P1 Start", 'S'), new Tuple<string, char>("P1 Start", 'S'),
new Tuple<string, char>("P1 B", 'B'), new Tuple<string, char>("P1 B", 'B'),
new Tuple<string, char>("P1 A", 'A'), new Tuple<string, char>("P1 A", 'A'),
new Tuple<string, char>(null, '|'), new Tuple<string, char>(null, '|'),
new Tuple<string, char>("P2 X1", '1'), new Tuple<string, char>("P2 X1", '1'),
new Tuple<string, char>("P2 X3", '3'), new Tuple<string, char>("P2 X3", '3'),
new Tuple<string, char>("P2 X4", '4'), new Tuple<string, char>("P2 X4", '4'),
new Tuple<string, char>("P2 X2", '2'), new Tuple<string, char>("P2 X2", '2'),
new Tuple<string, char>("P2 Y1", '1'), new Tuple<string, char>("P2 Y1", '1'),
new Tuple<string, char>("P2 Y3", '3'), new Tuple<string, char>("P2 Y3", '3'),
new Tuple<string, char>("P2 Y4", '4'), new Tuple<string, char>("P2 Y4", '4'),
new Tuple<string, char>("P2 Y2", '2'), new Tuple<string, char>("P2 Y2", '2'),
new Tuple<string, char>("P2 Start", 'S'), new Tuple<string, char>("P2 Start", 'S'),
new Tuple<string, char>("P2 B", 'B'), new Tuple<string, char>("P2 B", 'B'),
new Tuple<string, char>("P2 A", 'A'), new Tuple<string, char>("P2 A", 'A'),
new Tuple<string, char>(null, '|'), new Tuple<string, char>(null, '|'),
new Tuple<string, char>("Power", 'P'), new Tuple<string, char>("Power", 'P'),
new Tuple<string, char>("Rotate", 'R'), new Tuple<string, char>("Rotate", 'R'),
new Tuple<string, char>(null, '|') new Tuple<string, char>(null, '|')
}; };
} }
} }

View File

@ -1,150 +1,150 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
internal class BkmMovie internal class BkmMovie
{ {
private readonly List<string> _log = new List<string>(); private readonly List<string> _log = new List<string>();
private int? _loopOffset; private int? _loopOffset;
public BkmMovie() public BkmMovie()
{ {
Header = new BkmHeader { [HeaderKeys.MOVIEVERSION] = "BizHawk v0.0.1" }; Header = new BkmHeader { [HeaderKeys.MOVIEVERSION] = "BizHawk v0.0.1" };
} }
public string PreferredExtension => "bkm"; public string PreferredExtension => "bkm";
public BkmHeader Header { get; } public BkmHeader Header { get; }
public string Filename { get; set; } = ""; public string Filename { get; set; } = "";
public bool Loaded { get; private set; } public bool Loaded { get; private set; }
public int InputLogLength => _log.Count; public int InputLogLength => _log.Count;
public double FrameCount public double FrameCount
{ {
get get
{ {
if (_loopOffset.HasValue) if (_loopOffset.HasValue)
{ {
return double.PositiveInfinity; return double.PositiveInfinity;
} }
if (Loaded) if (Loaded)
{ {
return _log.Count; return _log.Count;
} }
return 0; return 0;
} }
} }
public BkmControllerAdapter GetInputState(int frame) public BkmControllerAdapter GetInputState(int frame)
{ {
if (frame < FrameCount && frame >= 0) if (frame < FrameCount && frame >= 0)
{ {
int getFrame; int getFrame;
if (_loopOffset.HasValue) if (_loopOffset.HasValue)
{ {
if (frame < _log.Count) if (frame < _log.Count)
{ {
getFrame = frame; getFrame = frame;
} }
else else
{ {
getFrame = ((frame - _loopOffset.Value) % (_log.Count - _loopOffset.Value)) + _loopOffset.Value; getFrame = ((frame - _loopOffset.Value) % (_log.Count - _loopOffset.Value)) + _loopOffset.Value;
} }
} }
else else
{ {
getFrame = frame; getFrame = frame;
} }
var adapter = new BkmControllerAdapter var adapter = new BkmControllerAdapter
{ {
Definition = Global.MovieSession.MovieControllerAdapter.Definition Definition = Global.MovieSession.MovieControllerAdapter.Definition
}; };
adapter.SetControllersAsMnemonic(_log[getFrame]); adapter.SetControllersAsMnemonic(_log[getFrame]);
return adapter; return adapter;
} }
return null; return null;
} }
public IDictionary<string, string> HeaderEntries => Header; public IDictionary<string, string> HeaderEntries => Header;
public SubtitleList Subtitles => Header.Subtitles; public SubtitleList Subtitles => Header.Subtitles;
public IList<string> Comments => Header.Comments; public IList<string> Comments => Header.Comments;
public string SyncSettingsJson public string SyncSettingsJson
{ {
get => Header[HeaderKeys.SYNCSETTINGS]; get => Header[HeaderKeys.SYNCSETTINGS];
set => Header[HeaderKeys.SYNCSETTINGS] = value; set => Header[HeaderKeys.SYNCSETTINGS] = value;
} }
public string TextSavestate { get; set; } public string TextSavestate { get; set; }
public byte[] BinarySavestate { get; set; } public byte[] BinarySavestate { get; set; }
public bool Load() public bool Load()
{ {
var file = new FileInfo(Filename); var file = new FileInfo(Filename);
if (file.Exists == false) if (file.Exists == false)
{ {
Loaded = false; Loaded = false;
return false; return false;
} }
Header.Clear(); Header.Clear();
_log.Clear(); _log.Clear();
using (var sr = file.OpenText()) using (var sr = file.OpenText())
{ {
string line; string line;
while ((line = sr.ReadLine()) != null) while ((line = sr.ReadLine()) != null)
{ {
if (line == "") if (line == "")
{ {
continue; continue;
} }
if (line.Contains("LoopOffset")) if (line.Contains("LoopOffset"))
{ {
try try
{ {
_loopOffset = int.Parse(line.Split(new[] { ' ' }, 2)[1]); _loopOffset = int.Parse(line.Split(new[] { ' ' }, 2)[1]);
} }
catch (Exception) catch (Exception)
{ {
continue; continue;
} }
} }
else if (Header.ParseLineFromFile(line)) else if (Header.ParseLineFromFile(line))
{ {
continue; continue;
} }
else if (line.StartsWith("|")) else if (line.StartsWith("|"))
{ {
_log.Add(line); _log.Add(line);
} }
else else
{ {
Header.Comments.Add(line); Header.Comments.Add(line);
} }
} }
} }
if (Header.SavestateBinaryBase64Blob != null) if (Header.SavestateBinaryBase64Blob != null)
{ {
BinarySavestate = Convert.FromBase64String(Header.SavestateBinaryBase64Blob); BinarySavestate = Convert.FromBase64String(Header.SavestateBinaryBase64Blob);
} }
Loaded = true; Loaded = true;
return true; return true;
} }
} }
} }

View File

@ -6,17 +6,42 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
public enum MovieMode
{
/// <summary>
/// There is no movie loaded
/// </summary>
Inactive,
/// <summary>
/// The movie is in playback mode
/// </summary>
Play,
/// <summary>
/// The movie is currently recording
/// </summary>
Record,
/// <summary>
/// The movie has played past the end, but is still loaded in memory
/// </summary>
Finished
}
// TODO: message callback / event handler // TODO: message callback / event handler
// TODO: consider other event handlers, switching modes? // TODO: consider other event handlers, switching modes?
public interface IMovie public interface IMovie
{ {
#region Status #region Status
/// <summary>
/// Gets the current movie mode
/// </summary>
MovieMode Mode { get; }
bool IsCountingRerecords { get; set; } bool IsCountingRerecords { get; set; }
bool IsActive { get; }
bool IsPlaying { get; }
bool IsRecording { get; }
bool IsFinished { get; }
bool Changes { get; } bool Changes { get; }
#endregion #endregion
@ -218,4 +243,14 @@ namespace BizHawk.Client.Common
#endregion #endregion
} }
public static class MovieExtensions
{
public static bool IsActive(this IMovie movie) => movie.Mode != MovieMode.Inactive;
public static bool NotActive(this IMovie movie) => movie.Mode == MovieMode.Inactive;
public static bool IsPlaying(this IMovie movie) => movie.Mode == MovieMode.Play || movie.Mode == MovieMode.Finished;
public static bool IsRecording(this IMovie movie) => movie.Mode == MovieMode.Record;
public static bool IsFinished(this IMovie movie) => movie.Mode == MovieMode.Finished;
public static bool IsPlayingOrRecording(this IMovie movie) => movie.Mode == MovieMode.Play && movie.Mode == MovieMode.Record;
}
} }

View File

@ -22,7 +22,7 @@ namespace BizHawk.Client.Common
TasLagLog.RemoveFrom(frame); TasLagLog.RemoveFrom(frame);
TasLagLog[frame] = Global.Emulator.AsInputPollable().IsLagFrame; TasLagLog[frame] = Global.Emulator.AsInputPollable().IsLagFrame;
if (IsRecording) if (this.IsRecording())
{ {
TasStateManager.Invalidate(frame + 1); TasStateManager.Invalidate(frame + 1);
} }

View File

@ -115,12 +115,12 @@ namespace BizHawk.Client.Common
public override void SwitchToPlay() public override void SwitchToPlay()
{ {
Mode = Moviemode.Play; Mode = MovieMode.Play;
} }
public override void SwitchToRecord() public override void SwitchToRecord()
{ {
Mode = Moviemode.Record; Mode = MovieMode.Record;
} }
/// <summary> /// <summary>
@ -379,7 +379,7 @@ namespace BizHawk.Client.Common
Truncate(Log.Count); Truncate(Log.Count);
} }
Mode = Moviemode.Finished; Mode = MovieMode.Finished;
} }
if (IsCountingRerecords) if (IsCountingRerecords)

View File

@ -313,7 +313,7 @@ namespace BizHawk.Client.Common
// each one records how to get back to the previous state, once we've gone back to // each one records how to get back to the previous state, once we've gone back to
// the second item, it's already resulted in the first state being loaded. The // the second item, it's already resulted in the first state being loaded. The
// first item is just a junk entry with the initial value of _lastState (0 bytes). // first item is just a junk entry with the initial value of _lastState (0 bytes).
if (_rewindBuffer.Count <= 1 || (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.InputLogLength == 0)) if (_rewindBuffer.Count <= 1 || (Global.MovieSession.Movie.IsActive() && Global.MovieSession.Movie.InputLogLength == 0))
{ {
break; break;
} }

View File

@ -1,10 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using BizHawk.Common.ReflectionExtensions;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Client.ApiHawk; using BizHawk.Client.ApiHawk;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -14,8 +12,8 @@ namespace BizHawk.Client.EmuHawk
{ {
public static class ApiManager public static class ApiManager
{ {
private static ApiContainer container; private static ApiContainer _container;
private static void Register(IEmulatorServiceProvider serviceProvider) private static IExternalApiProvider Register(IEmulatorServiceProvider serviceProvider)
{ {
foreach (var api in Assembly.Load("BizHawk.Client.Common").GetTypes() foreach (var api in Assembly.Load("BizHawk.Client.Common").GetTypes()
.Concat(Assembly.Load("BizHawk.Client.ApiHawk").GetTypes()) .Concat(Assembly.Load("BizHawk.Client.ApiHawk").GetTypes())
@ -26,14 +24,15 @@ namespace BizHawk.Client.EmuHawk
ServiceInjector.UpdateServices(serviceProvider, instance); ServiceInjector.UpdateServices(serviceProvider, instance);
Libraries.Add(api, instance); Libraries.Add(api, instance);
} }
container = new ApiContainer(Libraries); _container = new ApiContainer(Libraries);
GlobalWin.ApiProvider = new BasicApiProvider(container); return new BasicApiProvider(_container);
} }
private static readonly Dictionary<Type, IExternalApi> Libraries = new Dictionary<Type, IExternalApi>(); private static readonly Dictionary<Type, IExternalApi> Libraries = new Dictionary<Type, IExternalApi>();
public static void Restart(IEmulatorServiceProvider newServiceProvider) public static IExternalApiProvider Restart(IEmulatorServiceProvider newServiceProvider)
{ {
Libraries.Clear(); Libraries.Clear();
Register(newServiceProvider); return Register(newServiceProvider);
} }
} }
} }

View File

@ -491,7 +491,9 @@ namespace BizHawk.Client.EmuHawk
x -= Emulator.CoreComm.ScreenLogicalOffsetX; x -= Emulator.CoreComm.ScreenLogicalOffsetX;
y -= Emulator.CoreComm.ScreenLogicalOffsetY; y -= Emulator.CoreComm.ScreenLogicalOffsetY;
} }
GlobalWin.OSD.AddGuiText(message, x, y, Color.Black, forecolor ?? Color.White, a);
var pos = new MessagePosition{ X = x, Y = y, Anchor = (MessagePosition.AnchorType)a };
GlobalWin.OSD.AddGuiText(message, pos, Color.Black, forecolor ?? Color.White);
} }
public void Dispose() public void Dispose()

View File

@ -717,12 +717,6 @@
<Compile Include="movie\SubtitleMaker.Designer.cs"> <Compile Include="movie\SubtitleMaker.Designer.cs">
<DependentUpon>SubtitleMaker.cs</DependentUpon> <DependentUpon>SubtitleMaker.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="NameStateForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="NameStateForm.Designer.cs">
<DependentUpon>NameStateForm.cs</DependentUpon>
</Compile>
<Compile Include="OpenAdvancedChooser.cs"> <Compile Include="OpenAdvancedChooser.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@ -1172,7 +1166,7 @@
<Compile Include="tools\TI83\TI83KeyPad.Designer.cs"> <Compile Include="tools\TI83\TI83KeyPad.Designer.cs">
<DependentUpon>TI83KeyPad.cs</DependentUpon> <DependentUpon>TI83KeyPad.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="tools\ToolHelpers.cs"> <Compile Include="tools\ToolFormBase.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="tools\ToolManager.cs" /> <Compile Include="tools\ToolManager.cs" />
@ -1682,10 +1676,6 @@
<EmbeddedResource Include="movie\RecordMovie.resx"> <EmbeddedResource Include="movie\RecordMovie.resx">
<DependentUpon>RecordMovie.cs</DependentUpon> <DependentUpon>RecordMovie.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="NameStateForm.resx">
<DependentUpon>NameStateForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="OpenAdvancedChooser.resx"> <EmbeddedResource Include="OpenAdvancedChooser.resx">
<DependentUpon>OpenAdvancedChooser.cs</DependentUpon> <DependentUpon>OpenAdvancedChooser.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>

View File

@ -7,7 +7,6 @@ using System.Reflection;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common.IEmulatorExtensions; using BizHawk.Emulation.Common.IEmulatorExtensions;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
@ -18,7 +17,6 @@ namespace BizHawk.Client.EmuHawk
private class CoreInfo private class CoreInfo
{ {
public string CoreName { get; set; } public string CoreName { get; set; }
public string TypeName { get; set; }
public bool Released { get; set; } public bool Released { get; set; }
public Dictionary<string, ServiceInfo> Services { get; set; } public Dictionary<string, ServiceInfo> Services { get; set; }
public List<string> NotApplicableTypes { get; set; } public List<string> NotApplicableTypes { get; set; }
@ -26,7 +24,6 @@ namespace BizHawk.Client.EmuHawk
public CoreInfo() { } public CoreInfo() { }
public CoreInfo(IEmulator emu) public CoreInfo(IEmulator emu)
{ {
TypeName = emu.GetType().ToString();
CoreName = emu.Attributes().CoreName; CoreName = emu.Attributes().CoreName;
Released = emu.Attributes().Released; Released = emu.Attributes().Released;
Services = new Dictionary<string, ServiceInfo>(); Services = new Dictionary<string, ServiceInfo>();
@ -37,12 +34,12 @@ namespace BizHawk.Client.EmuHawk
Services.Add(si.TypeName, si); Services.Add(si.TypeName, si);
} }
var notapplicableAttr = ((ServiceNotApplicableAttribute)Attribute var notApplicableAttribute = ((ServiceNotApplicableAttribute)Attribute
.GetCustomAttribute(emu.GetType(), typeof(ServiceNotApplicableAttribute))); .GetCustomAttribute(emu.GetType(), typeof(ServiceNotApplicableAttribute)));
if (notapplicableAttr != null) if (notApplicableAttribute != null)
{ {
NotApplicableTypes = notapplicableAttr.NotApplicableTypes NotApplicableTypes = notApplicableAttribute.NotApplicableTypes
.Select(x => x.ToString()) .Select(x => x.ToString())
.ToList(); .ToList();
} }
@ -60,23 +57,19 @@ namespace BizHawk.Client.EmuHawk
public List<FunctionInfo> Functions { get; set; } public List<FunctionInfo> Functions { get; set; }
public ServiceInfo() { } public ServiceInfo() { }
public ServiceInfo(Type servicetype, object service) public ServiceInfo(Type serviceType, object service)
{ {
if (servicetype.IsGenericType) TypeName = serviceType.IsGenericType
{ ? serviceType.GetGenericTypeDefinition().ToString()
TypeName = servicetype.GetGenericTypeDefinition().ToString(); : serviceType.ToString();
}
else
{
TypeName = servicetype.ToString();
}
Functions = new List<FunctionInfo>(); Functions = new List<FunctionInfo>();
IEnumerable<MethodInfo> methods = servicetype.GetMethods(); // .Concat(servicetype.GetProperties().Select(p => p.GetGetMethod())); IEnumerable<MethodInfo> methods = serviceType.GetMethods();
if (servicetype.IsInterface) if (serviceType.IsInterface)
{ {
var map = service.GetType().GetInterfaceMap(servicetype); var map = service.GetType().GetInterfaceMap(serviceType);
// project interface methods to actual implementations // project interface methods to actual implementations
methods = methods.Select( methods = methods.Select(
m => map.TargetMethods[Array.IndexOf(map.InterfaceMethods, m)]); m => map.TargetMethods[Array.IndexOf(map.InterfaceMethods, m)]);
@ -115,8 +108,9 @@ namespace BizHawk.Client.EmuHawk
#endregion #endregion
// ReSharper disable once UnusedAutoPropertyAccessor.Local
[RequiredService] [RequiredService]
IEmulator emu { get; set; } IEmulator Emulator { get; set; }
public CoreFeatureAnalysis() public CoreFeatureAnalysis()
{ {
@ -124,11 +118,6 @@ namespace BizHawk.Client.EmuHawk
KnownCores = new Dictionary<string, CoreInfo>(); KnownCores = new Dictionary<string, CoreInfo>();
} }
private void OkBtn_Click(object sender, EventArgs e)
{
Close();
}
public void NewUpdate(ToolFormUpdateType type) { } public void NewUpdate(ToolFormUpdateType type) { }
private TreeNode CreateCoreTree(CoreInfo ci) private TreeNode CreateCoreTree(CoreInfo ci)
@ -167,13 +156,13 @@ namespace BizHawk.Client.EmuHawk
} }
var knownServies = Assembly.GetAssembly(typeof(IEmulator)) var knownServices = Assembly.GetAssembly(typeof(IEmulator))
.GetTypes() .GetTypes()
.Where(t => typeof(IEmulatorService).IsAssignableFrom(t)) .Where(t => typeof(IEmulatorService).IsAssignableFrom(t))
.Where(t => t != typeof(IEmulatorService)) .Where(t => t != typeof(IEmulatorService))
.Where(t => t.IsInterface); .Where(t => t.IsInterface);
var additionalServices = knownServies var additionalServices = knownServices
.Where(t => !ci.Services.ContainsKey(t.ToString())) .Where(t => !ci.Services.ContainsKey(t.ToString()))
.Where(t => !ci.NotApplicableTypes.Contains(t.ToString())) .Where(t => !ci.NotApplicableTypes.Contains(t.ToString()))
.Where(t => !typeof(ISpecializedEmulatorService).IsAssignableFrom(t)); // We don't want to show these as unimplemented, they aren't expected services .Where(t => !typeof(ISpecializedEmulatorService).IsAssignableFrom(t)); // We don't want to show these as unimplemented, they aren't expected services
@ -215,7 +204,7 @@ namespace BizHawk.Client.EmuHawk
CoreTree.ImageList.Images.Add("Bad", Properties.Resources.ExclamationRed); CoreTree.ImageList.Images.Add("Bad", Properties.Resources.ExclamationRed);
CoreTree.ImageList.Images.Add("Unknown", Properties.Resources.RetroQuestion); CoreTree.ImageList.Images.Add("Unknown", Properties.Resources.RetroQuestion);
var possiblecoretypes = var possibleCoreTypes =
Assembly Assembly
.Load("BizHawk.Emulation.Cores") .Load("BizHawk.Emulation.Cores")
.GetTypes() .GetTypes()
@ -229,7 +218,7 @@ namespace BizHawk.Client.EmuHawk
.ThenBy(t => t.CoreAttributes.CoreName) .ThenBy(t => t.CoreAttributes.CoreName)
.ToList(); .ToList();
toolStripStatusLabel1.Text = $"Total: {possiblecoretypes.Count} Released: {KnownCores.Values.Count(c => c.Released)} Profiled: {KnownCores.Count}"; toolStripStatusLabel1.Text = $"Total: {possibleCoreTypes.Count} Released: {KnownCores.Values.Count(c => c.Released)} Profiled: {KnownCores.Count}";
CoreTree.Nodes.Clear(); CoreTree.Nodes.Clear();
CoreTree.BeginUpdate(); CoreTree.BeginUpdate();
@ -245,7 +234,7 @@ namespace BizHawk.Client.EmuHawk
CoreTree.Nodes.Add(coreNode); CoreTree.Nodes.Add(coreNode);
} }
foreach (var t in possiblecoretypes) foreach (var t in possibleCoreTypes)
{ {
if (!KnownCores.ContainsKey(t.CoreAttributes.CoreName)) if (!KnownCores.ContainsKey(t.CoreAttributes.CoreName))
{ {
@ -277,22 +266,16 @@ namespace BizHawk.Client.EmuHawk
public void Restart() public void Restart()
{ {
var ci = new CoreInfo(emu); var ci = new CoreInfo(Emulator);
KnownCores[ci.CoreName] = ci; KnownCores[ci.CoreName] = ci;
DoCurrentCoreTree(ci); DoCurrentCoreTree(ci);
DoAllCoresTree(ci); DoAllCoresTree(ci);
} }
public bool AskSaveChanges() public bool AskSaveChanges() => true;
{
return true;
}
public bool UpdateBefore public bool UpdateBefore => false;
{
get { return false; }
}
#endregion #endregion
} }

File diff suppressed because it is too large Load Diff

View File

@ -24,20 +24,18 @@ namespace BizHawk.Client.EmuHawk
Rectangle ClipBounds { get; set; } Rectangle ClipBounds { get; set; }
} }
class UIMessage public class UIMessage
{ {
public string Message; public string Message { get; set; }
public DateTime ExpireAt; public DateTime ExpireAt { get; set; }
} }
class UIDisplay public class UIDisplay
{ {
public string Message; public string Message { get; set; }
public int X; public MessagePosition Position { get; set; }
public int Y; public Color ForeColor { get; set; }
public int Anchor; public Color BackGround { get; set; }
public Color ForeColor;
public Color BackGround;
} }
public class OSDManager public class OSDManager
@ -53,41 +51,24 @@ namespace BizHawk.Client.EmuHawk
public Color FixedMessagesColor => Color.FromArgb(Global.Config.MessagesColor); public Color FixedMessagesColor => Color.FromArgb(Global.Config.MessagesColor);
public Color FixedAlertMessageColor => Color.FromArgb(Global.Config.AlertMessageColor); public Color FixedAlertMessageColor => Color.FromArgb(Global.Config.AlertMessageColor);
private float GetX(IBlitter g, int x, int anchor, string message) private PointF GetCoordinates(IBlitter g, MessagePosition position, string message)
{ {
var size = g.MeasureString(message, MessageFont); var size = g.MeasureString(message, MessageFont);
float x = position.Anchor.IsLeft()
? position.X
: g.ClipBounds.Width - position.X - size.Width;
switch (anchor) float y = position.Anchor.IsTop()
{ ? position.Y
default: : g.ClipBounds.Height - position.Y - size.Height;
case 0: //Top Left
case 2: //Bottom Left
return x;
case 1: //Top Right
case 3: //Bottom Right
return g.ClipBounds.Width - x - size.Width;
}
}
private float GetY(IBlitter g, int y, int anchor, string message) return new PointF(x, y);
{
var size = g.MeasureString(message, MessageFont);
switch (anchor)
{
default:
case 0: //Top Left
case 1: //Top Right
return y;
case 2: //Bottom Left
case 3: //Bottom Right
return g.ClipBounds.Height - y - size.Height;
}
} }
private string MakeFrameCounter() private string MakeFrameCounter()
{ {
if (Global.MovieSession.Movie.IsFinished) if (Global.MovieSession.Movie.IsFinished())
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
sb sb
@ -98,7 +79,7 @@ namespace BizHawk.Client.EmuHawk
return sb.ToString(); return sb.ToString();
} }
if (Global.MovieSession.Movie.IsPlaying) if (Global.MovieSession.Movie.IsPlaying())
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
sb sb
@ -109,11 +90,6 @@ namespace BizHawk.Client.EmuHawk
return sb.ToString(); return sb.ToString();
} }
if (Global.MovieSession.Movie.IsRecording)
{
return Global.Emulator.Frame.ToString();
}
return Global.Emulator.Frame.ToString(); return Global.Emulator.Frame.ToString();
} }
@ -125,16 +101,14 @@ namespace BizHawk.Client.EmuHawk
_messages.Add(new UIMessage { Message = message, ExpireAt = DateTime.Now + TimeSpan.FromSeconds(2) }); _messages.Add(new UIMessage { Message = message, ExpireAt = DateTime.Now + TimeSpan.FromSeconds(2) });
} }
public void AddGuiText(string message, int x, int y, Color backGround, Color foreColor, int anchor) public void AddGuiText(string message, MessagePosition pos, Color backGround, Color foreColor)
{ {
_guiTextList.Add(new UIDisplay _guiTextList.Add(new UIDisplay
{ {
Message = message, Message = message,
X = x, Position = pos,
Y = y,
BackGround = backGround, BackGround = backGround,
ForeColor = foreColor, ForeColor = foreColor
Anchor = anchor
}); });
} }
@ -143,6 +117,13 @@ namespace BizHawk.Client.EmuHawk
_guiTextList.Clear(); _guiTextList.Clear();
} }
private void DrawMessage(IBlitter g, UIMessage message, int yOffset)
{
var point = GetCoordinates(g, Global.Config.Messages, message.Message);
var y = point.Y + yOffset; // TODO: clean me up
g.DrawString(message.Message, MessageFont, FixedMessagesColor, point.X, y);
}
public void DrawMessages(IBlitter g) public void DrawMessages(IBlitter g)
{ {
if (!Global.Config.DisplayMessages) if (!Global.Config.DisplayMessages)
@ -151,43 +132,27 @@ namespace BizHawk.Client.EmuHawk
} }
_messages.RemoveAll(m => DateTime.Now > m.ExpireAt); _messages.RemoveAll(m => DateTime.Now > m.ExpireAt);
int line = 1;
if (Global.Config.StackOSDMessages)
{
for (int i = _messages.Count - 1; i >= 0; i--, line++)
{
float x = GetX(g, Global.Config.DispMessagex, Global.Config.DispMessageanchor, _messages[i].Message);
float y = GetY(g, Global.Config.DispMessagey, Global.Config.DispMessageanchor, _messages[i].Message);
if (Global.Config.DispMessageanchor < 2)
{
y += (line - 1) * 18;
}
else
{
y -= (line - 1) * 18;
}
g.DrawString(_messages[i].Message, MessageFont, FixedMessagesColor, x, y); if (_messages.Any())
{
if (Global.Config.StackOSDMessages)
{
int line = 1;
for (int i = _messages.Count - 1; i >= 0; i--, line++)
{
int yOffset = (line - 1) * 18;
if (!Global.Config.Messages.Anchor.IsTop())
{
yOffset = 0 - yOffset;
}
DrawMessage(g, _messages[i], yOffset);
}
} }
} else
else
{
if (_messages.Any())
{ {
int i = _messages.Count - 1; var message = _messages.Last();
DrawMessage(g, message, 0);
float x = GetX(g, Global.Config.DispMessagex, Global.Config.DispMessageanchor, _messages[i].Message);
float y = GetY(g, Global.Config.DispMessagey, Global.Config.DispMessageanchor, _messages[i].Message);
if (Global.Config.DispMessageanchor < 2)
{
y += (line - 1) * 18;
}
else
{
y -= (line - 1) * 18;
}
g.DrawString(_messages[i].Message, MessageFont, FixedMessagesColor, x, y);
} }
} }
@ -195,10 +160,8 @@ namespace BizHawk.Client.EmuHawk
{ {
try try
{ {
float posX = GetX(g, text.X, text.Anchor, text.Message); var point = GetCoordinates(g, text.Position, text.Message);
float posY = GetY(g, text.Y, text.Anchor, text.Message); g.DrawString(text.Message, MessageFont, text.ForeColor, point.X, point.Y);
g.DrawString(text.Message, MessageFont, text.ForeColor, posX, posY);
} }
catch (Exception) catch (Exception)
{ {
@ -225,7 +188,7 @@ namespace BizHawk.Client.EmuHawk
public string InputPrevious() public string InputPrevious()
{ {
if (Global.MovieSession.Movie.IsActive && !Global.MovieSession.Movie.IsFinished) if (Global.MovieSession.Movie.IsPlayingOrRecording())
{ {
var lg = Global.MovieSession.LogGeneratorInstance(); var lg = Global.MovieSession.LogGeneratorInstance();
var state = Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1); var state = Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1);
@ -241,11 +204,9 @@ namespace BizHawk.Client.EmuHawk
public string InputStrOrAll() public string InputStrOrAll()
{ {
var m = (Global.MovieSession.Movie.IsActive && var m = Global.MovieSession.Movie.IsPlayingOrRecording() && Global.Emulator.Frame > 0
!Global.MovieSession.Movie.IsFinished && ? Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1)
Global.Emulator.Frame > 0) ? : Global.MovieSession.MovieControllerInstance();
Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1) :
Global.MovieSession.MovieControllerInstance();
var lg = Global.MovieSession.LogGeneratorInstance(); var lg = Global.MovieSession.LogGeneratorInstance();
@ -262,11 +223,11 @@ namespace BizHawk.Client.EmuHawk
public string MakeIntersectImmediatePrevious() public string MakeIntersectImmediatePrevious()
{ {
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive())
{ {
var m = Global.MovieSession.Movie.IsActive && !Global.MovieSession.Movie.IsFinished ? var m = Global.MovieSession.Movie.IsPlayingOrRecording()
Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1) : ? Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1)
Global.MovieSession.MovieControllerInstance(); : Global.MovieSession.MovieControllerInstance();
var lg = Global.MovieSession.LogGeneratorInstance(); var lg = Global.MovieSession.LogGeneratorInstance();
lg.SetSource(Global.AutofireStickyXORAdapter.And(m)); lg.SetSource(Global.AutofireStickyXORAdapter.And(m));
@ -278,7 +239,7 @@ namespace BizHawk.Client.EmuHawk
public string MakeRerecordCount() public string MakeRerecordCount()
{ {
return Global.MovieSession.Movie.IsActive return Global.MovieSession.Movie.IsActive()
? Global.MovieSession.Movie.Rerecords.ToString() ? Global.MovieSession.Movie.Rerecords.ToString()
: ""; : "";
} }
@ -296,27 +257,24 @@ namespace BizHawk.Client.EmuHawk
if (Global.Config.DisplayFrameCounter && !Global.Game.IsNullInstance()) if (Global.Config.DisplayFrameCounter && !Global.Game.IsNullInstance())
{ {
string message = MakeFrameCounter(); string message = MakeFrameCounter();
float x = GetX(g, Global.Config.DispFrameCx, Global.Config.DispFrameanchor, message); var point = GetCoordinates(g, Global.Config.FrameCounter, message);
float y = GetY(g, Global.Config.DispFrameCy, Global.Config.DispFrameanchor, message); DrawOsdMessage(g, message, Color.FromArgb(Global.Config.MessagesColor), point.X, point.Y);
DrawOsdMessage(g, message, Color.FromArgb(Global.Config.MessagesColor), x, y);
if (GlobalWin.MainForm.IsLagFrame) if (GlobalWin.MainForm.IsLagFrame)
{ {
DrawOsdMessage(g, Global.Emulator.Frame.ToString(), FixedAlertMessageColor, x, y); DrawOsdMessage(g, Global.Emulator.Frame.ToString(), FixedAlertMessageColor, point.X, point.Y);
} }
} }
if (Global.Config.DisplayInput && !Global.Game.IsNullInstance()) if (Global.Config.DisplayInput && !Global.Game.IsNullInstance())
{ {
if ((Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished) if (Global.MovieSession.Movie.Mode == MovieMode.Play
|| (Global.MovieSession.Movie.IsFinished && Global.Emulator.Frame == Global.MovieSession.Movie.InputLogLength)) // Account for the last frame of the movie, the movie state is immediately "Finished" here but we still want to show the input || (Global.MovieSession.Movie.IsFinished() && Global.Emulator.Frame == Global.MovieSession.Movie.InputLogLength)) // Account for the last frame of the movie, the movie state is immediately "Finished" here but we still want to show the input
{ {
var input = InputStrMovie(); var input = InputStrMovie();
var x = GetX(g, Global.Config.DispInpx, Global.Config.DispInpanchor, input); var point = GetCoordinates(g, Global.Config.InputDisplay, input);
var y = GetY(g, Global.Config.DispInpy, Global.Config.DispInpanchor, input);
Color c = Color.FromArgb(Global.Config.MovieInput); Color c = Color.FromArgb(Global.Config.MovieInput);
g.DrawString(input, MessageFont, c, x, y); g.DrawString(input, MessageFont, c, point.X, point.Y);
} }
else // TODO: message config -- allow setting of "previous", "mixed", and "auto" else // TODO: message config -- allow setting of "previous", "mixed", and "auto"
@ -328,22 +286,21 @@ namespace BizHawk.Client.EmuHawk
//we need some kind of string for calculating position when right-anchoring, of something like that //we need some kind of string for calculating position when right-anchoring, of something like that
var bgStr = InputStrOrAll(); var bgStr = InputStrOrAll();
var x = GetX(g, Global.Config.DispInpx, Global.Config.DispInpanchor, bgStr); var point = GetCoordinates(g, Global.Config.InputDisplay, bgStr);
var y = GetY(g, Global.Config.DispInpy, Global.Config.DispInpanchor, bgStr);
// now, we're going to render these repeatedly, with higher-priority things overriding // now, we're going to render these repeatedly, with higher-priority things overriding
// first display previous frame's input. // first display previous frame's input.
// note: that's only available in case we're working on a movie // note: that's only available in case we're working on a movie
var previousStr = InputPrevious(); var previousStr = InputPrevious();
g.DrawString(previousStr, MessageFont, previousColor, x, y); g.DrawString(previousStr, MessageFont, previousColor, point.X, point.Y);
// next, draw the immediate input. // next, draw the immediate input.
// that is, whatever is being held down interactively right this moment even if the game is paused // that is, whatever is being held down interactively right this moment even if the game is paused
// this includes things held down due to autohold or autofire // this includes things held down due to autohold or autofire
// I know, this is all really confusing // I know, this is all really confusing
var immediate = InputStrImmediate(); var immediate = InputStrImmediate();
g.DrawString(immediate, MessageFont, immediateColor, x, y); g.DrawString(immediate, MessageFont, immediateColor, point.X, point.Y);
// next draw anything that's pressed because it's sticky. // next draw anything that's pressed because it's sticky.
// this applies to autofire and autohold both. somehow. I don't understand it. // this applies to autofire and autohold both. somehow. I don't understand it.
@ -351,46 +308,38 @@ namespace BizHawk.Client.EmuHawk
// in order to achieve this we want to avoid drawing anything pink that isn't actually held down right now // in order to achieve this we want to avoid drawing anything pink that isn't actually held down right now
// so we make an AND adapter and combine it using immediate & sticky // so we make an AND adapter and combine it using immediate & sticky
var autoString = MakeStringFor(Global.StickyXORAdapter.Source.Xor(Global.AutofireStickyXORAdapter).And(Global.AutofireStickyXORAdapter)); var autoString = MakeStringFor(Global.StickyXORAdapter.Source.Xor(Global.AutofireStickyXORAdapter).And(Global.AutofireStickyXORAdapter));
g.DrawString(autoString, MessageFont, autoColor, x, y); g.DrawString(autoString, MessageFont, autoColor, point.X, point.Y);
//recolor everything that's changed from the previous input //recolor everything that's changed from the previous input
var immediateOverlay = MakeIntersectImmediatePrevious(); var immediateOverlay = MakeIntersectImmediatePrevious();
g.DrawString(immediateOverlay, MessageFont, changedColor, x, y); g.DrawString(immediateOverlay, MessageFont, changedColor, point.X, point.Y);
} }
} }
if (Global.MovieSession.MultiTrack.IsActive) if (Global.MovieSession.MultiTrack.IsActive)
{ {
float x = GetX(g, Global.Config.DispMultix, Global.Config.DispMultianchor, Global.MovieSession.MultiTrack.Status); var point = GetCoordinates(g, Global.Config.MultitrackRecorder, Global.MovieSession.MultiTrack.Status);
float y = GetY(g, Global.Config.DispMultiy, Global.Config.DispMultianchor, Global.MovieSession.MultiTrack.Status); DrawOsdMessage(g, Global.MovieSession.MultiTrack.Status, FixedMessagesColor, point.X, point.Y);
DrawOsdMessage(g, Global.MovieSession.MultiTrack.Status, FixedMessagesColor, x, y);
} }
if (Global.Config.DisplayFPS && Fps != null) if (Global.Config.DisplayFPS && Fps != null)
{ {
float x = GetX(g, Global.Config.DispFPSx, Global.Config.DispFPSanchor, Fps); var point = GetCoordinates(g, Global.Config.Fps, Fps);
float y = GetY(g, Global.Config.DispFPSy, Global.Config.DispFPSanchor, Fps); DrawOsdMessage(g, Fps, FixedMessagesColor, point.X, point.Y);
DrawOsdMessage(g, Fps, FixedMessagesColor, x, y);
} }
if (Global.Config.DisplayLagCounter && Global.Emulator.CanPollInput()) if (Global.Config.DisplayLagCounter && Global.Emulator.CanPollInput())
{ {
var counter = Global.Emulator.AsInputPollable().LagCount.ToString(); var counter = Global.Emulator.AsInputPollable().LagCount.ToString();
var x = GetX(g, Global.Config.DispLagx, Global.Config.DispLaganchor, counter); var point = GetCoordinates(g, Global.Config.LagCounter, counter);
var y = GetY(g, Global.Config.DispLagy, Global.Config.DispLaganchor, counter); DrawOsdMessage(g, counter, FixedAlertMessageColor, point.X, point.Y);
DrawOsdMessage(g, counter, FixedAlertMessageColor, x, y);
} }
if (Global.Config.DisplayRerecordCount) if (Global.Config.DisplayRerecordCount)
{ {
string rerecordCount = MakeRerecordCount(); string rerecordCount = MakeRerecordCount();
float x = GetX(g, Global.Config.DispRecx, Global.Config.DispRecanchor, rerecordCount); var point = GetCoordinates(g, Global.Config.ReRecordCounter, rerecordCount);
float y = GetY(g, Global.Config.DispRecy, Global.Config.DispRecanchor, rerecordCount); DrawOsdMessage(g, rerecordCount, FixedMessagesColor, point.X, point.Y);
DrawOsdMessage(g, rerecordCount, FixedMessagesColor, x, y);
} }
if (Global.ClientControls["Autohold"] || Global.ClientControls["Autofire"]) if (Global.ClientControls["Autohold"] || Global.ClientControls["Autofire"])
@ -411,16 +360,11 @@ namespace BizHawk.Client.EmuHawk
} }
var message = sb.ToString(); var message = sb.ToString();
var point = GetCoordinates(g, Global.Config.Autohold, message);
g.DrawString( g.DrawString(message, MessageFont, Color.White, point.X, point.Y);
message,
MessageFont,
Color.White,
GetX(g, Global.Config.DispAutoholdx, Global.Config.DispAutoholdanchor, message),
GetY(g, Global.Config.DispAutoholdy, Global.Config.DispAutoholdanchor, message));
} }
if (Global.MovieSession.Movie.IsActive && Global.Config.DisplaySubtitles) if (Global.MovieSession.Movie.IsActive() && Global.Config.DisplaySubtitles)
{ {
var subList = Global.MovieSession.Movie.Subtitles.GetSubtitles(Global.Emulator.Frame); var subList = Global.MovieSession.Movie.Subtitles.GetSubtitles(Global.Emulator.Frame);

View File

@ -1,5 +1,5 @@
using System.Drawing; using System.Drawing;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common.IEmulatorExtensions; using BizHawk.Emulation.Common.IEmulatorExtensions;
@ -10,6 +10,7 @@ using BizHawk.Emulation.Cores.Nintendo.SNES9X;
using BizHawk.Emulation.Cores.Consoles.Sega.gpgx; using BizHawk.Emulation.Cores.Consoles.Sega.gpgx;
using BizHawk.Emulation.Cores.Sony.PSP; using BizHawk.Emulation.Cores.Sony.PSP;
using BizHawk.Emulation.Cores.Arcades.MAME; using BizHawk.Emulation.Cores.Arcades.MAME;
using BizHawk.Emulation.Cores.Sega.MasterSystem;
namespace BizHawk.Client.EmuHawk.CoreExtensions namespace BizHawk.Client.EmuHawk.CoreExtensions
{ {
@ -71,5 +72,99 @@ namespace BizHawk.Client.EmuHawk.CoreExtensions
return str; return str;
} }
public static SystemInfo System(this IEmulator emulator)
{
switch (emulator.SystemId)
{
default:
case "NULL":
return SystemInfo.Null;
case "NES":
return SystemInfo.Nes;
case "INTV":
return SystemInfo.Intellivision;
case "SG":
return SystemInfo.SG;
case "SMS":
if (emulator is SMS gg && gg.IsGameGear)
{
return SystemInfo.GG;
}
if (emulator is SMS sg && sg.IsSG1000)
{
return SystemInfo.SG;
}
return SystemInfo.SMS;
case "PCECD":
return SystemInfo.PCECD;
case "PCE":
return SystemInfo.PCE;
case "SGX":
return SystemInfo.SGX;
case "GEN":
return SystemInfo.Genesis;
case "TI83":
return SystemInfo.TI83;
case "SNES":
return SystemInfo.SNES;
case "GB":
/*
if ((Emulator as IGameboyCommon).IsCGBMode())
{
return SystemInfo.GBC;
}
*/
return SystemInfo.GB;
case "A26":
return SystemInfo.Atari2600;
case "A78":
return SystemInfo.Atari7800;
case "C64":
return SystemInfo.C64;
case "Coleco":
return SystemInfo.Coleco;
case "GBA":
return SystemInfo.GBA;
case "N64":
return SystemInfo.N64;
case "SAT":
return SystemInfo.Saturn;
case "DGB":
return SystemInfo.DualGB;
case "GB3x":
return SystemInfo.GB3x;
case "GB4x":
return SystemInfo.GB4x;
case "WSWAN":
return SystemInfo.WonderSwan;
case "Lynx":
return SystemInfo.Lynx;
case "PSX":
return SystemInfo.PSX;
case "AppleII":
return SystemInfo.AppleII;
case "Libretro":
return SystemInfo.Libretro;
case "VB":
return SystemInfo.VirtualBoy;
case "VEC":
return SystemInfo.Vectrex;
case "NGP":
return SystemInfo.NeoGeoPocket;
case "ZXSpectrum":
return SystemInfo.ZxSpectrum;
case "AmstradCPC":
return SystemInfo.AmstradCpc;
case "ChannelF":
return SystemInfo.ChannelF;
case "O2":
return SystemInfo.O2;
case "MAME":
return SystemInfo.Mame;
}
}
} }
} }

View File

@ -1,6 +1,7 @@
using System; using System;
using BizHawk.Bizware.BizwareGL; using BizHawk.Bizware.BizwareGL;
using BizHawk.Bizware.BizwareGL.Drivers.OpenTK;
using BizHawk.Bizware.BizwareGL.Drivers.SlimDX;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
@ -11,7 +12,6 @@ namespace BizHawk.Client.EmuHawk
{ {
private GLManager() private GLManager()
{ {
} }
public void Dispose() public void Dispose()
@ -20,28 +20,26 @@ namespace BizHawk.Client.EmuHawk
public static GLManager Instance { get; private set; } public static GLManager Instance { get; private set; }
Bizware.BizwareGL.Drivers.OpenTK.IGL_TK MainContext; public static void CreateInstance()
public static void CreateInstance(Bizware.BizwareGL.Drivers.OpenTK.IGL_TK mainContext)
{ {
if (Instance != null) throw new InvalidOperationException($"Attempted to create more than one {nameof(GLManager)}"); if (Instance != null)
{
throw new InvalidOperationException($"Attempted to create more than one {nameof(GLManager)}");
}
Instance = new GLManager(); Instance = new GLManager();
Instance.MainContext = mainContext;
} }
public void ReleaseGLContext(object o) public void ReleaseGLContext(object o)
{ {
ContextRef cr = (ContextRef)o; var cr = (ContextRef)o;
cr.gl.Dispose(); cr.GL.Dispose();
} }
//[System.Runtime.InteropServices.DllImport("opengl32.dll")] public ContextRef CreateGLContext(int majorVersion, int minorVersion, bool forwardCompatible)
//bool wglShareLists(IntPtr hglrc1, IntPtr hglrc2);
public ContextRef CreateGLContext(int major_version, int minor_version, bool forward_compatible)
{ {
var gl = new Bizware.BizwareGL.Drivers.OpenTK.IGL_TK(major_version, minor_version, forward_compatible); var gl = new IGL_TK(majorVersion, minorVersion, forwardCompatible);
var ret = new ContextRef { gl = gl }; var ret = new ContextRef { GL = gl };
return ret; return ret;
} }
@ -49,27 +47,16 @@ namespace BizHawk.Client.EmuHawk
{ {
return new ContextRef return new ContextRef
{ {
gc = gc, Gc = gc,
gl = gc.IGL GL = gc.IGL
}; };
} }
/// <summary> private ContextRef _activeContext;
/// This might not be a GL implementation. If it isnt GL, then setting it as active context is just NOP
/// </summary>
public ContextRef GetContextForIGL(IGL gl)
{
return new ContextRef
{
gl = gl
};
}
ContextRef ActiveContext;
public void Invalidate() public void Invalidate()
{ {
ActiveContext = null; _activeContext = null;
} }
public void Activate(ContextRef cr) public void Activate(ContextRef cr)
@ -77,26 +64,32 @@ namespace BizHawk.Client.EmuHawk
bool begun = false; bool begun = false;
//this needs a begin signal to set the swap chain to the next backbuffer //this needs a begin signal to set the swap chain to the next backbuffer
if (cr.gl is BizHawk.Bizware.BizwareGL.Drivers.SlimDX.IGL_SlimDX9) if (cr.GL is IGL_SlimDX9)
{ {
cr.gc.Begin(); cr.Gc.Begin();
begun = true; begun = true;
} }
if (cr == ActiveContext) if (cr == _activeContext)
{
return; return;
}
ActiveContext = cr; _activeContext = cr;
if (cr.gc != null) if (cr.Gc != null)
{ {
//TODO - this is checking the current context inside to avoid an extra NOP context change. make this optional or remove it, since we're tracking it here //TODO - this is checking the current context inside to avoid an extra NOP context change. make this optional or remove it, since we're tracking it here
if(!begun) if (!begun)
cr.gc.Begin(); {
cr.Gc.Begin();
}
} }
else if (cr.gl != null) else
{ {
if(cr.gl is BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK) if (cr.GL is IGL_TK tk)
((BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK)cr.gl).MakeDefaultCurrent(); {
tk.MakeDefaultCurrent();
}
} }
} }
@ -107,8 +100,8 @@ namespace BizHawk.Client.EmuHawk
public class ContextRef public class ContextRef
{ {
public IGL gl; public IGL GL { get; set; }
public GraphicsControl gc; public GraphicsControl Gc { get; set; }
} }
} }
} }

View File

@ -1,5 +1,4 @@
using BizHawk.Bizware.BizwareGL; using BizHawk.Bizware.BizwareGL;
using BizHawk.Client.ApiHawk;
// ReSharper disable StyleCop.SA1401 // ReSharper disable StyleCop.SA1401
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
@ -8,7 +7,6 @@ namespace BizHawk.Client.EmuHawk
{ {
public static MainForm MainForm; public static MainForm MainForm;
public static ToolManager Tools; public static ToolManager Tools;
public static BasicApiProvider ApiProvider;
/// <summary> /// <summary>
/// the IGL to be used for rendering /// the IGL to be used for rendering

View File

@ -1,7 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
@ -9,54 +6,60 @@ namespace BizHawk.Client.EmuHawk
{ {
public class JumpLists public class JumpLists
{ {
static readonly Assembly PresentationFramework; private static readonly Type JumpList;
static Type Application; private static readonly Type JumpTask;
static Type JumpList;
static Type JumpTask;
static object _app;
static JumpLists() static JumpLists()
{ {
try try
{ {
PresentationFramework = Assembly.Load("PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); var presentationFramework =
Application = PresentationFramework.GetType("System.Windows.Application"); Assembly.Load(
JumpList = PresentationFramework.GetType("System.Windows.Shell.JumpList"); "PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
JumpTask = PresentationFramework.GetType("System.Windows.Shell.JumpTask"); var application = presentationFramework.GetType("System.Windows.Application");
_app = Activator.CreateInstance(Application); JumpList = presentationFramework.GetType("System.Windows.Shell.JumpList");
JumpTask = presentationFramework.GetType("System.Windows.Shell.JumpTask");
var app = Activator.CreateInstance(application);
dynamic jmp = Activator.CreateInstance(JumpList); dynamic jmp = Activator.CreateInstance(JumpList);
jmp.ShowRecentCategory = true; jmp.ShowRecentCategory = true;
JumpList.GetMethod("SetJumpList").Invoke(null, new[] { _app, jmp }); JumpList
.GetMethod("SetJumpList")
?.Invoke(null, new[] {app, jmp});
}
catch
{
// Do nothing
} }
catch { }
} }
/// <summary> /// <summary>
/// add an item to the W7+ jumplist /// add an item to the W7+ jumplist
/// </summary> /// </summary>
/// <param name="fullpath">fully qualified path, can include '|' character for archives</param> /// <param name="fullPath">fully qualified path, can include '|' character for archives</param>
public static void AddRecentItem(string fullpath, string title) /// <param name="title">The text displayed in the jumplist entry</param>
public static void AddRecentItem(string fullPath, string title)
{ {
//string title;
//if (fullpath.Contains('|'))
// title = fullpath.Split('|')[1];
//else
// title = Path.GetFileName(fullpath);
try try
{ {
string exepath = Assembly.GetEntryAssembly().Location; string execPath = Assembly.GetEntryAssembly()
?.Location;
dynamic ji = Activator.CreateInstance(JumpTask); dynamic ji = Activator.CreateInstance(JumpTask);
ji.ApplicationPath = exepath; ji.ApplicationPath = execPath;
ji.Arguments = $"\"{fullpath}\""; ji.Arguments = $"\"{fullPath}\"";
ji.Title = title; ji.Title = title;
// for some reason, this doesn't work // for some reason, this doesn't work
ji.WorkingDirectory = Path.GetDirectoryName(exepath); ji.WorkingDirectory = Path.GetDirectoryName(execPath);
JumpList.GetMethod("AddToRecentCategory", new[] { JumpTask }).Invoke(null, new[] { ji }); JumpList
.GetMethod("AddToRecentCategory", new[] {JumpTask})
?.Invoke(null, new[] {ji});
}
catch
{
// Do nothing
} }
catch { }
} }
} }
} }

View File

@ -6,55 +6,39 @@ using System.Runtime.InteropServices;
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Client.Common; using BizHawk.Client.Common;
#pragma warning disable 162 // thanks! - http://sharp-developer.net/ru/CodeBank/WinForms/GuiConsole.aspx
// todo - quit using Console.WriteLine (well, we can leave it hooked up as a backstop)
//thanks! - http://sharp-developer.net/ru/CodeBank/WinForms/GuiConsole.aspx // use a different method instead, so we can collect unicode data
// also, collect log data independently of whether the log window is open
//todo - quit using Console.WriteLine (well, we can leave it hooked up as a backstop) // we also need to dice it into lines so that we can have a backlog policy
//use a different method instead, so we can collect unicode data
//also, collect log data independently of whether the log window is open
//we also need to dice it into lines so that we can have a backlog policy
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
static class LogConsole internal static class LogConsole
{ {
public static bool ConsoleVisible public static bool ConsoleVisible { get; private set; }
{
get;
private set;
}
static LogWindow window; private static LogWindow _window;
static LogStream logStream; private static LogStream _logStream;
static bool NeedToRelease; private static bool _needToRelease;
class LogStream : Stream private class LogStream : Stream
{ {
public override bool CanRead { get { return false; } } public override bool CanRead => false;
public override bool CanSeek { get { return false; } } public override bool CanSeek => false;
public override bool CanWrite { get { return true; } } public override bool CanWrite => true;
public override void Flush() public override void Flush()
{ {
//TODO - maybe this will help with decoding //TODO - maybe this will help with decoding
} }
public override long Length public override long Length => throw new NotImplementedException();
{
get { throw new NotImplementedException(); }
}
public override long Position public override long Position
{ {
get get => throw new NotImplementedException();
{ set => throw new NotImplementedException();
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
} }
public override int Read(byte[] buffer, int offset, int count) public override int Read(byte[] buffer, int offset, int count)
@ -77,18 +61,16 @@ namespace BizHawk.Client.EmuHawk
//TODO - buffer undecoded characters (this may be important) //TODO - buffer undecoded characters (this may be important)
//(use decoder = System.Text.Encoding.Unicode.GetDecoder()) //(use decoder = System.Text.Encoding.Unicode.GetDecoder())
string str = Encoding.ASCII.GetString(buffer, offset, count); string str = Encoding.ASCII.GetString(buffer, offset, count);
if (Emit != null) Emit?.Invoke(str);
Emit(str);
} }
public Action<string> Emit; public Action<string> Emit;
} }
static string SkipEverythingButProgramInCommandLine(string cmdLine) static string SkipEverythingButProgramInCommandLine(string cmdLine)
{ {
//skip past the program name. can anyone think of a better way to do this? // skip past the program name. can anyone think of a better way to do this?
//we could use CommandLineToArgvW (commented out below) but then we would just have to re-assemble and potentially re-quote it // we could use CommandLineToArgvW (commented out below) but then we would just have to re-assemble and potentially re-quote it
int childCmdLine = 0; int childCmdLine = 0;
int lastSlash = 0; int lastSlash = 0;
int lastGood = 0; int lastGood = 0;
@ -100,7 +82,10 @@ namespace BizHawk.Client.EmuHawk
if (childCmdLine == cmdLine.Length) break; if (childCmdLine == cmdLine.Length) break;
bool thisIsQuote = (cur == '\"'); bool thisIsQuote = (cur == '\"');
if (cur == '\\' || cur == '/') if (cur == '\\' || cur == '/')
{
lastSlash = childCmdLine; lastSlash = childCmdLine;
}
if (quote) if (quote)
{ {
if (thisIsQuote) if (thisIsQuote)
@ -121,10 +106,10 @@ namespace BizHawk.Client.EmuHawk
return $"{path} {remainder}"; return $"{path} {remainder}";
} }
static IntPtr oldOut, conOut; private static IntPtr oldOut, conOut;
static bool hasConsole; private static bool hasConsole;
static bool attachedConsole; private static bool attachedConsole;
static bool shouldRedirectStdout; private static bool shouldRedirectStdout;
public static void CreateConsole() public static void CreateConsole()
{ {
//(see desmume for the basis of some of this logic) //(see desmume for the basis of some of this logic)
@ -135,7 +120,7 @@ namespace BizHawk.Client.EmuHawk
if (oldOut == IntPtr.Zero) if (oldOut == IntPtr.Zero)
oldOut = ConsoleImports.GetStdHandle( -11 ); //STD_OUTPUT_HANDLE oldOut = ConsoleImports.GetStdHandle( -11 ); //STD_OUTPUT_HANDLE
ConsoleImports.FileType fileType = ConsoleImports.GetFileType(oldOut); var fileType = ConsoleImports.GetFileType(oldOut);
//stdout is already connected to something. keep using it and dont let the console interfere //stdout is already connected to something. keep using it and dont let the console interfere
shouldRedirectStdout = (fileType == ConsoleImports.FileType.FileTypeUnknown || fileType == ConsoleImports.FileType.FileTypePipe); shouldRedirectStdout = (fileType == ConsoleImports.FileType.FileTypeUnknown || fileType == ConsoleImports.FileType.FileTypePipe);
@ -143,7 +128,7 @@ namespace BizHawk.Client.EmuHawk
//attach to an existing console //attach to an existing console
attachedConsole = false; attachedConsole = false;
//ever since a recent KB, XP-based systems glitch out when attachconsole is called and theres no console to attach to. //ever since a recent KB, XP-based systems glitch out when attachconsole is called and there's no console to attach to.
if (Environment.OSVersion.Version.Major != 5) if (Environment.OSVersion.Version.Major != 5)
{ {
if (ConsoleImports.AttachConsole(-1)) if (ConsoleImports.AttachConsole(-1))
@ -164,10 +149,12 @@ namespace BizHawk.Client.EmuHawk
hasConsole = true; hasConsole = true;
} }
else else
{
System.Windows.Forms.MessageBox.Show($"Couldn't allocate win32 console: {Marshal.GetLastWin32Error()}"); System.Windows.Forms.MessageBox.Show($"Couldn't allocate win32 console: {Marshal.GetLastWin32Error()}");
}
} }
if(hasConsole) if (hasConsole)
{ {
IntPtr ptr = ConsoleImports.GetCommandLine(); IntPtr ptr = ConsoleImports.GetCommandLine();
string commandLine = Marshal.PtrToStringAuto(ptr); string commandLine = Marshal.PtrToStringAuto(ptr);
@ -195,7 +182,19 @@ namespace BizHawk.Client.EmuHawk
static void ReleaseConsole() static void ReleaseConsole()
{ {
if (!hasConsole) if (!hasConsole)
{
return; return;
}
if (shouldRedirectStdout)
{
ConsoleImports.CloseHandle(conOut);
}
if (!attachedConsole)
{
ConsoleImports.FreeConsole();
}
if(shouldRedirectStdout) ConsoleImports.CloseHandle(conOut); if(shouldRedirectStdout) ConsoleImports.CloseHandle(conOut);
if(!attachedConsole) ConsoleImports.FreeConsole(); if(!attachedConsole) ConsoleImports.FreeConsole();
@ -209,11 +208,15 @@ namespace BizHawk.Client.EmuHawk
/// pops the console in front of the main window (where it should probably go after booting up the game). /// pops the console in front of the main window (where it should probably go after booting up the game).
/// maybe this should be optional, or maybe we can somehow position the console sensibly. /// maybe this should be optional, or maybe we can somehow position the console sensibly.
/// sometimes it annoys me, but i really need it on top while debugging or else i will be annoyed. /// sometimes it annoys me, but i really need it on top while debugging or else i will be annoyed.
/// best of all would be to position it beneath the bizhawk main window somehow. /// best of all would be to position it beneath the BizHawk main window somehow.
/// </summary> /// </summary>
public static void PositionConsole() public static void PositionConsole()
{ {
if (ConsoleVisible == false) return; if (ConsoleVisible == false)
{
return;
}
if (Global.Config.WIN32_CONSOLE) if (Global.Config.WIN32_CONSOLE)
{ {
IntPtr x = ConsoleImports.GetConsoleWindow(); IntPtr x = ConsoleImports.GetConsoleWindow();
@ -228,61 +231,58 @@ namespace BizHawk.Client.EmuHawk
if (Global.Config.WIN32_CONSOLE) if (Global.Config.WIN32_CONSOLE)
{ {
NeedToRelease = true; _needToRelease = true;
CreateConsole(); CreateConsole();
//not sure whether we need to set a buffer size here
//var sout = new StreamWriter(Console.OpenStandardOutput(),Encoding.ASCII,1) { AutoFlush = true };
//var sout = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true };
//Console.SetOut(sout);
//Console.Title = "BizHawk Message Log";
//System.Runtime.InteropServices.SafeFi
//new Microsoft.Win32.SafeHandles.SafeFileHandle(
} }
else else
{ {
logStream = new LogStream(); _logStream = new LogStream();
Log.HACK_LOG_STREAM = logStream; Log.HACK_LOG_STREAM = _logStream;
var sout = new StreamWriter(logStream) { AutoFlush = true }; Console.SetOut(new StreamWriter(_logStream) { AutoFlush = true });
new StringBuilder(); //not using this right now _window = new LogWindow();
Console.SetOut(sout); _window.Show();
window = new LogWindow(); _logStream.Emit = str => { _window.Append(str); };
window.Show();
logStream.Emit = (str) => { window.Append(str); };
} }
} }
public static void HideConsole() public static void HideConsole()
{ {
if (ConsoleVisible == false) return; if (ConsoleVisible == false)
{
return;
}
Console.SetOut(TextWriter.Null); Console.SetOut(TextWriter.Null);
ConsoleVisible = false; ConsoleVisible = false;
if (NeedToRelease) if (_needToRelease)
{ {
ReleaseConsole(); ReleaseConsole();
NeedToRelease = false; _needToRelease = false;
} }
else else
{ {
logStream.Close(); _logStream.Close();
logStream = null; _logStream = null;
Log.HACK_LOG_STREAM = null; Log.HACK_LOG_STREAM = null;
window.Close(); _window.Close();
window = null; _window = null;
} }
} }
public static void notifyLogWindowClosing() public static void NotifyLogWindowClosing()
{ {
Console.SetOut(TextWriter.Null); Console.SetOut(TextWriter.Null);
ConsoleVisible = false; ConsoleVisible = false;
if(logStream != null) logStream.Close(); _logStream?.Close();
Log.HACK_LOG_STREAM = null; Log.HACK_LOG_STREAM = null;
} }
public static void SaveConfigSettings() public static void SaveConfigSettings()
{ {
if (window != null && window.IsHandleCreated) if (_window != null && _window.IsHandleCreated)
window.SaveConfigSettings(); {
_window.SaveConfigSettings();
}
} }
} }
} }

View File

@ -26,7 +26,7 @@ namespace BizHawk.Client.EmuHawk
{ {
Global.Config.ShowLogWindow = false; Global.Config.ShowLogWindow = false;
GlobalWin.MainForm.NotifyLogWindowClosing(); GlobalWin.MainForm.NotifyLogWindowClosing();
LogConsole.notifyLogWindowClosing(); LogConsole.NotifyLogWindowClosing();
SaveConfigSettings(); SaveConfigSettings();
}; };
ListView_ClientSizeChanged(null, null); ListView_ClientSizeChanged(null, null);

View File

@ -237,12 +237,12 @@ namespace BizHawk.Client.EmuHawk
private void MovieSubMenu_DropDownOpened(object sender, EventArgs e) private void MovieSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
FullMovieLoadstatesMenuItem.Enabled = !MovieSession.MultiTrack.IsActive; FullMovieLoadstatesMenuItem.Enabled = !MovieSession.MultiTrack.IsActive;
StopMovieWithoutSavingMenuItem.Enabled = MovieSession.Movie.IsActive && MovieSession.Movie.Changes; StopMovieWithoutSavingMenuItem.Enabled = MovieSession.Movie.IsActive() && MovieSession.Movie.Changes;
StopMovieMenuItem.Enabled StopMovieMenuItem.Enabled
= PlayFromBeginningMenuItem.Enabled = PlayFromBeginningMenuItem.Enabled
= SaveMovieMenuItem.Enabled = SaveMovieMenuItem.Enabled
= SaveMovieAsMenuItem.Enabled = SaveMovieAsMenuItem.Enabled
= MovieSession.Movie.IsActive; = MovieSession.Movie.IsActive();
ReadonlyMenuItem.Checked = MovieSession.ReadOnly; ReadonlyMenuItem.Checked = MovieSession.ReadOnly;
AutomaticallyBackupMoviesMenuItem.Checked = Config.EnableBackupMovies; AutomaticallyBackupMoviesMenuItem.Checked = Config.EnableBackupMovies;
@ -684,11 +684,11 @@ namespace BizHawk.Client.EmuHawk
{ {
PauseMenuItem.Checked = _didMenuPause ? _wasPaused : EmulatorPaused; PauseMenuItem.Checked = _didMenuPause ? _wasPaused : EmulatorPaused;
SoftResetMenuItem.Enabled = Emulator.ControllerDefinition.BoolButtons.Contains("Reset") && SoftResetMenuItem.Enabled = Emulator.ControllerDefinition.BoolButtons.Contains("Reset")
(!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished); && MovieSession.Movie.Mode != MovieMode.Play;
HardResetMenuItem.Enabled = Emulator.ControllerDefinition.BoolButtons.Contains("Power") && HardResetMenuItem.Enabled = Emulator.ControllerDefinition.BoolButtons.Contains("Power")
(!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished); && MovieSession.Movie.Mode != MovieMode.Play;;
PauseMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Pause"].Bindings; PauseMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Pause"].Bindings;
RebootCoreMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Reboot Core"].Bindings; RebootCoreMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Reboot Core"].Bindings;
@ -994,7 +994,7 @@ namespace BizHawk.Client.EmuHawk
private void MessagesMenuItem_Click(object sender, EventArgs e) private void MessagesMenuItem_Click(object sender, EventArgs e)
{ {
using var form = new MessageConfig(); using var form = new MessageConfig(Config);
var result = form.ShowDialog(); var result = form.ShowDialog();
AddOnScreenMessage(result.IsOk() AddOnScreenMessage(result.IsOk()
? "Message settings saved" ? "Message settings saved"
@ -1012,8 +1012,14 @@ namespace BizHawk.Client.EmuHawk
using var form = new SoundConfig(Config); using var form = new SoundConfig(Config);
if (form.ShowDialog().IsOk()) if (form.ShowDialog().IsOk())
{ {
Sound.StartSound();
AddOnScreenMessage("Sound settings saved");
RewireSound(); RewireSound();
} }
else
{
AddOnScreenMessage("Sound config aborted");
}
} }
private void AutofireMenuItem_Click(object sender, EventArgs e) private void AutofireMenuItem_Click(object sender, EventArgs e)
@ -1546,10 +1552,10 @@ namespace BizHawk.Client.EmuHawk
NESSoundChannelsMenuItem.Enabled = Tools.IsAvailable<NESSoundConfig>(); NESSoundChannelsMenuItem.Enabled = Tools.IsAvailable<NESSoundConfig>();
MovieSettingsMenuItem.Enabled = (Emulator is NES || Emulator is SubNESHawk) MovieSettingsMenuItem.Enabled = (Emulator is NES || Emulator is SubNESHawk)
&& !MovieSession.Movie.IsActive; && !MovieSession.Movie.IsActive();
NesControllerSettingsMenuItem.Enabled = Tools.IsAvailable<NesControllerSettings>() NesControllerSettingsMenuItem.Enabled = Tools.IsAvailable<NesControllerSettings>()
&& !MovieSession.Movie.IsActive; && !MovieSession.Movie.IsActive();
barcodeReaderToolStripMenuItem.Enabled = ServiceInjector.IsAvailable(Emulator.ServiceProvider, typeof(BarcodeEntry)); barcodeReaderToolStripMenuItem.Enabled = ServiceInjector.IsAvailable(Emulator.ServiceProvider, typeof(BarcodeEntry));
@ -1600,12 +1606,12 @@ namespace BizHawk.Client.EmuHawk
{ {
if (Emulator is NES nes) if (Emulator is NES nes)
{ {
using var form = new NESGraphicsConfig(this, nes.GetSettings().Clone()); using var form = new NESGraphicsConfig(this, Config, nes.GetSettings().Clone());
form.ShowDialog(this); form.ShowDialog(this);
} }
else if (Emulator is SubNESHawk sub) else if (Emulator is SubNESHawk sub)
{ {
using var form = new NESGraphicsConfig(this, sub.GetSettings().Clone()); using var form = new NESGraphicsConfig(this, Config, sub.GetSettings().Clone());
form.ShowDialog(this); form.ShowDialog(this);
} }
else if (Emulator is QuickNES quickNes) else if (Emulator is QuickNES quickNes)
@ -1636,7 +1642,7 @@ namespace BizHawk.Client.EmuHawk
private void FdsEjectDiskMenuItem_Click(object sender, EventArgs e) private void FdsEjectDiskMenuItem_Click(object sender, EventArgs e)
{ {
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
ClickyVirtualPadController.Click("FDS Eject"); ClickyVirtualPadController.Click("FDS Eject");
AddOnScreenMessage("FDS disk ejected."); AddOnScreenMessage("FDS disk ejected.");
@ -1648,7 +1654,7 @@ namespace BizHawk.Client.EmuHawk
if (Emulator is NES nes && nes.IsVS if (Emulator is NES nes && nes.IsVS
|| Emulator is SubNESHawk sub && sub.IsVs) || Emulator is SubNESHawk sub && sub.IsVs)
{ {
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
ClickyVirtualPadController.Click("Insert Coin P1"); ClickyVirtualPadController.Click("Insert Coin P1");
AddOnScreenMessage("P1 Coin Inserted"); AddOnScreenMessage("P1 Coin Inserted");
@ -1661,7 +1667,7 @@ namespace BizHawk.Client.EmuHawk
if (Emulator is NES nes && nes.IsVS if (Emulator is NES nes && nes.IsVS
|| Emulator is SubNESHawk sub && sub.IsVs) || Emulator is SubNESHawk sub && sub.IsVs)
{ {
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
ClickyVirtualPadController.Click("Insert Coin P2"); ClickyVirtualPadController.Click("Insert Coin P2");
AddOnScreenMessage("P2 Coin Inserted"); AddOnScreenMessage("P2 Coin Inserted");
@ -1674,7 +1680,7 @@ namespace BizHawk.Client.EmuHawk
if (Emulator is NES nes && nes.IsVS if (Emulator is NES nes && nes.IsVS
|| Emulator is SubNESHawk sub && sub.IsVs) || Emulator is SubNESHawk sub && sub.IsVs)
{ {
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
ClickyVirtualPadController.Click("Service Switch"); ClickyVirtualPadController.Click("Service Switch");
AddOnScreenMessage("Service Switch Pressed"); AddOnScreenMessage("Service Switch Pressed");
@ -1728,8 +1734,7 @@ namespace BizHawk.Client.EmuHawk
{ {
var s = ((PCEngine)Emulator).GetSettings(); var s = ((PCEngine)Emulator).GetSettings();
PceControllerSettingsMenuItem.Enabled = !MovieSession.Movie.IsActive; PceControllerSettingsMenuItem.Enabled = MovieSession.Movie.NotActive();
PCEAlwaysPerformSpriteLimitMenuItem.Checked = s.SpriteLimit; PCEAlwaysPerformSpriteLimitMenuItem.Checked = s.SpriteLimit;
PCEAlwaysEqualizeVolumesMenuItem.Checked = s.EqualizeVolume; PCEAlwaysEqualizeVolumesMenuItem.Checked = s.EqualizeVolume;
PCEArcadeCardRewindEnableMenuItem.Checked = s.ArcadeCardRewindHack; PCEArcadeCardRewindEnableMenuItem.Checked = s.ArcadeCardRewindHack;
@ -2082,8 +2087,9 @@ namespace BizHawk.Client.EmuHawk
private void A7800SubMenu_DropDownOpened(object sender, EventArgs e) private void A7800SubMenu_DropDownOpened(object sender, EventArgs e)
{ {
A7800ControllerSettingsMenuItem.Enabled = !MovieSession.Movie.IsActive; A7800ControllerSettingsMenuItem.Enabled
A7800FilterSettingsMenuItem.Enabled = !MovieSession.Movie.IsActive; = A7800FilterSettingsMenuItem.Enabled
= MovieSession.Movie.NotActive();
} }
private void A7800ControllerSettingsToolStripMenuItem_Click(object sender, EventArgs e) private void A7800ControllerSettingsToolStripMenuItem_Click(object sender, EventArgs e)
@ -2189,7 +2195,7 @@ namespace BizHawk.Client.EmuHawk
private void PSXSubMenu_DropDownOpened(object sender, EventArgs e) private void PSXSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
PSXControllerSettingsMenuItem.Enabled = !MovieSession.Movie.IsActive; PSXControllerSettingsMenuItem.Enabled = MovieSession.Movie.NotActive();
} }
private void PSXControllerSettingsMenuItem_Click(object sender, EventArgs e) private void PSXControllerSettingsMenuItem_Click(object sender, EventArgs e)
@ -2239,7 +2245,7 @@ namespace BizHawk.Client.EmuHawk
SnesGBInSGBMenuItem.Visible = false; SnesGBInSGBMenuItem.Visible = false;
} }
SNESControllerConfigurationMenuItem.Enabled = !MovieSession.Movie.IsActive; SNESControllerConfigurationMenuItem.Enabled = MovieSession.Movie.NotActive();
SnesGfxDebuggerMenuItem.Enabled = !OSTailoredCode.IsUnixHost; SnesGfxDebuggerMenuItem.Enabled = !OSTailoredCode.IsUnixHost;
} }
@ -2290,7 +2296,7 @@ namespace BizHawk.Client.EmuHawk
var ss = ((ColecoVision)Emulator).GetSyncSettings(); var ss = ((ColecoVision)Emulator).GetSyncSettings();
ColecoSkipBiosMenuItem.Checked = ss.SkipBiosIntro; ColecoSkipBiosMenuItem.Checked = ss.SkipBiosIntro;
ColecoUseSGMMenuItem.Checked = ss.UseSGM; ColecoUseSGMMenuItem.Checked = ss.UseSGM;
ColecoControllerSettingsMenuItem.Enabled = !MovieSession.Movie.IsActive; ColecoControllerSettingsMenuItem.Enabled = MovieSession.Movie.NotActive();
} }
private void ColecoSkipBiosMenuItem_Click(object sender, EventArgs e) private void ColecoSkipBiosMenuItem_Click(object sender, EventArgs e)
@ -2324,8 +2330,8 @@ namespace BizHawk.Client.EmuHawk
{ {
N64PluginSettingsMenuItem.Enabled = N64PluginSettingsMenuItem.Enabled =
N64ControllerSettingsMenuItem.Enabled = N64ControllerSettingsMenuItem.Enabled =
N64ExpansionSlotMenuItem.Enabled = N64ExpansionSlotMenuItem.Enabled =
!MovieSession.Movie.IsActive; MovieSession.Movie.NotActive();
N64CircularAnalogRangeMenuItem.Checked = Config.N64UseCircularAnalogConstraint; N64CircularAnalogRangeMenuItem.Checked = Config.N64UseCircularAnalogConstraint;
@ -2578,7 +2584,7 @@ namespace BizHawk.Client.EmuHawk
private void IntVSubMenu_DropDownOpened(object sender, EventArgs e) private void IntVSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
IntVControllerSettingsMenuItem.Enabled = !MovieSession.Movie.IsActive; IntVControllerSettingsMenuItem.Enabled = MovieSession.Movie.NotActive();
} }
private void IntVControllerSettingsMenuItem_Click(object sender, EventArgs e) private void IntVControllerSettingsMenuItem_Click(object sender, EventArgs e)
@ -2969,7 +2975,7 @@ namespace BizHawk.Client.EmuHawk
RecordMovieContextMenuItem.Visible = RecordMovieContextMenuItem.Visible =
PlayMovieContextMenuItem.Visible = PlayMovieContextMenuItem.Visible =
LoadLastMovieContextMenuItem.Visible = LoadLastMovieContextMenuItem.Visible =
!Emulator.IsNull() && !MovieSession.Movie.IsActive; !Emulator.IsNull() && MovieSession.Movie.NotActive();
RestartMovieContextMenuItem.Visible = RestartMovieContextMenuItem.Visible =
StopMovieContextMenuItem.Visible = StopMovieContextMenuItem.Visible =
@ -2977,13 +2983,13 @@ namespace BizHawk.Client.EmuHawk
ViewCommentsContextMenuItem.Visible = ViewCommentsContextMenuItem.Visible =
SaveMovieContextMenuItem.Visible = SaveMovieContextMenuItem.Visible =
SaveMovieAsContextMenuItem.Visible = SaveMovieAsContextMenuItem.Visible =
MovieSession.Movie.IsActive; MovieSession.Movie.IsActive();
BackupMovieContextMenuItem.Visible = MovieSession.Movie.IsActive; BackupMovieContextMenuItem.Visible = MovieSession.Movie.IsActive();
StopNoSaveContextMenuItem.Visible = MovieSession.Movie.IsActive && MovieSession.Movie.Changes; StopNoSaveContextMenuItem.Visible = MovieSession.Movie.IsActive() && MovieSession.Movie.Changes;
AddSubtitleContextMenuItem.Visible = !Emulator.IsNull() && MovieSession.Movie.IsActive && !MovieSession.ReadOnly; AddSubtitleContextMenuItem.Visible = !Emulator.IsNull() && MovieSession.Movie.IsActive() && !MovieSession.ReadOnly;
ConfigContextMenuItem.Visible = _inFullscreen; ConfigContextMenuItem.Visible = _inFullscreen;
@ -2994,7 +3000,7 @@ namespace BizHawk.Client.EmuHawk
LoadLastRomContextMenuItem.Enabled = !Config.RecentRoms.Empty; LoadLastRomContextMenuItem.Enabled = !Config.RecentRoms.Empty;
LoadLastMovieContextMenuItem.Enabled = !Config.RecentMovies.Empty; LoadLastMovieContextMenuItem.Enabled = !Config.RecentMovies.Empty;
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
if (MovieSession.ReadOnly) if (MovieSession.ReadOnly)
{ {
@ -3094,7 +3100,7 @@ namespace BizHawk.Client.EmuHawk
private void ViewSubtitlesContextMenuItem_Click(object sender, EventArgs e) private void ViewSubtitlesContextMenuItem_Click(object sender, EventArgs e)
{ {
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
using var form = new EditSubtitlesForm { ReadOnly = MovieSession.ReadOnly }; using var form = new EditSubtitlesForm { ReadOnly = MovieSession.ReadOnly };
form.GetMovie(MovieSession.Movie); form.GetMovie(MovieSession.Movie);
@ -3140,7 +3146,7 @@ namespace BizHawk.Client.EmuHawk
private void ViewCommentsContextMenuItem_Click(object sender, EventArgs e) private void ViewCommentsContextMenuItem_Click(object sender, EventArgs e)
{ {
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
using var form = new EditCommentsForm(); using var form = new EditCommentsForm();
form.GetMovie(MovieSession.Movie); form.GetMovie(MovieSession.Movie);
@ -3247,7 +3253,7 @@ namespace BizHawk.Client.EmuHawk
private void LinkConnectStatusBarButton_Click(object sender, EventArgs e) private void LinkConnectStatusBarButton_Click(object sender, EventArgs e)
{ {
// toggle Link status (only outside of a movie session) // toggle Link status (only outside of a movie session)
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
Emulator.AsLinkable().LinkConnected ^= true; Emulator.AsLinkable().LinkConnected ^= true;
Console.WriteLine("Cable connect status to {0}", Emulator.AsLinkable().LinkConnected); Console.WriteLine("Cable connect status to {0}", Emulator.AsLinkable().LinkConnected);

View File

@ -14,7 +14,7 @@ namespace BizHawk.Client.EmuHawk
{ {
// SuuperW: Check changes. adelikat: this could break bk2 movies // SuuperW: Check changes. adelikat: this could break bk2 movies
// TODO: Clean up the saving process // TODO: Clean up the saving process
if (movie.IsActive && (movie.Changes || !(movie is TasMovie))) if (movie.IsActive() && (movie.Changes || !(movie is TasMovie)))
{ {
movie.Save(); movie.Save();
} }
@ -98,19 +98,19 @@ namespace BizHawk.Client.EmuHawk
public void SetMainformMovieInfo() public void SetMainformMovieInfo()
{ {
if (MovieSession.Movie.IsPlaying) if (MovieSession.Movie.IsPlaying())
{ {
PlayRecordStatusButton.Image = Properties.Resources.Play; PlayRecordStatusButton.Image = Properties.Resources.Play;
PlayRecordStatusButton.ToolTipText = "Movie is in playback mode"; PlayRecordStatusButton.ToolTipText = "Movie is in playback mode";
PlayRecordStatusButton.Visible = true; PlayRecordStatusButton.Visible = true;
} }
else if (MovieSession.Movie.IsRecording) else if (MovieSession.Movie.IsRecording())
{ {
PlayRecordStatusButton.Image = Properties.Resources.RecordHS; PlayRecordStatusButton.Image = Properties.Resources.RecordHS;
PlayRecordStatusButton.ToolTipText = "Movie is in record mode"; PlayRecordStatusButton.ToolTipText = "Movie is in record mode";
PlayRecordStatusButton.Visible = true; PlayRecordStatusButton.Visible = true;
} }
else if (!MovieSession.Movie.IsActive) else if (!MovieSession.Movie.IsActive())
{ {
PlayRecordStatusButton.Image = Properties.Resources.Blank; PlayRecordStatusButton.Image = Properties.Resources.Blank;
PlayRecordStatusButton.ToolTipText = "No movie is active"; PlayRecordStatusButton.ToolTipText = "No movie is active";
@ -129,7 +129,7 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
StartNewMovie(MovieSession.Movie, false); StartNewMovie(MovieSession.Movie, false);
AddOnScreenMessage("Replaying movie file in read-only mode"); AddOnScreenMessage("Replaying movie file in read-only mode");

View File

@ -356,7 +356,7 @@ namespace BizHawk.Client.EmuHawk
Sound.StartSound(); Sound.StartSound();
InputManager.RewireInputChain(); InputManager.RewireInputChain();
GlobalWin.Tools = new ToolManager(this); GlobalWin.Tools = new ToolManager(this, Config, Emulator);
RewireSound(); RewireSound();
// Workaround for windows, location is -32000 when minimized, if they close it during this time, that's what gets saved // Workaround for windows, location is -32000 when minimized, if they close it during this time, that's what gets saved
@ -1010,14 +1010,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public byte[] CurrentFrameBuffer(bool captureOSD)
{
using var bb = captureOSD ? CaptureOSD() : MakeScreenshotImage();
using var img = bb.ToSysdrawingBitmap();
ImageConverter converter = new ImageConverter();
return (byte[])converter.ConvertTo(img, typeof(byte[]));
}
public void TakeScreenshotToClipboard() public void TakeScreenshotToClipboard()
{ {
using (var bb = Config.Screenshot_CaptureOSD ? CaptureOSD() : MakeScreenshotImage()) using (var bb = Config.Screenshot_CaptureOSD ? CaptureOSD() : MakeScreenshotImage())
@ -1076,10 +1068,6 @@ namespace BizHawk.Client.EmuHawk
img.Save(fi.FullName, ImageFormat.Png); img.Save(fi.FullName, ImageFormat.Png);
} }
/*
using (var fs = new FileStream($"{path}_test.bmp", FileMode.OpenOrCreate, FileAccess.Write))
QuickBmpFile.Save(Emulator.VideoProvider(), fs, r.Next(50, 500), r.Next(50, 500));
*/
AddOnScreenMessage($"{fi.Name} saved."); AddOnScreenMessage($"{fi.Name} saved.");
} }
@ -1562,7 +1550,7 @@ namespace BizHawk.Client.EmuHawk
str += $"{VersionInfo.CustomBuildString} "; str += $"{VersionInfo.CustomBuildString} ";
} }
str += Emulator.IsNull() ? "BizHawk" : Global.SystemInfo.DisplayName; str += Emulator.IsNull() ? "BizHawk" : Emulator.System().DisplayName;
if (VersionInfo.DeveloperBuild) if (VersionInfo.DeveloperBuild)
{ {
@ -1573,7 +1561,7 @@ namespace BizHawk.Client.EmuHawk
{ {
str += $" - {Game.Name}"; str += $" - {Game.Name}";
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
str += $" - {Path.GetFileName(MovieSession.Movie.Filename)}"; str += $" - {Path.GetFileName(MovieSession.Movie.Filename)}";
} }
@ -2393,7 +2381,7 @@ namespace BizHawk.Client.EmuHawk
public void PutCoreSyncSettings(object o) public void PutCoreSyncSettings(object o)
{ {
var settable = new SettingsAdapter(Emulator); var settable = new SettingsAdapter(Emulator);
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
AddOnScreenMessage("Attempt to change sync-relevant settings while recording BLOCKED."); AddOnScreenMessage("Attempt to change sync-relevant settings while recording BLOCKED.");
} }
@ -2490,7 +2478,7 @@ namespace BizHawk.Client.EmuHawk
// is it enough to run this for one frame? maybe.. // is it enough to run this for one frame? maybe..
if (Emulator.ControllerDefinition.BoolButtons.Contains("Reset")) if (Emulator.ControllerDefinition.BoolButtons.Contains("Reset"))
{ {
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
ClickyVirtualPadController.Click("Reset"); ClickyVirtualPadController.Click("Reset");
AddOnScreenMessage("Reset button pressed."); AddOnScreenMessage("Reset button pressed.");
@ -2503,7 +2491,7 @@ namespace BizHawk.Client.EmuHawk
// is it enough to run this for one frame? maybe.. // is it enough to run this for one frame? maybe..
if (Emulator.ControllerDefinition.BoolButtons.Contains("Power")) if (Emulator.ControllerDefinition.BoolButtons.Contains("Power"))
{ {
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
ClickyVirtualPadController.Click("Power"); ClickyVirtualPadController.Click("Power");
AddOnScreenMessage("Power button pressed."); AddOnScreenMessage("Power button pressed.");
@ -2676,7 +2664,7 @@ namespace BizHawk.Client.EmuHawk
private void SaveMovie() private void SaveMovie()
{ {
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
MovieSession.Movie.Save(); MovieSession.Movie.Save();
AddOnScreenMessage($"{MovieSession.Movie.Filename} saved."); AddOnScreenMessage($"{MovieSession.Movie.Filename} saved.");
@ -2785,7 +2773,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (Emulator.ControllerDefinition.BoolButtons.Contains(button)) if (Emulator.ControllerDefinition.BoolButtons.Contains(button))
{ {
if (!MovieSession.Movie.IsPlaying || MovieSession.Movie.IsFinished) if (MovieSession.Movie.Mode != MovieMode.Play)
{ {
ClickyVirtualPadController.Click(button); ClickyVirtualPadController.Click(button);
AddOnScreenMessage(msg); AddOnScreenMessage(msg);
@ -3064,7 +3052,7 @@ namespace BizHawk.Client.EmuHawk
MovieSession.Movie.SwitchToRecord(); MovieSession.Movie.SwitchToRecord();
} }
if (isRewinding && !IsRewindSlave && MovieSession.Movie.IsRecording) if (isRewinding && !IsRewindSlave && MovieSession.Movie.IsRecording())
{ {
MovieSession.Movie.Truncate(Global.Emulator.Frame); MovieSession.Movie.Truncate(Global.Emulator.Frame);
} }
@ -3602,7 +3590,7 @@ namespace BizHawk.Client.EmuHawk
private string ChoosePlatformForRom(RomGame rom) private string ChoosePlatformForRom(RomGame rom)
{ {
using var platformChooser = new PlatformChooser using var platformChooser = new PlatformChooser(Config)
{ {
RomGame = rom RomGame = rom
}; };
@ -3841,12 +3829,11 @@ namespace BizHawk.Client.EmuHawk
} }
} }
ApiManager.Restart(Emulator.ServiceProvider); Tools.Restart(Emulator);
Tools.Restart();
if (Config.LoadCheatFileByGame) if (Config.LoadCheatFileByGame)
{ {
CheatList.SetDefaultFileName(ToolManager.GenerateDefaultCheatFilename()); CheatList.SetDefaultFileName(Tools.GenerateDefaultCheatFilename());
if (CheatList.AttemptToLoadCheatFile()) if (CheatList.AttemptToLoadCheatFile())
{ {
AddOnScreenMessage("Cheats file loaded"); AddOnScreenMessage("Cheats file loaded");
@ -3887,19 +3874,19 @@ namespace BizHawk.Client.EmuHawk
ClientApi.OnRomLoaded(Emulator); ClientApi.OnRomLoaded(Emulator);
return true; return true;
} }
else if (!(Emulator is NullEmulator)) else if (Emulator.IsNull())
{
// The ROM has been loaded by a recursive invocation of the LoadROM method.
ClientApi.OnRomLoaded(Emulator);
return true;
}
else
{ {
// This shows up if there's a problem // This shows up if there's a problem
ClientApi.UpdateEmulatorAndVP(Emulator); ClientApi.UpdateEmulatorAndVP(Emulator);
OnRomChanged(); OnRomChanged();
return false; return false;
} }
else
{
// The ROM has been loaded by a recursive invocation of the LoadROM method.
ClientApi.OnRomLoaded(Emulator);
return true;
}
} }
finally finally
{ {
@ -3932,7 +3919,7 @@ namespace BizHawk.Client.EmuHawk
Config.PutCoreSettings(settable.GetSettings(), t); Config.PutCoreSettings(settable.GetSettings(), t);
} }
if (settable.HasSyncSettings && !MovieSession.Movie.IsActive) if (settable.HasSyncSettings && !MovieSession.Movie.IsActive())
{ {
// don't trample config with loaded-from-movie settings // don't trample config with loaded-from-movie settings
Config.PutCoreSyncSettings(settable.GetSyncSettings(), t); Config.PutCoreSyncSettings(settable.GetSyncSettings(), t);
@ -3972,7 +3959,7 @@ namespace BizHawk.Client.EmuHawk
StopAv(); StopAv();
CommitCoreSettingsToConfig(); CommitCoreSettingsToConfig();
if (MovieSession.Movie.IsActive) // Note: this must be called after CommitCoreSettingsToConfig() if (MovieSession.Movie.IsActive()) // Note: this must be called after CommitCoreSettingsToConfig()
{ {
StopMovie(); StopMovie();
} }
@ -4011,8 +3998,7 @@ namespace BizHawk.Client.EmuHawk
Emulator = new NullEmulator(coreComm); Emulator = new NullEmulator(coreComm);
Global.Game = GameInfo.NullInstance; Global.Game = GameInfo.NullInstance;
Tools.Restart(); Tools.Restart(Emulator);
ApiManager.Restart(Emulator.ServiceProvider);
RewireSound(); RewireSound();
ClearHolds(); ClearHolds();
ToolFormBase.UpdateCheatRelatedTools(null, null); ToolFormBase.UpdateCheatRelatedTools(null, null);
@ -4122,7 +4108,7 @@ namespace BizHawk.Client.EmuHawk
UpdateToolsLoadstate(); UpdateToolsLoadstate();
AutoFireController.ClearStarts(); AutoFireController.ClearStarts();
if (!IsRewindSlave && MovieSession.Movie.IsActive) if (!IsRewindSlave && MovieSession.Movie.IsActive())
{ {
ClearRewindData(); ClearRewindData();
} }
@ -4419,7 +4405,7 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
if (MovieSession.Movie.IsActive) if (MovieSession.Movie.IsActive())
{ {
MovieSession.ReadOnly ^= true; MovieSession.ReadOnly ^= true;
AddOnScreenMessage(MovieSession.ReadOnly ? "Movie read-only mode" : "Movie read+write mode"); AddOnScreenMessage(MovieSession.ReadOnly ? "Movie read-only mode" : "Movie read+write mode");
@ -4537,7 +4523,7 @@ namespace BizHawk.Client.EmuHawk
{ {
runFrame = Rewinder.Rewind(1) && Emulator.Frame > 1; runFrame = Rewinder.Rewind(1) && Emulator.Frame > 1;
if (runFrame && MovieSession.Movie.IsRecording) if (runFrame && MovieSession.Movie.IsRecording())
{ {
MovieSession.Movie.SwitchToPlay(); MovieSession.Movie.SwitchToPlay();
returnToRecording = true; returnToRecording = true;

View File

@ -1,103 +0,0 @@
namespace BizHawk.Client.EmuHawk
{
partial class NameStateForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.cancelButton = new System.Windows.Forms.Button();
this.saveButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.stateLabelTextBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// cancelButton
//
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Location = new System.Drawing.Point(199, 51);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(75, 23);
this.cancelButton.TabIndex = 0;
this.cancelButton.Text = "Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// saveButton
//
this.saveButton.Location = new System.Drawing.Point(118, 51);
this.saveButton.Name = "saveButton";
this.saveButton.Size = new System.Drawing.Size(75, 23);
this.saveButton.TabIndex = 1;
this.saveButton.Text = "Save";
this.saveButton.UseVisualStyleBackColor = true;
this.saveButton.Click += new System.EventHandler(this.saveButton_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(181, 13);
this.label1.TabIndex = 2;
this.label1.Text = "Enter a short label for this save state:";
//
// stateLabelTextBox
//
this.stateLabelTextBox.Location = new System.Drawing.Point(15, 25);
this.stateLabelTextBox.MaxLength = 248;
this.stateLabelTextBox.Name = "stateLabelTextBox";
this.stateLabelTextBox.Size = new System.Drawing.Size(259, 20);
this.stateLabelTextBox.TabIndex = 3;
//
// NameStateForm
//
this.AcceptButton = this.saveButton;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelButton;
this.ClientSize = new System.Drawing.Size(278, 81);
this.Controls.Add(this.stateLabelTextBox);
this.Controls.Add(this.label1);
this.Controls.Add(this.saveButton);
this.Controls.Add(this.cancelButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "NameStateForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Label Save State";
this.Shown += new System.EventHandler(this.NameStateForm_Shown);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.Button saveButton;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox stateLabelTextBox;
}
}

View File

@ -1,38 +0,0 @@
using System;
using System.Windows.Forms;
namespace BizHawk.Client.EmuHawk
{
public partial class NameStateForm : Form
{
public string Result;
public bool OK;
public NameStateForm()
{
InitializeComponent();
AcceptButton = saveButton;
CancelButton = cancelButton;
}
private void cancelButton_Click(object sender, EventArgs e)
{
Close();
}
private void saveButton_Click(object sender, EventArgs e)
{
if (stateLabelTextBox.Text.Length != 0)
{
Result = stateLabelTextBox.Text;
OK = true;
Close();
}
}
private void NameStateForm_Shown(object sender, EventArgs e)
{
stateLabelTextBox.Focus();
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,10 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
@ -14,41 +11,32 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class PlatformChooser : Form public partial class PlatformChooser : Form
{ {
private readonly Config _config;
private readonly List<SystemLookup.SystemInfo> _availableSystems = new SystemLookup().AllSystems.ToList();
public PlatformChooser(Config config)
{
_config = config;
InitializeComponent();
}
public RomGame RomGame { get; set; } public RomGame RomGame { get; set; }
public string PlatformChoice { get; set; } public string PlatformChoice { get; set; }
private RadioButton SelectedRadio private RadioButton SelectedRadio => PlatformsGroupBox.Controls.OfType<RadioButton>().FirstOrDefault(x => x.Checked);
{
get
{
return PlatformsGroupBox.Controls.OfType<RadioButton>().FirstOrDefault(x => x.Checked);
}
}
public PlatformChooser()
{
InitializeComponent();
AvailableSystems = new SystemLookup().AllSystems.ToList();
}
private readonly List<SystemLookup.SystemInfo> AvailableSystems;
private void PlatformChooser_Load(object sender, EventArgs e) private void PlatformChooser_Load(object sender, EventArgs e)
{ {
if (RomGame.RomData.Length > 10 * 1024 * 1024) // If 10mb, show in megabytes RomSizeLabel.Text = RomGame.RomData.Length > 10 * 1024 * 1024
{ ? $"{RomGame.RomData.Length / 1024 / 1024:n0}mb"
RomSizeLabel.Text = $"{RomGame.RomData.Length / 1024 / 1024:n0}mb"; : $"{RomGame.RomData.Length / 1024:n0}kb";
}
else
{
RomSizeLabel.Text = $"{RomGame.RomData.Length / 1024:n0}kb";
}
ExtensionLabel.Text = RomGame.Extension.ToLower(); ExtensionLabel.Text = RomGame.Extension.ToLower();
HashBox.Text = RomGame.GameInfo.Hash; HashBox.Text = RomGame.GameInfo.Hash;
int count = 0; int count = 0;
int spacing = 25; int spacing = 25;
foreach (var platform in AvailableSystems) foreach (var platform in _availableSystems)
{ {
var radio = new RadioButton var radio = new RadioButton
{ {
@ -75,11 +63,11 @@ namespace BizHawk.Client.EmuHawk
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
var selectedValue = SelectedRadio != null ? SelectedRadio.Text : ""; var selectedValue = SelectedRadio != null ? SelectedRadio.Text : "";
PlatformChoice = AvailableSystems.FirstOrDefault(x => x.FullName == selectedValue).SystemId; PlatformChoice = _availableSystems.First(x => x.FullName == selectedValue).SystemId;
if (AlwaysCheckbox.Checked) if (AlwaysCheckbox.Checked)
{ {
Global.Config.PreferredPlatformsForExtensions[RomGame.Extension.ToLower()] = PlatformChoice; _config.PreferredPlatformsForExtensions[RomGame.Extension.ToLower()] = PlatformChoice;
} }
Close(); Close();

View File

@ -146,13 +146,15 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.IGL_GL = new Bizware.BizwareGL.Drivers.OpenTK.IGL_TK(2, 0, false); GlobalWin.IGL_GL = new Bizware.BizwareGL.Drivers.OpenTK.IGL_TK(2, 0, false);
// setup the GL context manager, needed for coping with multiple opengl cores vs opengl display method // setup the GL context manager, needed for coping with multiple opengl cores vs opengl display method
GLManager.CreateInstance(GlobalWin.IGL_GL); GLManager.CreateInstance();
GlobalWin.GLManager = GLManager.Instance; GlobalWin.GLManager = GLManager.Instance;
//now create the "GL" context for the display method. we can reuse the IGL_TK context if opengl display method is chosen //now create the "GL" context for the display method. we can reuse the IGL_TK context if opengl display method is chosen
REDO_DISPMETHOD: REDO_DISPMETHOD:
if (Global.Config.DispMethod == Config.EDispMethod.GdiPlus) if (Global.Config.DispMethod == Config.EDispMethod.GdiPlus)
{
GlobalWin.GL = new Bizware.BizwareGL.Drivers.GdiPlus.IGL_GdiPlus(); GlobalWin.GL = new Bizware.BizwareGL.Drivers.GdiPlus.IGL_GdiPlus();
}
else if (Global.Config.DispMethod == Config.EDispMethod.SlimDX9) else if (Global.Config.DispMethod == Config.EDispMethod.SlimDX9)
{ {
try try
@ -172,7 +174,7 @@ namespace BizHawk.Client.EmuHawk
{ {
GlobalWin.GL = GlobalWin.IGL_GL; GlobalWin.GL = GlobalWin.IGL_GL;
// check the opengl version and dont even try to boot this crap up if its too old // check the opengl version and don't even try to boot this crap up if its too old
if (GlobalWin.IGL_GL.Version < 200) if (GlobalWin.IGL_GL.Version < 200)
{ {
// fallback // fallback
@ -221,27 +223,25 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
using (var mf = new MainForm(args)) using var mf = new MainForm(args);
var title = mf.Text;
mf.Show();
mf.Text = title;
try
{ {
var title = mf.Text; GlobalWin.ExitCode = mf.ProgramRunLoop();
mf.Show(); }
mf.Text = title; catch (Exception e) when (Global.MovieSession.Movie.IsActive() && !(Debugger.IsAttached || VersionInfo.DeveloperBuild))
try {
var result = MessageBox.Show(
"EmuHawk has thrown a fatal exception and is about to close.\nA movie has been detected. Would you like to try to save?\n(Note: Depending on what caused this error, this may or may not succeed)",
$"Fatal error: {e.GetType().Name}",
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation
);
if (result == DialogResult.Yes)
{ {
GlobalWin.ExitCode = mf.ProgramRunLoop(); Global.MovieSession.Movie.Save();
}
catch (Exception e) when (Global.MovieSession.Movie.IsActive && !(Debugger.IsAttached || VersionInfo.DeveloperBuild))
{
var result = MessageBox.Show(
"EmuHawk has thrown a fatal exception and is about to close.\nA movie has been detected. Would you like to try to save?\n(Note: Depending on what caused this error, this may or may not succeed)",
$"Fatal error: {e.GetType().Name}",
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation
);
if (result == DialogResult.Yes)
{
Global.MovieSession.Movie.Save();
}
} }
} }
} }

View File

@ -28,7 +28,7 @@ namespace BizHawk.Client.EmuHawk
_s = s ?? new Gameboy.GambatteSettings(); _s = s ?? new Gameboy.GambatteSettings();
_ss = ss ?? new Gameboy.GambatteSyncSettings(); _ss = ss ?? new Gameboy.GambatteSyncSettings();
propertyGrid1.SelectedObject = _ss; propertyGrid1.SelectedObject = _ss;
propertyGrid1.Enabled = !Global.MovieSession.Movie.IsActive; propertyGrid1.Enabled = Global.MovieSession.Movie.NotActive();
checkBoxMuted.Checked = _s.Muted; checkBoxMuted.Checked = _s.Muted;
cbDisplayBG.Checked = _s.DisplayBG; cbDisplayBG.Checked = _s.DisplayBG;
cbDisplayOBJ.Checked = _s.DisplayOBJ; cbDisplayOBJ.Checked = _s.DisplayOBJ;
@ -43,8 +43,8 @@ namespace BizHawk.Client.EmuHawk
private void ButtonDefaults_Click(object sender, EventArgs e) private void ButtonDefaults_Click(object sender, EventArgs e)
{ {
PutSettings(null, Global.MovieSession.Movie.IsActive ? _ss : null); PutSettings(null, Global.MovieSession.Movie.IsActive() ? _ss : null);
if (!Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.NotActive())
{ {
SyncSettingsChanged = true; SyncSettingsChanged = true;
} }

View File

@ -52,7 +52,7 @@ namespace BizHawk.Client.EmuHawk
tabControl1.TabPages.Remove(tabPage2); tabControl1.TabPages.Remove(tabPage2);
} }
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive())
{ {
propertyGrid2.Enabled = false; // disable changes to sync setting when movie, so as not to confuse user propertyGrid2.Enabled = false; // disable changes to sync setting when movie, so as not to confuse user
} }

View File

@ -530,8 +530,7 @@
0, 0,
0, 0,
0}); 0});
this.XNumeric.Click += new System.EventHandler(this.XNumeric_Click); this.XNumeric.ValueChanged += new System.EventHandler(this.XNumeric_Changed);
this.XNumeric.KeyUp += new System.Windows.Forms.KeyEventHandler(this.XNumeric_KeyUp);
// //
// YNumeric // YNumeric
// //
@ -550,8 +549,7 @@
0, 0,
0, 0,
0}); 0});
this.YNumeric.Click += new System.EventHandler(this.YNumeric_Click); this.YNumeric.ValueChanged += new System.EventHandler(this.YNumeric_Changed);
this.YNumeric.KeyUp += new System.Windows.Forms.KeyEventHandler(this.YNumeric_KeyUp);
// //
// label1 // label1
// //

View File

@ -2,54 +2,55 @@
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Common.IEmulatorExtensions;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Client.EmuHawk.WinFormExtensions;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class MessageConfig : Form public partial class MessageConfig : Form
{ {
private int _dispFpSx = Global.Config.DispFPSx; private readonly Config _config;
private int _dispFpSy = Global.Config.DispFPSy;
private int _dispFrameCx = Global.Config.DispFrameCx;
private int _dispFrameCy = Global.Config.DispFrameCy;
private int _dispLagx = Global.Config.DispLagx;
private int _dispLagy = Global.Config.DispLagy;
private int _dispInpx = Global.Config.DispInpx;
private int _dispInpy = Global.Config.DispInpy;
private int _dispWatchesx = Global.Config.DispRamWatchx;
private int _dispWatchesy = Global.Config.DispRamWatchy;
private int _lastInputColor = Global.Config.LastInputColor;
private int _dispRecx = Global.Config.DispRecx;
private int _dispRecy = Global.Config.DispRecy;
private int _dispMultix = Global.Config.DispMultix;
private int _dispMultiy = Global.Config.DispMultiy;
private int _dispMessagex = Global.Config.DispMessagex;
private int _dispMessagey = Global.Config.DispMessagey;
private int _dispAutoholdx = Global.Config.DispAutoholdx;
private int _dispAutoholdy = Global.Config.DispAutoholdy;
private int _messageColor = Global.Config.MessagesColor; private MessagePosition _fps;
private int _alertColor = Global.Config.AlertMessageColor; private MessagePosition _frameCounter;
private int _movieInput = Global.Config.MovieInput; private MessagePosition _lagCounter;
private MessagePosition _inputDisplay;
private MessagePosition _reRecordCounter;
private MessagePosition _multitrackRecorder;
private MessagePosition _messages;
private MessagePosition _autohold;
private MessagePosition _ramWatches;
private int _messageColor;
private int _alertColor;
private int _lastInputColor;
private int _movieInput;
private int _dispFpSanchor = Global.Config.DispFPSanchor;
private int _dispFrameanchor = Global.Config.DispFrameanchor;
private int _dispLaganchor = Global.Config.DispLaganchor;
private int _dispInputanchor = Global.Config.DispInpanchor;
private int _dispWatchesanchor = Global.Config.DispWatchesanchor;
private int _dispRecanchor = Global.Config.DispRecanchor;
private int _dispMultiAnchor = Global.Config.DispMultianchor;
private int _dispMessageAnchor = Global.Config.DispMessageanchor;
private int _dispAutoholdAnchor = Global.Config.DispAutoholdanchor;
private readonly Brush _brush = Brushes.Black;
private int _px; private int _px;
private int _py; private int _py;
private bool _mousedown; private bool _mousedown;
private bool _programmaticallyChangingValues;
public MessageConfig() public MessageConfig(Config config)
{ {
_config = config;
_fps = _config.Fps.Clone();
_frameCounter = _config.FrameCounter.Clone();
_lagCounter = _config.LagCounter.Clone();
_inputDisplay = _config.InputDisplay.Clone();
_reRecordCounter = _config.ReRecordCounter.Clone();
_multitrackRecorder = _config.MultitrackRecorder.Clone();
_messages = _config.Messages.Clone();
_autohold = _config.Autohold.Clone();
_ramWatches = _config.RamWatches.Clone();
_messageColor = _config.MessagesColor;
_alertColor = _config.AlertMessageColor;
_lastInputColor = _config.LastInputColor;
_movieInput = _config.MovieInput;
InitializeComponent(); InitializeComponent();
} }
@ -62,12 +63,12 @@ namespace BizHawk.Client.EmuHawk
MovieInputColorDialog.Color = Color.FromArgb(_movieInput); MovieInputColorDialog.Color = Color.FromArgb(_movieInput);
SetColorBox(); SetColorBox();
SetPositionInfo(); SetPositionInfo();
StackMessagesCheckbox.Checked = Global.Config.StackOSDMessages; StackMessagesCheckbox.Checked = _config.StackOSDMessages;
} }
private void SetMaxXy() private void SetMaxXy()
{ {
var video = Global.Emulator.AsVideoProvider(); // TODO: this is objectively wrong, these are core agnostic settings, why is the current core used here? Also this will crash on a core without a video provider var video = NullVideo.Instance; // Good enough
XNumeric.Maximum = video.BufferWidth - 12; XNumeric.Maximum = video.BufferWidth - 12;
YNumeric.Maximum = video.BufferHeight - 12; YNumeric.Maximum = video.BufferHeight - 12;
PositionPanel.Size = new Size(video.BufferWidth + 2, video.BufferHeight + 2); PositionPanel.Size = new Size(video.BufferWidth + 2, video.BufferHeight + 2);
@ -96,99 +97,71 @@ namespace BizHawk.Client.EmuHawk
MovieInputText.Text = $"{_movieInput:X8}"; MovieInputText.Text = $"{_movieInput:X8}";
} }
private void SetAnchorRadio(int anchor) private void SetFromOption(MessagePosition position)
{ {
switch (anchor) _programmaticallyChangingValues = true;
XNumeric.Value = position.X;
YNumeric.Value = position.Y;
_px = position.X;
_py = position.Y;
switch (position.Anchor)
{ {
default: default:
case 0: case MessagePosition.AnchorType.TopLeft:
TL.Checked = true; TL.Checked = true;
break; break;
case 1: case MessagePosition.AnchorType.TopRight:
TR.Checked = true; TR.Checked = true;
break; break;
case 2: case MessagePosition.AnchorType.BottomLeft:
BL.Checked = true; BL.Checked = true;
break; break;
case 3: case MessagePosition.AnchorType.BottomRight:
BR.Checked = true; BR.Checked = true;
break; break;
} }
_programmaticallyChangingValues = false;
} }
private void SetPositionInfo() private void SetPositionInfo()
{ {
if (FPSRadio.Checked) if (FPSRadio.Checked)
{ {
XNumeric.Value = _dispFpSx; SetFromOption(_fps);
YNumeric.Value = _dispFpSy;
_px = _dispFpSx;
_py = _dispFpSy;
SetAnchorRadio(_dispFpSanchor);
} }
else if (FrameCounterRadio.Checked) else if (FrameCounterRadio.Checked)
{ {
XNumeric.Value = _dispFrameCx; SetFromOption(_frameCounter);
YNumeric.Value = _dispFrameCy;
_px = _dispFrameCx;
_py = _dispFrameCy;
SetAnchorRadio(_dispFrameanchor);
} }
else if (LagCounterRadio.Checked) else if (LagCounterRadio.Checked)
{ {
XNumeric.Value = _dispLagx; SetFromOption(_lagCounter);
YNumeric.Value = _dispLagy;
_px = _dispLagx;
_py = _dispLagy;
SetAnchorRadio(_dispLaganchor);
} }
else if (InputDisplayRadio.Checked) else if (InputDisplayRadio.Checked)
{ {
XNumeric.Value = _dispInpx; SetFromOption(_inputDisplay);
XNumeric.Value = _dispInpy;
_px = _dispInpx;
_py = _dispInpy;
SetAnchorRadio(_dispInputanchor);
} }
else if (WatchesRadio.Checked) else if (WatchesRadio.Checked)
{ {
XNumeric.Value = _dispWatchesx; SetFromOption(_ramWatches);
XNumeric.Value = _dispWatchesy;
_px = _dispWatchesx;
_py = _dispWatchesy;
SetAnchorRadio(_dispWatchesanchor);
} }
else if (MessagesRadio.Checked) else if (MessagesRadio.Checked)
{ {
XNumeric.Value = _dispMessagex; SetFromOption(_messages);
YNumeric.Value = _dispMessagey;
_px = _dispMessagex;
_py = _dispMessagey;
SetAnchorRadio(_dispMessageAnchor);
} }
else if (RerecordsRadio.Checked) else if (RerecordsRadio.Checked)
{ {
XNumeric.Value = _dispRecx; SetFromOption(_reRecordCounter);
YNumeric.Value = _dispRecy;
_px = _dispRecx;
_py = _dispRecy;
SetAnchorRadio(_dispRecanchor);
} }
else if (MultitrackRadio.Checked) else if (MultitrackRadio.Checked)
{ {
XNumeric.Value = _dispMultix; SetFromOption(_multitrackRecorder);
YNumeric.Value = _dispMultiy;
_px = _dispMultix;
_py = _dispMultiy;
SetAnchorRadio(_dispMultiAnchor);
} }
else if (AutoholdRadio.Checked) else if (AutoholdRadio.Checked)
{ {
XNumeric.Value = _dispAutoholdx; SetFromOption(_autohold);
YNumeric.Value = _dispAutoholdy;
_px = _dispAutoholdx;
_py = _dispAutoholdy;
SetAnchorRadio(_dispAutoholdAnchor);
} }
PositionPanel.Refresh(); PositionPanel.Refresh();
@ -197,46 +170,25 @@ namespace BizHawk.Client.EmuHawk
SetPositionLabels(); SetPositionLabels();
} }
private void SaveSettings()
{
Global.Config.DispFPSx = _dispFpSx;
Global.Config.DispFPSy = _dispFpSy;
Global.Config.DispFrameCx = _dispFrameCx;
Global.Config.DispFrameCy = _dispFrameCy;
Global.Config.DispLagx = _dispLagx;
Global.Config.DispLagy = _dispLagy;
Global.Config.DispInpx = _dispInpx;
Global.Config.DispInpy = _dispInpy;
Global.Config.DispRamWatchx = _dispWatchesx;
Global.Config.DispRamWatchy = _dispWatchesy;
Global.Config.DispRecx = _dispRecx;
Global.Config.DispRecy = _dispRecy;
Global.Config.DispMultix = _dispMultix;
Global.Config.DispMultiy = _dispMultiy;
Global.Config.DispMessagex = _dispMessagex;
Global.Config.DispMessagey = _dispMessagey;
Global.Config.DispAutoholdx = _dispAutoholdx;
Global.Config.DispAutoholdy = _dispAutoholdy;
Global.Config.MessagesColor = _messageColor;
Global.Config.AlertMessageColor = _alertColor;
Global.Config.LastInputColor = _lastInputColor;
Global.Config.MovieInput = _movieInput;
Global.Config.DispFPSanchor = _dispFpSanchor;
Global.Config.DispFrameanchor = _dispFrameanchor;
Global.Config.DispLaganchor = _dispLaganchor;
Global.Config.DispInpanchor = _dispInputanchor;
Global.Config.DispRecanchor = _dispRecanchor;
Global.Config.DispMultianchor = _dispMultiAnchor;
Global.Config.DispMessageanchor = _dispMessageAnchor;
Global.Config.DispAutoholdanchor = _dispAutoholdAnchor;
Global.Config.StackOSDMessages = StackMessagesCheckbox.Checked;
}
private void Ok_Click(object sender, EventArgs e) private void Ok_Click(object sender, EventArgs e)
{ {
SaveSettings(); _config.Fps = _fps;
_config.FrameCounter = _frameCounter;
_config.LagCounter = _lagCounter;
_config.InputDisplay = _inputDisplay;
_config.ReRecordCounter = _reRecordCounter;
_config.MultitrackRecorder = _multitrackRecorder;
_config.Messages = _messages;
_config.Autohold = _autohold;
_config.RamWatches = _ramWatches;
_config.MessagesColor = _messageColor;
_config.AlertMessageColor = _alertColor;
_config.LastInputColor = _lastInputColor;
_config.MovieInput = _movieInput;
_config.StackOSDMessages = StackMessagesCheckbox.Checked;
DialogResult = DialogResult.OK;
Close(); Close();
} }
@ -250,20 +202,6 @@ namespace BizHawk.Client.EmuHawk
SetPositionInfo(); SetPositionInfo();
} }
private void XNumericChange()
{
_px = (int)XNumeric.Value;
SetPositionLabels();
PositionPanel.Refresh();
}
private void YNumericChange()
{
_py = (int)YNumeric.Value;
SetPositionLabels();
PositionPanel.Refresh();
}
private void PositionPanel_MouseEnter(object sender, EventArgs e) private void PositionPanel_MouseEnter(object sender, EventArgs e)
{ {
Cursor = Cursors.Hand; Cursor = Cursors.Hand;
@ -300,7 +238,7 @@ namespace BizHawk.Client.EmuHawk
y = (int)YNumeric.Maximum - _py; y = (int)YNumeric.Maximum - _py;
} }
using var p = new Pen(_brush); using var p = new Pen(Color.Black);
e.Graphics.DrawLine(p, new Point(x, y), new Point(x + 8, y + 8)); e.Graphics.DrawLine(p, new Point(x, y), new Point(x + 8, y + 8));
e.Graphics.DrawLine(p, new Point(x + 8, y), new Point(x, y + 8)); e.Graphics.DrawLine(p, new Point(x + 8, y), new Point(x, y + 8));
e.Graphics.DrawRectangle(p, new Rectangle(x, y, 8, 8)); e.Graphics.DrawRectangle(p, new Rectangle(x, y, 8, 8));
@ -321,6 +259,7 @@ namespace BizHawk.Client.EmuHawk
private void SetNewPosition(int mx, int my) private void SetNewPosition(int mx, int my)
{ {
_programmaticallyChangingValues = true;
if (mx < 0) mx = 0; if (mx < 0) mx = 0;
if (my < 0) my = 0; if (my < 0) my = 0;
if (mx > XNumeric.Maximum) mx = (int)XNumeric.Maximum; if (mx > XNumeric.Maximum) mx = (int)XNumeric.Maximum;
@ -351,6 +290,8 @@ namespace BizHawk.Client.EmuHawk
PositionPanel.Refresh(); PositionPanel.Refresh();
SetPositionLabels(); SetPositionLabels();
_programmaticallyChangingValues = false;
} }
private void PositionPanel_MouseMove(object sender, MouseEventArgs e) private void PositionPanel_MouseMove(object sender, MouseEventArgs e)
@ -361,128 +302,83 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void SetOptionPosition(MessagePosition position)
{
position.X = _px;
position.Y = _py;
}
private void SetPositionLabels() private void SetPositionLabels()
{ {
if (FPSRadio.Checked) if (FPSRadio.Checked)
{ {
_dispFpSx = _px; SetOptionPosition(_fps);
_dispFpSy = _py;
} }
else if (FrameCounterRadio.Checked) else if (FrameCounterRadio.Checked)
{ {
_dispFrameCx = _px; SetOptionPosition(_frameCounter);
_dispFrameCy = _py;
} }
else if (LagCounterRadio.Checked) else if (LagCounterRadio.Checked)
{ {
_dispLagx = _px; SetOptionPosition(_lagCounter);
_dispLagy = _py;
} }
else if (InputDisplayRadio.Checked) else if (InputDisplayRadio.Checked)
{ {
_dispInpx = _px; SetOptionPosition(_inputDisplay);
_dispInpy = _py;
} }
else if (WatchesRadio.Checked) else if (WatchesRadio.Checked)
{ {
_dispWatchesx = _px; SetOptionPosition(_ramWatches);
_dispWatchesy = _py;
} }
else if (RerecordsRadio.Checked) else if (RerecordsRadio.Checked)
{ {
_dispRecx = _px; SetOptionPosition(_reRecordCounter);
_dispRecy = _py;
} }
else if (MultitrackRadio.Checked) else if (MultitrackRadio.Checked)
{ {
_dispMultix = _px; SetOptionPosition(_multitrackRecorder);
_dispMultiy = _py;
} }
else if (MessagesRadio.Checked) else if (MessagesRadio.Checked)
{ {
_dispMessagex = _px; SetOptionPosition(_messages);
_dispMessagey = _py;
} }
else if (AutoholdRadio.Checked) else if (AutoholdRadio.Checked)
{ {
_dispAutoholdx = _px; SetOptionPosition(_autohold);
_dispAutoholdy = _py;
} }
FpsPosLabel.Text = $"{_dispFpSx}, {_dispFpSy}"; FpsPosLabel.Text = ToCoordinateStr(_fps);
FCLabel.Text = $"{_dispFrameCx}, {_dispFrameCy}"; FCLabel.Text = ToCoordinateStr(_frameCounter);
LagLabel.Text = $"{_dispLagx}, {_dispLagy}"; LagLabel.Text = ToCoordinateStr(_lagCounter);
InpLabel.Text = $"{_dispInpx}, {_dispInpy}"; InpLabel.Text = ToCoordinateStr(_inputDisplay);
WatchesLabel.Text = $"{_dispWatchesx}, {_dispWatchesy}"; WatchesLabel.Text = ToCoordinateStr(_ramWatches);
RerecLabel.Text = $"{_dispRecx}, {_dispRecy}"; RerecLabel.Text = ToCoordinateStr(_reRecordCounter);
MultitrackLabel.Text = $"{_dispMultix}, {_dispMultiy}"; MultitrackLabel.Text = ToCoordinateStr(_multitrackRecorder);
MessLabel.Text = $"{_dispMessagex}, {_dispMessagey}"; MessLabel.Text = ToCoordinateStr(_messages);
AutoholdLabel.Text = $"{_dispAutoholdx}, {_dispAutoholdy}"; AutoholdLabel.Text = ToCoordinateStr(_autohold);
}
private string ToCoordinateStr(MessagePosition position)
{
return $"{position.X}, {position.Y}";
} }
private void ResetDefaultsButton_Click(object sender, EventArgs e) private void ResetDefaultsButton_Click(object sender, EventArgs e)
{ {
Global.Config.DispFPSx = Config.DefaultMessageOptions.DispFPSx; _fps = _config.Fps = DefaultMessagePositions.Fps.Clone();
Global.Config.DispFPSy = Config.DefaultMessageOptions.DispFPSy; _frameCounter = _config.FrameCounter = DefaultMessagePositions.FrameCounter.Clone();
Global.Config.DispFrameCx = Config.DefaultMessageOptions.DispFrameCx; _lagCounter = _config.LagCounter = DefaultMessagePositions.LagCounter.Clone();
Global.Config.DispFrameCy = Config.DefaultMessageOptions.DispFrameCy; _inputDisplay = _config.InputDisplay = DefaultMessagePositions.InputDisplay.Clone();
Global.Config.DispLagx = Config.DefaultMessageOptions.DispLagx; _reRecordCounter = _config.ReRecordCounter = DefaultMessagePositions.ReRecordCounter.Clone();
Global.Config.DispLagy = Config.DefaultMessageOptions.DispLagy; _multitrackRecorder = _config.MultitrackRecorder = DefaultMessagePositions.MultitrackRecorder.Clone();
Global.Config.DispInpx = Config.DefaultMessageOptions.DispInpx; _messages = _config.Messages = DefaultMessagePositions.Messages.Clone();
Global.Config.DispInpy = Config.DefaultMessageOptions.DispInpy; _autohold = _config.Autohold = DefaultMessagePositions.Autohold.Clone();
Global.Config.DispRecx = Config.DefaultMessageOptions.DispRecx; _ramWatches = _config.RamWatches = DefaultMessagePositions.RamWatches.Clone();
Global.Config.DispRecy = Config.DefaultMessageOptions.DispRecy;
Global.Config.DispMultix = Config.DefaultMessageOptions.DispMultix;
Global.Config.DispMultiy = Config.DefaultMessageOptions.DispMultiy;
Global.Config.DispMessagex = Config.DefaultMessageOptions.DispMessagex;
Global.Config.DispMessagey = Config.DefaultMessageOptions.DispMessagey;
Global.Config.DispAutoholdx = Config.DefaultMessageOptions.DispAutoholdx;
Global.Config.DispAutoholdy = Config.DefaultMessageOptions.DispAutoholdy;
Global.Config.DispFPSanchor = Config.DefaultMessageOptions.DispFPSanchor; _messageColor = _config.MessagesColor = DefaultMessagePositions.MessagesColor;
Global.Config.DispFrameanchor = Config.DefaultMessageOptions.DispFrameanchor; _alertColor = _config.AlertMessageColor = DefaultMessagePositions.AlertMessageColor;
Global.Config.DispLaganchor = Config.DefaultMessageOptions.DispLaganchor; _lastInputColor = _config.LastInputColor = DefaultMessagePositions.LastInputColor;
Global.Config.DispInpanchor = Config.DefaultMessageOptions.DispInpanchor; _movieInput = _config.MovieInput = DefaultMessagePositions.MovieInput;
Global.Config.DispRecanchor = Config.DefaultMessageOptions.DispRecanchor;
Global.Config.DispMultianchor = Config.DefaultMessageOptions.DispMultianchor;
Global.Config.DispMessageanchor = Config.DefaultMessageOptions.DispMessageanchor;
Global.Config.DispAutoholdanchor = Config.DefaultMessageOptions.DispAutoholdanchor;
Global.Config.MessagesColor = Config.DefaultMessageOptions.MessagesColor;
Global.Config.AlertMessageColor = Config.DefaultMessageOptions.AlertMessageColor;
Global.Config.LastInputColor = Config.DefaultMessageOptions.LastInputColor;
Global.Config.MovieInput = Config.DefaultMessageOptions.MovieInput;
_dispFpSx = Global.Config.DispFPSx;
_dispFpSy = Global.Config.DispFPSy;
_dispFrameCx = Global.Config.DispFrameCx;
_dispFrameCy = Global.Config.DispFrameCy;
_dispLagx = Global.Config.DispLagx;
_dispLagy = Global.Config.DispLagy;
_dispInpx = Global.Config.DispInpx;
_dispInpy = Global.Config.DispInpy;
_dispRecx = Global.Config.DispRecx;
_dispRecy = Global.Config.DispRecy;
_dispMultix = Global.Config.DispMultix;
_dispMultiy = Global.Config.DispMultiy;
_dispMessagex = Global.Config.DispMessagex;
_dispMessagey = Global.Config.DispMessagey;
_dispAutoholdx = Global.Config.DispAutoholdx;
_dispAutoholdy = Global.Config.DispAutoholdy;
_dispFpSanchor = Global.Config.DispFPSanchor;
_dispFrameanchor = Global.Config.DispFrameanchor;
_dispLaganchor = Global.Config.DispLaganchor;
_dispInputanchor = Global.Config.DispInpanchor;
_dispRecanchor = Global.Config.DispRecanchor;
_dispMultiAnchor = Global.Config.DispMultianchor;
_dispMessageAnchor = Global.Config.DispMessageanchor;
_dispAutoholdAnchor = Global.Config.DispAutoholdanchor;
_messageColor = Global.Config.MessagesColor;
_alertColor = Global.Config.AlertMessageColor;
_lastInputColor = Global.Config.LastInputColor;
_movieInput = Global.Config.MovieInput;
MessageColorDialog.Color = Color.FromArgb(_messageColor); MessageColorDialog.Color = Color.FromArgb(_messageColor);
AlertColorDialog.Color = Color.FromArgb(_alertColor); AlertColorDialog.Color = Color.FromArgb(_alertColor);
@ -493,46 +389,46 @@ namespace BizHawk.Client.EmuHawk
SetColorBox(); SetColorBox();
SetPositionInfo(); SetPositionInfo();
StackMessagesCheckbox.Checked = Global.Config.StackOSDMessages = true; StackMessagesCheckbox.Checked = _config.StackOSDMessages = true;
} }
private void SetAnchorValue(int value) private void SetAnchorValue(MessagePosition.AnchorType value)
{ {
if (FPSRadio.Checked) if (FPSRadio.Checked)
{ {
_dispFpSanchor = value; _fps.Anchor = value;
} }
else if (FrameCounterRadio.Checked) else if (FrameCounterRadio.Checked)
{ {
_dispFrameanchor = value; _frameCounter.Anchor = value;
} }
else if (LagCounterRadio.Checked) else if (LagCounterRadio.Checked)
{ {
_dispLaganchor = value; _lagCounter.Anchor = value;
} }
else if (InputDisplayRadio.Checked) else if (InputDisplayRadio.Checked)
{ {
_dispInputanchor = value; _inputDisplay.Anchor = value;
} }
else if (WatchesRadio.Checked) else if (WatchesRadio.Checked)
{ {
_dispWatchesanchor = value; _ramWatches.Anchor = value;
} }
else if (MessagesRadio.Checked) else if (MessagesRadio.Checked)
{ {
_dispMessageAnchor = value; _messages.Anchor = value;
} }
else if (RerecordsRadio.Checked) else if (RerecordsRadio.Checked)
{ {
_dispRecanchor = value; _reRecordCounter.Anchor = value;
} }
else if (MultitrackRadio.Checked) else if (MultitrackRadio.Checked)
{ {
_dispMultiAnchor = value; _multitrackRecorder.Anchor = value;
} }
else if (AutoholdRadio.Checked) else if (AutoholdRadio.Checked)
{ {
_dispAutoholdAnchor = value; _autohold.Anchor = value;
} }
} }
@ -540,7 +436,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (TL.Checked) if (TL.Checked)
{ {
SetAnchorValue(0); SetAnchorValue(MessagePosition.AnchorType.TopLeft);
} }
PositionPanel.Refresh(); PositionPanel.Refresh();
@ -550,7 +446,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (TR.Checked) if (TR.Checked)
{ {
SetAnchorValue(1); SetAnchorValue(MessagePosition.AnchorType.TopRight);
} }
PositionPanel.Refresh(); PositionPanel.Refresh();
@ -560,8 +456,9 @@ namespace BizHawk.Client.EmuHawk
{ {
if (BL.Checked) if (BL.Checked)
{ {
SetAnchorValue(2); SetAnchorValue(MessagePosition.AnchorType.BottomLeft);
} }
PositionPanel.Refresh(); PositionPanel.Refresh();
} }
@ -569,24 +466,35 @@ namespace BizHawk.Client.EmuHawk
{ {
if (BR.Checked) if (BR.Checked)
{ {
SetAnchorValue(3); SetAnchorValue(MessagePosition.AnchorType.BottomRight);
} }
PositionPanel.Refresh(); PositionPanel.Refresh();
} }
private void XNumeric_Click(object sender, EventArgs e) private void XNumeric_Changed(object sender, EventArgs e)
{ {
XNumericChange(); if (!_programmaticallyChangingValues)
{
_px = (int)XNumeric.Value;
SetPositionLabels();
PositionPanel.Refresh();
}
} }
private void YNumeric_Click(object sender, EventArgs e) private void YNumeric_Changed(object sender, EventArgs e)
{ {
YNumericChange(); if (!_programmaticallyChangingValues)
{
_py = (int)YNumeric.Value;
SetPositionLabels();
PositionPanel.Refresh();
}
} }
private void ColorPanel_Click(object sender, EventArgs e) private void ColorPanel_Click(object sender, EventArgs e)
{ {
if (MessageColorDialog.ShowDialog() == DialogResult.OK) if (MessageColorDialog.ShowDialog().IsOk())
{ {
SetColorBox(); SetColorBox();
} }
@ -594,7 +502,7 @@ namespace BizHawk.Client.EmuHawk
private void AlertColorPanel_Click(object sender, EventArgs e) private void AlertColorPanel_Click(object sender, EventArgs e)
{ {
if (AlertColorDialog.ShowDialog() == DialogResult.OK) if (AlertColorDialog.ShowDialog().IsOk())
{ {
SetColorBox(); SetColorBox();
} }
@ -602,7 +510,7 @@ namespace BizHawk.Client.EmuHawk
private void LInputColorPanel_Click(object sender, EventArgs e) private void LInputColorPanel_Click(object sender, EventArgs e)
{ {
if (LInputColorDialog.ShowDialog() == DialogResult.OK) if (LInputColorDialog.ShowDialog().IsOk())
{ {
SetColorBox(); SetColorBox();
} }
@ -610,20 +518,10 @@ namespace BizHawk.Client.EmuHawk
private void MovieInputColor_Click(object sender, EventArgs e) private void MovieInputColor_Click(object sender, EventArgs e)
{ {
if (MovieInputColorDialog.ShowDialog() == DialogResult.OK) if (MovieInputColorDialog.ShowDialog().IsOk())
{ {
SetColorBox(); SetColorBox();
} }
} }
private void XNumeric_KeyUp(object sender, KeyEventArgs e)
{
XNumericChange();
}
private void YNumeric_KeyUp(object sender, KeyEventArgs e)
{
YNumericChange();
}
} }
} }

View File

@ -5,7 +5,6 @@ using System.Windows.Forms;
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.Nintendo.NES; using BizHawk.Emulation.Cores.Nintendo.NES;
using BizHawk.Emulation.Cores.Nintendo.SubNESHawk;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
@ -16,14 +15,17 @@ namespace BizHawk.Client.EmuHawk
// Hotkeys for BG & Sprite display toggle // Hotkeys for BG & Sprite display toggle
// NTSC filter settings? Hue, Tint (This should probably be a client thing, not a nes specific thing?) // NTSC filter settings? Hue, Tint (This should probably be a client thing, not a nes specific thing?)
private readonly MainForm _mainForm; private readonly MainForm _mainForm;
private readonly Config _config;
private NES.NESSettings _settings; private NES.NESSettings _settings;
//private Bitmap _bmp; //private Bitmap _bmp;
public NESGraphicsConfig( public NESGraphicsConfig(
MainForm mainForm, MainForm mainForm,
Config config,
NES.NESSettings settings) NES.NESSettings settings)
{ {
_mainForm = mainForm; _mainForm = mainForm;
_config = config;
_settings = settings; _settings = settings;
InitializeComponent(); InitializeComponent();
} }
@ -52,11 +54,11 @@ namespace BizHawk.Client.EmuHawk
private void BrowsePalette_Click(object sender, EventArgs e) private void BrowsePalette_Click(object sender, EventArgs e)
{ {
using var ofd = new OpenFileDialog using var ofd = new OpenFileDialog
{ {
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["NES", "Palettes"].Path, "NES"), InitialDirectory = PathManager.MakeAbsolutePath(_config.PathEntries["NES", "Palettes"].Path, "NES"),
Filter = "Palette Files (.pal)|*.PAL|All Files (*.*)|*.*", Filter = "Palette Files (.pal)|*.PAL|All Files (*.*)|*.*",
RestoreDirectory = true RestoreDirectory = true
}; };
var result = ofd.ShowDialog(); var result = ofd.ShowDialog();
if (result != DialogResult.OK) if (result != DialogResult.OK)
@ -71,7 +73,7 @@ namespace BizHawk.Client.EmuHawk
private void SetPaletteImage() private void SetPaletteImage()
{ {
var pal = ResolvePalette(false); var pal = ResolvePalette();
int w = pictureBoxPalette.Size.Width; int w = pictureBoxPalette.Size.Width;
int h = pictureBoxPalette.Size.Height; int h = pictureBoxPalette.Size.Height;
@ -83,8 +85,8 @@ namespace BizHawk.Client.EmuHawk
for (int i = 0; i < w; i++) for (int i = 0; i < w; i++)
{ {
int cx = i * 16 / w; int cx = i * 16 / w;
int cindex = (cy * 16) + cx; int cIndex = (cy * 16) + cx;
Color col = Color.FromArgb(0xff, pal[cindex, 0], pal[cindex, 1], pal[cindex, 2]); Color col = Color.FromArgb(0xff, pal[cIndex, 0], pal[cIndex, 1], pal[cIndex, 2]);
bmp.SetPixel(i, j, col); bmp.SetPixel(i, j, col);
} }
} }
@ -92,7 +94,7 @@ namespace BizHawk.Client.EmuHawk
pictureBoxPalette.Image = bmp; pictureBoxPalette.Image = bmp;
} }
private byte[,] ResolvePalette(bool showmsg = false) private byte[,] ResolvePalette(bool showMsg = false)
{ {
if (AutoLoadPalette.Checked) // checkbox checked: try to load palette from file if (AutoLoadPalette.Checked) // checkbox checked: try to load palette from file
{ {
@ -103,9 +105,9 @@ namespace BizHawk.Client.EmuHawk
if (palette.Exists) if (palette.Exists)
{ {
var data = Palettes.Load_FCEUX_Palette(HawkFile.ReadAllBytes(palette.Name)); var data = Palettes.Load_FCEUX_Palette(HawkFile.ReadAllBytes(palette.Name));
if (showmsg) if (showMsg)
{ {
GlobalWin.OSD.AddMessage($"Palette file loaded: {palette.Name}"); _mainForm.AddOnScreenMessage($"Palette file loaded: {palette.Name}");
} }
return data; return data;
@ -115,9 +117,9 @@ namespace BizHawk.Client.EmuHawk
} }
// no filename: interpret this as "reset to default" // no filename: interpret this as "reset to default"
if (showmsg) if (showMsg)
{ {
GlobalWin.OSD.AddMessage("Standard Palette set"); _mainForm.AddOnScreenMessage("Standard Palette set");
} }
return (byte[,])Palettes.QuickNESPalette.Clone(); return (byte[,])Palettes.QuickNESPalette.Clone();

View File

@ -97,11 +97,11 @@ namespace BizHawk.Client.EmuHawk
var tabPages = new List<TabPage>(systems.Count); var tabPages = new List<TabPage>(systems.Count);
int x = UIHelper.ScaleX(6); int x = UIHelper.ScaleX(6);
int textboxWidth = UIHelper.ScaleX(70); int textBoxWidth = UIHelper.ScaleX(70);
int padding = UIHelper.ScaleX(5); int padding = UIHelper.ScaleX(5);
int buttonWidth = UIHelper.ScaleX(26); int buttonWidth = UIHelper.ScaleX(26);
int buttonHeight = UIHelper.ScaleY(23); int buttonHeight = UIHelper.ScaleY(23);
int buttonOffsetY = -1; // To align the top with the textbox I guess? Always 1 pixel regardless of scaling. int buttonOffsetY = -1; // To align the top with the TextBox I guess? Always 1 pixel regardless of scaling.
int widgetOffset = UIHelper.ScaleX(85); int widgetOffset = UIHelper.ScaleX(85);
int rowHeight = UIHelper.ScaleY(30); int rowHeight = UIHelper.ScaleY(30);
@ -127,7 +127,7 @@ namespace BizHawk.Client.EmuHawk
{ {
Text = path.Path, Text = path.Path,
Location = new Point(x, y), Location = new Point(x, y),
Width = textboxWidth, Width = textBoxWidth,
Name = path.Type, Name = path.Type,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right, Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
MinimumSize = new Size(UIHelper.ScaleX(26), UIHelper.ScaleY(23)), MinimumSize = new Size(UIHelper.ScaleX(26), UIHelper.ScaleY(23)),
@ -200,12 +200,6 @@ namespace BizHawk.Client.EmuHawk
y += rowHeight; y += rowHeight;
} }
var sys = systemDisplayName;
if (systemDisplayName == "PCE") // Hack
{
sys = "PCECD";
}
tabPages.Add(t); tabPages.Add(t);
} }

View File

@ -76,14 +76,11 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.Sound = new Sound(GlobalWin.MainForm.Handle); GlobalWin.Sound = new Sound(GlobalWin.MainForm.Handle);
} }
GlobalWin.Sound.StartSound();
GlobalWin.OSD.AddMessage("Sound settings saved");
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
} }
private void Cancel_Click(object sender, EventArgs e) private void Cancel_Click(object sender, EventArgs e)
{ {
GlobalWin.OSD.AddMessage("Sound config aborted");
Close(); Close();
} }

View File

@ -481,7 +481,7 @@ namespace BizHawk.Client.EmuHawk
{ {
var file = OpenFileDialog( var file = OpenFileDialog(
CurrentFileName, CurrentFileName,
PathManager.MakeAbsolutePath(Global.Config.PathEntries.ToolsPathFragment, null), PathManager.MakeAbsolutePath(Config.PathEntries.ToolsPathFragment, null),
"Bot files", "Bot files",
"bot" "bot"
); );
@ -504,7 +504,7 @@ namespace BizHawk.Client.EmuHawk
{ {
var file = SaveFileDialog( var file = SaveFileDialog(
CurrentFileName, CurrentFileName,
PathManager.MakeAbsolutePath(Global.Config.PathEntries.ToolsPathFragment, null), PathManager.MakeAbsolutePath(Config.PathEntries.ToolsPathFragment, null),
"Bot files", "Bot files",
"bot" "bot"
); );
@ -1099,7 +1099,7 @@ namespace BizHawk.Client.EmuHawk
GoalGroupBox.Enabled = false; GoalGroupBox.Enabled = false;
_currentBotAttempt = new BotAttempt { Attempt = Attempts }; _currentBotAttempt = new BotAttempt { Attempt = Attempts };
if (Global.MovieSession.Movie.IsRecording) if (Global.MovieSession.Movie.IsRecording())
{ {
_oldCountingSetting = Global.MovieSession.Movie.IsCountingRerecords; _oldCountingSetting = Global.MovieSession.Movie.IsCountingRerecords;
Global.MovieSession.Movie.IsCountingRerecords = false; Global.MovieSession.Movie.IsCountingRerecords = false;
@ -1156,7 +1156,7 @@ namespace BizHawk.Client.EmuHawk
_currentBotAttempt = null; _currentBotAttempt = null;
GoalGroupBox.Enabled = true; GoalGroupBox.Enabled = true;
if (Global.MovieSession.Movie.IsRecording) if (Global.MovieSession.Movie.IsRecording())
{ {
Global.MovieSession.Movie.IsCountingRerecords = _oldCountingSetting; Global.MovieSession.Movie.IsCountingRerecords = _oldCountingSetting;
} }

View File

@ -1,14 +1,11 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Client.EmuHawk.ToolExtensions; using BizHawk.Client.EmuHawk.ToolExtensions;
using BizHawk.Common;
//TODO - select which memorydomains go out to the CDL file. will this cause a problem when re-importing it? //TODO - select which memorydomains go out to the CDL file. will this cause a problem when re-importing it?
//perhaps missing domains shouldnt fail a check //perhaps missing domains shouldnt fail a check
@ -27,20 +24,16 @@ namespace BizHawk.Client.EmuHawk
[ConfigPersist] [ConfigPersist]
private RecentFiles _recent private RecentFiles _recent
{ {
get get => _recent_fld;
{ return _recent_fld; } set => _recent_fld = value;
set
{
_recent_fld = value;
}
} }
void SetCurrentFilename(string fname) void SetCurrentFilename(string fname)
{ {
_currentFilename = fname; _currentFilename = fname;
if (_currentFilename == null) Text = _currentFilename == null
Text = "Code Data Logger"; ? "Code Data Logger"
else Text = $"Code Data Logger - {fname}"; : $"Code Data Logger - {fname}";
} }
[RequiredService] [RequiredService]
@ -194,12 +187,12 @@ namespace BizHawk.Client.EmuHawk
public bool AskSaveChanges() public bool AskSaveChanges()
{ {
//nothing to fear: // nothing to fear:
if (_cdl == null) if (_cdl == null)
return true; return true;
//try auto-saving if appropriate // try auto-saving if appropriate
if (Global.Config.CDLAutoSave) if (Config.CDLAutoSave)
{ {
if (_currentFilename != null) if (_currentFilename != null)
{ {
@ -209,7 +202,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
//TODO - I dont like this system. It's hard to figure out how to use it. It should be done in multiple passes. // TODO - I don't like this system. It's hard to figure out how to use it. It should be done in multiple passes.
var result = MessageBox.Show("Save changes to CDL session?", "CDL Auto Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question); var result = MessageBox.Show("Save changes to CDL session?", "CDL Auto Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.No) if (result == DialogResult.No)
{ {
@ -224,29 +217,17 @@ namespace BizHawk.Client.EmuHawk
ShutdownCDL(); ShutdownCDL();
return true; return true;
} }
else
{
ShutdownCDL();
return false;
}
}
else
{
RunSave();
ShutdownCDL(); ShutdownCDL();
return true; return false;
} }
RunSave();
ShutdownCDL();
return true;
} }
public bool UpdateBefore public bool UpdateBefore => false;
{
get { return false; }
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
}
bool autoloading = false; bool autoloading = false;
public void LoadFile(string path) public void LoadFile(string path)
@ -269,7 +250,7 @@ namespace BizHawk.Client.EmuHawk
//ok, it's all good: //ok, it's all good:
_cdl = newCDL; _cdl = newCDL;
CodeDataLogger.SetCDL(null); CodeDataLogger.SetCDL(null);
if (tsbLoggingActive.Checked || Global.Config.CDLAutoStart) if (tsbLoggingActive.Checked || Config.CDLAutoStart)
{ {
tsbLoggingActive.Checked = true; tsbLoggingActive.Checked = true;
CodeDataLogger.SetCDL(_cdl); CodeDataLogger.SetCDL(_cdl);
@ -290,9 +271,9 @@ namespace BizHawk.Client.EmuHawk
DisassembleMenuItem.Enabled = DisassembleMenuItem.Enabled =
_cdl != null; _cdl != null;
miAutoSave.Checked = Global.Config.CDLAutoSave; miAutoSave.Checked = Config.CDLAutoSave;
miAutoStart.Checked = Global.Config.CDLAutoStart; miAutoStart.Checked = Config.CDLAutoStart;
miAutoResume.Checked = Global.Config.CDLAutoResume; miAutoResume.Checked = Config.CDLAutoResume;
} }
private void RecentSubMenu_DropDownOpened(object sender, EventArgs e) private void RecentSubMenu_DropDownOpened(object sender, EventArgs e)
@ -306,7 +287,7 @@ namespace BizHawk.Client.EmuHawk
_cdl = new CodeDataLog(); _cdl = new CodeDataLog();
CodeDataLogger.NewCDL(_cdl); CodeDataLogger.NewCDL(_cdl);
if (tsbLoggingActive.Checked || Global.Config.CDLAutoStart) if (tsbLoggingActive.Checked || Config.CDLAutoStart)
CodeDataLogger.SetCDL(_cdl); CodeDataLogger.SetCDL(_cdl);
else CodeDataLogger.SetCDL(null); else CodeDataLogger.SetCDL(null);
@ -332,7 +313,7 @@ namespace BizHawk.Client.EmuHawk
{ {
var file = OpenFileDialog( var file = OpenFileDialog(
_currentFilename, _currentFilename,
PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPathFragment, null), PathManager.MakeAbsolutePath(Config.PathEntries.LogPathFragment, null),
"Code Data Logger Files", "Code Data Logger Files",
"cdl"); "cdl");
@ -353,10 +334,8 @@ namespace BizHawk.Client.EmuHawk
void RunSave() void RunSave()
{ {
_recent.Add(_currentFilename); _recent.Add(_currentFilename);
using (var fs = new FileStream(_currentFilename, FileMode.Create, FileAccess.Write)) using var fs = new FileStream(_currentFilename, FileMode.Create, FileAccess.Write);
{ _cdl.Save(fs);
_cdl.Save(fs);
}
} }
private void SaveMenuItem_Click(object sender, EventArgs e) private void SaveMenuItem_Click(object sender, EventArgs e)
@ -383,7 +362,7 @@ namespace BizHawk.Client.EmuHawk
{ {
var file = SaveFileDialog( var file = SaveFileDialog(
_currentFilename, _currentFilename,
PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPathFragment, null), PathManager.MakeAbsolutePath(Config.PathEntries.LogPathFragment, null),
"Code Data Logger Files", "Code Data Logger Files",
"cdl"); "cdl");
@ -410,24 +389,22 @@ namespace BizHawk.Client.EmuHawk
{ {
var file = ToolFormBase.OpenFileDialog( var file = ToolFormBase.OpenFileDialog(
_currentFilename, _currentFilename,
PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPathFragment, null), PathManager.MakeAbsolutePath(Config.PathEntries.LogPathFragment, null),
"Code Data Logger Files", "Code Data Logger Files",
"cdl"); "cdl");
if (file != null) if (file != null)
{ {
using (var fs = new FileStream(file.FullName, FileMode.Open, FileAccess.Read)) using var fs = new FileStream(file.FullName, FileMode.Open, FileAccess.Read);
var newCDL = new CodeDataLog();
newCDL.Load(fs);
if (!_cdl.Check(newCDL))
{ {
var newCDL = new CodeDataLog(); MessageBox.Show(this, "CDL file does not match emulator's current memory map!");
newCDL.Load(fs); return;
if (!_cdl.Check(newCDL))
{
MessageBox.Show(this, "CDL file does not match emulator's current memory map!");
return;
}
_cdl.LogicalOrFrom(newCDL);
UpdateDisplay(true);
} }
_cdl.LogicalOrFrom(newCDL);
UpdateDisplay(true);
} }
} }
} }
@ -461,10 +438,8 @@ namespace BizHawk.Client.EmuHawk
var result = sfd.ShowDialog(this); var result = sfd.ShowDialog(this);
if (result == DialogResult.OK) if (result == DialogResult.OK)
{ {
using (var fs = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write)) using var fs = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write);
{ CodeDataLogger.DisassembleCDL(fs, _cdl);
CodeDataLogger.DisassembleCDL(fs, _cdl);
}
} }
} }
@ -489,7 +464,7 @@ namespace BizHawk.Client.EmuHawk
protected override void OnShown(EventArgs e) protected override void OnShown(EventArgs e)
{ {
if (Global.Config.CDLAutoStart) if (Config.CDLAutoStart)
{ {
if (_cdl == null) if (_cdl == null)
NewFileLogic(); NewFileLogic();
@ -499,20 +474,18 @@ namespace BizHawk.Client.EmuHawk
protected override void OnClosed(EventArgs e) protected override void OnClosed(EventArgs e)
{ {
//deactivate logger CodeDataLogger?.SetCDL(null);
if (CodeDataLogger != null) //just in case...
CodeDataLogger.SetCDL(null);
} }
private void CDL_Load(object sender, EventArgs e) private void CDL_Load(object sender, EventArgs e)
{ {
if (Global.Config.CDLAutoResume) if (Config.CDLAutoResume)
{ {
try try
{ {
autoloading = true; autoloading = true;
var autoresume_file = $"{PathManager.FilesystemSafeName(Global.Game)}.cdl"; var autoresume_file = $"{PathManager.FilesystemSafeName(Global.Game)}.cdl";
var autoresume_dir = PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPathFragment, null); var autoresume_dir = PathManager.MakeAbsolutePath(Config.PathEntries.LogPathFragment, null);
var autoresume_path = Path.Combine(autoresume_dir, autoresume_file); var autoresume_path = Path.Combine(autoresume_dir, autoresume_file);
if (File.Exists(autoresume_path)) if (File.Exists(autoresume_path))
LoadFile(autoresume_path); LoadFile(autoresume_path);
@ -596,17 +569,17 @@ namespace BizHawk.Client.EmuHawk
private void miAutoSave_Click(object sender, EventArgs e) private void miAutoSave_Click(object sender, EventArgs e)
{ {
Global.Config.CDLAutoSave ^= true; Config.CDLAutoSave ^= true;
} }
private void miAutoStart_Click(object sender, EventArgs e) private void miAutoStart_Click(object sender, EventArgs e)
{ {
Global.Config.CDLAutoStart ^= true; Config.CDLAutoStart ^= true;
} }
private void miAutoResume_Click(object sender, EventArgs e) private void miAutoResume_Click(object sender, EventArgs e)
{ {
Global.Config.CDLAutoResume ^= true; Config.CDLAutoResume ^= true;
} }
} }
} }

View File

@ -91,11 +91,11 @@ namespace BizHawk.Client.EmuHawk
var loadResult = Global.CheatList.Load(path, append: false); var loadResult = Global.CheatList.Load(path, append: false);
if (!loadResult) if (!loadResult)
{ {
Global.Config.RecentCheats.HandleLoadError(path); Config.RecentCheats.HandleLoadError(path);
} }
else else
{ {
Global.Config.RecentCheats.Add(path); Config.RecentCheats.Add(path);
UpdateDialog(); UpdateDialog();
UpdateMessageLabel(); UpdateMessageLabel();
} }
@ -131,7 +131,7 @@ namespace BizHawk.Client.EmuHawk
Global.CheatList.Load(file.FullName, append); Global.CheatList.Load(file.FullName, append);
UpdateDialog(); UpdateDialog();
UpdateMessageLabel(); UpdateMessageLabel();
Global.Config.RecentCheats.Add(Global.CheatList.CurrentFileName); Config.RecentCheats.Add(Global.CheatList.CurrentFileName);
} }
} }
} }
@ -185,7 +185,7 @@ namespace BizHawk.Client.EmuHawk
{ {
GameGenieToolbarSeparator.Visible = GameGenieToolbarSeparator.Visible =
LoadGameGenieToolbarItem.Visible = LoadGameGenieToolbarItem.Visible =
GlobalWin.Tools.IsAvailable<GameShark>(); Tools.IsAvailable<GameShark>();
} }
private void AddCheat() private void AddCheat()
@ -352,7 +352,7 @@ namespace BizHawk.Client.EmuHawk
var result = !Global.CheatList.Changes || AskSaveChanges(); var result = !Global.CheatList.Changes || AskSaveChanges();
if (result) if (result)
{ {
Global.CheatList.NewList(ToolManager.GenerateDefaultCheatFilename()); Global.CheatList.NewList(Tools.GenerateDefaultCheatFilename());
UpdateDialog(); UpdateDialog();
UpdateMessageLabel(); UpdateMessageLabel();
ToggleGameGenieButton(); ToggleGameGenieButton();
@ -381,7 +381,7 @@ namespace BizHawk.Client.EmuHawk
{ {
RecentSubMenu.DropDownItems.Clear(); RecentSubMenu.DropDownItems.Clear();
RecentSubMenu.DropDownItems.AddRange( RecentSubMenu.DropDownItems.AddRange(
Global.Config.RecentCheats.RecentMenu(LoadFileFromRecent)); Config.RecentCheats.RecentMenu(LoadFileFromRecent));
} }
private void NewMenuItem_Click(object sender, EventArgs e) private void NewMenuItem_Click(object sender, EventArgs e)
@ -445,7 +445,7 @@ namespace BizHawk.Client.EmuHawk
GameGenieSeparator.Visible = GameGenieSeparator.Visible =
OpenGameGenieEncoderDecoderMenuItem.Visible = OpenGameGenieEncoderDecoderMenuItem.Visible =
GlobalWin.Tools.IsAvailable<GameShark>(); Tools.IsAvailable<GameShark>();
} }
private void RemoveCheatMenuItem_Click(object sender, EventArgs e) private void RemoveCheatMenuItem_Click(object sender, EventArgs e)
@ -554,7 +554,7 @@ namespace BizHawk.Client.EmuHawk
private void OpenGameGenieEncoderDecoderMenuItem_Click(object sender, EventArgs e) private void OpenGameGenieEncoderDecoderMenuItem_Click(object sender, EventArgs e)
{ {
GlobalWin.Tools.LoadGameGenieEc(); Tools.LoadGameGenieEc();
} }
#endregion #endregion
@ -563,10 +563,10 @@ namespace BizHawk.Client.EmuHawk
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e) private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
AlwaysLoadCheatsMenuItem.Checked = Global.Config.LoadCheatFileByGame; AlwaysLoadCheatsMenuItem.Checked = Config.LoadCheatFileByGame;
AutoSaveCheatsMenuItem.Checked = Global.Config.CheatsAutoSaveOnClose; AutoSaveCheatsMenuItem.Checked = Config.CheatsAutoSaveOnClose;
DisableCheatsOnLoadMenuItem.Checked = Global.Config.DisableCheatsOnLoad; DisableCheatsOnLoadMenuItem.Checked = Config.DisableCheatsOnLoad;
AutoloadMenuItem.Checked = Global.Config.RecentCheats.AutoLoad; AutoloadMenuItem.Checked = Config.RecentCheats.AutoLoad;
SaveWindowPositionMenuItem.Checked = Settings.SaveWindowPosition; SaveWindowPositionMenuItem.Checked = Settings.SaveWindowPosition;
AlwaysOnTopMenuItem.Checked = Settings.TopMost; AlwaysOnTopMenuItem.Checked = Settings.TopMost;
FloatingWindowMenuItem.Checked = Settings.FloatingWindow; FloatingWindowMenuItem.Checked = Settings.FloatingWindow;
@ -574,22 +574,22 @@ namespace BizHawk.Client.EmuHawk
private void AlwaysLoadCheatsMenuItem_Click(object sender, EventArgs e) private void AlwaysLoadCheatsMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.LoadCheatFileByGame ^= true; Config.LoadCheatFileByGame ^= true;
} }
private void AutoSaveCheatsMenuItem_Click(object sender, EventArgs e) private void AutoSaveCheatsMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.CheatsAutoSaveOnClose ^= true; Config.CheatsAutoSaveOnClose ^= true;
} }
private void CheatsOnOffLoadMenuItem_Click(object sender, EventArgs e) private void CheatsOnOffLoadMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.DisableCheatsOnLoad ^= true; Config.DisableCheatsOnLoad ^= true;
} }
private void AutoloadMenuItem_Click(object sender, EventArgs e) private void AutoloadMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.RecentCheats.AutoLoad ^= true; Config.RecentCheats.AutoLoad ^= true;
} }
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e) private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
@ -620,9 +620,9 @@ namespace BizHawk.Client.EmuHawk
CheatsMenu.Items.Add(CheatListView.ToColumnsMenu(ColumnToggleCallback)); CheatsMenu.Items.Add(CheatListView.ToColumnsMenu(ColumnToggleCallback));
Global.Config.DisableCheatsOnLoad = false; Config.DisableCheatsOnLoad = false;
Global.Config.LoadCheatFileByGame = true; Config.LoadCheatFileByGame = true;
Global.Config.CheatsAutoSaveOnClose = true; Config.CheatsAutoSaveOnClose = true;
RefreshFloatingWindowControl(Settings.FloatingWindow); RefreshFloatingWindowControl(Settings.FloatingWindow);
CheatListView.AllColumns.Clear(); CheatListView.AllColumns.Clear();
@ -700,7 +700,7 @@ namespace BizHawk.Client.EmuHawk
var selected = SelectedCheats.ToList(); var selected = SelectedCheats.ToList();
if (selected.Any()) if (selected.Any())
{ {
GlobalWin.Tools.Load<HexEditor>(); Tools.Load<HexEditor>();
if (selected.Select(x => x.Domain).Distinct().Count() > 1) if (selected.Select(x => x.Domain).Distinct().Count() > 1)
{ {

View File

@ -169,9 +169,9 @@ namespace BizHawk.Client.EmuHawk
_maxRow = _domain.Size / 2; _maxRow = _domain.Size / 2;
// Don't reset scroll bar if restarting the same rom // Don't reset scroll bar if restarting the same rom
if (_lastRom != GlobalWin.MainForm.CurrentlyOpenRom) if (_lastRom != MainForm.CurrentlyOpenRom)
{ {
_lastRom = GlobalWin.MainForm.CurrentlyOpenRom; _lastRom = MainForm.CurrentlyOpenRom;
ResetScrollBar(); ResetScrollBar();
} }
@ -365,9 +365,9 @@ namespace BizHawk.Client.EmuHawk
return (char)val; return (char)val;
} }
private static bool CurrentRomIsArchive() private bool CurrentRomIsArchive()
{ {
var path = GlobalWin.MainForm.CurrentlyOpenRom; var path = MainForm.CurrentlyOpenRom;
if (path == null) if (path == null)
{ {
return false; return false;
@ -384,9 +384,9 @@ namespace BizHawk.Client.EmuHawk
return file.IsArchive; return file.IsArchive;
} }
private static byte[] GetRomBytes() private byte[] GetRomBytes()
{ {
var path = GlobalWin.MainForm.CurrentlyOpenRomArgs.OpenAdvanced.SimplePath; var path = MainForm.CurrentlyOpenRomArgs.OpenAdvanced.SimplePath;
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
{ {
return new byte[] { 0xFF }; return new byte[] { 0xFF };
@ -460,11 +460,11 @@ namespace BizHawk.Client.EmuHawk
private void LoadConfigSettings() private void LoadConfigSettings()
{ {
HexMenuStrip.BackColor = Global.Config.HexMenubarColor; HexMenuStrip.BackColor = Config.HexMenubarColor;
MemoryViewerBox.BackColor = Global.Config.HexBackgrndColor; MemoryViewerBox.BackColor = Config.HexBackgrndColor;
MemoryViewerBox.ForeColor = Global.Config.HexForegrndColor; MemoryViewerBox.ForeColor = Config.HexForegrndColor;
Header.BackColor = Global.Config.HexBackgrndColor; Header.BackColor = Config.HexBackgrndColor;
Header.ForeColor = Global.Config.HexForegrndColor; Header.ForeColor = Config.HexForegrndColor;
} }
private void CloseHexFind() private void CloseHexFind()
@ -842,7 +842,7 @@ namespace BizHawk.Client.EmuHawk
{ {
get get
{ {
string path = Global.Config.RecentRoms.MostRecent; string path = Config.RecentRoms.MostRecent;
if (string.IsNullOrWhiteSpace(path)) if (string.IsNullOrWhiteSpace(path))
{ {
@ -862,7 +862,7 @@ namespace BizHawk.Client.EmuHawk
{ {
get get
{ {
string path = Global.Config.RecentRoms.MostRecent; string path = Config.RecentRoms.MostRecent;
if (string.IsNullOrWhiteSpace(path)) if (string.IsNullOrWhiteSpace(path))
{ {
@ -1213,7 +1213,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (!CurrentRomIsArchive()) if (!CurrentRomIsArchive())
{ {
SaveFileBinary(GlobalWin.MainForm.CurrentlyOpenRom); SaveFileBinary(MainForm.CurrentlyOpenRom);
} }
} }
@ -1281,10 +1281,10 @@ namespace BizHawk.Client.EmuHawk
private void LoadTableFileMenuItem_Click(object sender, EventArgs e) private void LoadTableFileMenuItem_Click(object sender, EventArgs e)
{ {
string initialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.ToolsPathFragment, null); string initialDirectory = PathManager.MakeAbsolutePath(Config.PathEntries.ToolsPathFragment, null);
var romName = Global.Config.RecentRoms.MostRecent.Contains('|') var romName = Config.RecentRoms.MostRecent.Contains('|')
? Global.Config.RecentRoms.MostRecent.Split('|').Last() ? Config.RecentRoms.MostRecent.Split('|').Last()
: Global.Config.RecentRoms.MostRecent; : Config.RecentRoms.MostRecent;
using var ofd = new OpenFileDialog using var ofd = new OpenFileDialog
{ {
@ -1587,16 +1587,16 @@ namespace BizHawk.Client.EmuHawk
{ {
if (_highlightedAddress.HasValue || _secondaryHighlightedAddresses.Any()) if (_highlightedAddress.HasValue || _secondaryHighlightedAddresses.Any())
{ {
GlobalWin.Tools.LoadRamWatch(true); Tools.LoadRamWatch(true);
} }
if (_highlightedAddress.HasValue) if (_highlightedAddress.HasValue)
{ {
GlobalWin.Tools.RamWatch.AddWatch(MakeWatch(_highlightedAddress.Value)); Tools.RamWatch.AddWatch(MakeWatch(_highlightedAddress.Value));
} }
_secondaryHighlightedAddresses.ForEach(addr => _secondaryHighlightedAddresses.ForEach(addr =>
GlobalWin.Tools.RamWatch.AddWatch(MakeWatch(addr))); Tools.RamWatch.AddWatch(MakeWatch(addr)));
} }
private void FreezeAddressMenuItem_Click(object sender, EventArgs e) private void FreezeAddressMenuItem_Click(object sender, EventArgs e)
@ -1684,15 +1684,15 @@ namespace BizHawk.Client.EmuHawk
{ {
MemoryViewerBox.BackColor = Color.FromName("Control"); MemoryViewerBox.BackColor = Color.FromName("Control");
MemoryViewerBox.ForeColor = Color.FromName("ControlText"); MemoryViewerBox.ForeColor = Color.FromName("ControlText");
this.HexMenuStrip.BackColor = Color.FromName("Control"); HexMenuStrip.BackColor = Color.FromName("Control");
Header.BackColor = Color.FromName("Control"); Header.BackColor = Color.FromName("Control");
Header.ForeColor = Color.FromName("ControlText"); Header.ForeColor = Color.FromName("ControlText");
Global.Config.HexMenubarColor = Color.FromName("Control"); Config.HexMenubarColor = Color.FromName("Control");
Global.Config.HexForegrndColor = Color.FromName("ControlText"); Config.HexForegrndColor = Color.FromName("ControlText");
Global.Config.HexBackgrndColor = Color.FromName("Control"); Config.HexBackgrndColor = Color.FromName("Control");
Global.Config.HexFreezeColor = Color.LightBlue; Config.HexFreezeColor = Color.LightBlue;
Global.Config.HexHighlightColor = Color.Pink; Config.HexHighlightColor = Color.Pink;
Global.Config.HexHighlightFreezeColor = Color.Violet; Config.HexHighlightFreezeColor = Color.Violet;
} }
#endregion #endregion
@ -2097,7 +2097,7 @@ namespace BizHawk.Client.EmuHawk
var rect = new Rectangle(GetAddressCoordinates(cheat.Address ?? 0), new Size(width, _fontHeight)); var rect = new Rectangle(GetAddressCoordinates(cheat.Address ?? 0), new Size(width, _fontHeight));
e.Graphics.DrawRectangle(_blackPen, rect); e.Graphics.DrawRectangle(_blackPen, rect);
_freezeBrush.Color = Global.Config.HexFreezeColor; _freezeBrush.Color = Config.HexFreezeColor;
e.Graphics.FillRectangle(_freezeBrush, rect); e.Graphics.FillRectangle(_freezeBrush, rect);
} }
} }
@ -2119,13 +2119,13 @@ namespace BizHawk.Client.EmuHawk
if (Global.CheatList.IsActive(_domain, addressHighlighted)) if (Global.CheatList.IsActive(_domain, addressHighlighted))
{ {
_freezeHighlightBrush.Color = Global.Config.HexHighlightFreezeColor; _freezeHighlightBrush.Color = Config.HexHighlightFreezeColor;
e.Graphics.FillRectangle(_freezeHighlightBrush, rect); e.Graphics.FillRectangle(_freezeHighlightBrush, rect);
e.Graphics.FillRectangle(_freezeHighlightBrush, textRect); e.Graphics.FillRectangle(_freezeHighlightBrush, textRect);
} }
else else
{ {
_highlightBrush.Color = Global.Config.HexHighlightColor; _highlightBrush.Color = Config.HexHighlightColor;
e.Graphics.FillRectangle(_highlightBrush, rect); e.Graphics.FillRectangle(_highlightBrush, rect);
e.Graphics.FillRectangle(_highlightBrush, textRect); e.Graphics.FillRectangle(_highlightBrush, textRect);
} }
@ -2146,13 +2146,13 @@ namespace BizHawk.Client.EmuHawk
if (Global.CheatList.IsActive(_domain, address)) if (Global.CheatList.IsActive(_domain, address))
{ {
_freezeHighlightBrush.Color = Global.Config.HexHighlightFreezeColor; _freezeHighlightBrush.Color = Config.HexHighlightFreezeColor;
e.Graphics.FillRectangle(_freezeHighlightBrush, rect); e.Graphics.FillRectangle(_freezeHighlightBrush, rect);
e.Graphics.FillRectangle(_freezeHighlightBrush, textRect); e.Graphics.FillRectangle(_freezeHighlightBrush, textRect);
} }
else else
{ {
_secondaryHighlightBrush.Color = Color.FromArgb(0x44, Global.Config.HexHighlightColor); _secondaryHighlightBrush.Color = Color.FromArgb(0x44, Config.HexHighlightColor);
e.Graphics.FillRectangle(_secondaryHighlightBrush, rect); e.Graphics.FillRectangle(_secondaryHighlightBrush, rect);
e.Graphics.FillRectangle(_secondaryHighlightBrush, textRect); e.Graphics.FillRectangle(_secondaryHighlightBrush, textRect);
} }

View File

@ -74,13 +74,13 @@ namespace BizHawk.Client.EmuHawk
if (GlobalWin.DisplayManager.ClientExtraPadding != Padding.Empty) if (GlobalWin.DisplayManager.ClientExtraPadding != Padding.Empty)
{ {
GlobalWin.DisplayManager.ClientExtraPadding = new Padding(0); GlobalWin.DisplayManager.ClientExtraPadding = new Padding(0);
GlobalWin.MainForm.FrameBufferResized(); MainForm.FrameBufferResized();
} }
if (GlobalWin.DisplayManager.GameExtraPadding != Padding.Empty) if (GlobalWin.DisplayManager.GameExtraPadding != Padding.Empty)
{ {
GlobalWin.DisplayManager.GameExtraPadding = new Padding(0); GlobalWin.DisplayManager.GameExtraPadding = new Padding(0);
GlobalWin.MainForm.FrameBufferResized(); MainForm.FrameBufferResized();
} }
LuaImp.GuiLibrary.DrawFinish(); LuaImp.GuiLibrary.DrawFinish();
@ -131,15 +131,15 @@ namespace BizHawk.Client.EmuHawk
LuaImp.ScriptList.ChangedCallback = SessionChangedCallback; LuaImp.ScriptList.ChangedCallback = SessionChangedCallback;
LuaImp.ScriptList.LoadCallback = ClearOutputWindow; LuaImp.ScriptList.LoadCallback = ClearOutputWindow;
if (Global.Config.RecentLuaSession.AutoLoad && !Global.Config.RecentLuaSession.Empty) if (Config.RecentLuaSession.AutoLoad && !Config.RecentLuaSession.Empty)
{ {
LoadSessionFromRecent(Global.Config.RecentLuaSession.MostRecent); LoadSessionFromRecent(Config.RecentLuaSession.MostRecent);
} }
else if (Global.Config.RecentLua.AutoLoad) else if (Config.RecentLua.AutoLoad)
{ {
if (!Global.Config.RecentLua.Empty) if (!Config.RecentLua.Empty)
{ {
LoadLuaFile(Global.Config.RecentLua.MostRecent); LoadLuaFile(Config.RecentLua.MostRecent);
} }
} }
@ -234,7 +234,7 @@ namespace BizHawk.Client.EmuHawk
private void AddFileWatches() private void AddFileWatches()
{ {
if (Global.Config.LuaReloadOnScriptFileChange) if (Config.LuaReloadOnScriptFileChange)
{ {
_watches.Clear(); _watches.Clear();
foreach (var item in LuaImp.ScriptList.Where(s => !s.IsSeparator)) foreach (var item in LuaImp.ScriptList.Where(s => !s.IsSeparator))
@ -285,7 +285,7 @@ namespace BizHawk.Client.EmuHawk
foreach (var file in LuaImp.ScriptList foreach (var file in LuaImp.ScriptList
.Where(file => processedPath == file.Path .Where(file => processedPath == file.Path
&& file.Enabled == false && file.Enabled == false
&& !Global.Config.DisableLuaScriptsOnLoad)) && !Config.DisableLuaScriptsOnLoad))
{ {
if (file.Thread != null) if (file.Thread != null)
{ {
@ -303,9 +303,9 @@ namespace BizHawk.Client.EmuHawk
LuaImp.ScriptList.Add(luaFile); LuaImp.ScriptList.Add(luaFile);
LuaListView.RowCount = LuaImp.ScriptList.Count; LuaListView.RowCount = LuaImp.ScriptList.Count;
Global.Config.RecentLua.Add(processedPath); Config.RecentLua.Add(processedPath);
if (!Global.Config.DisableLuaScriptsOnLoad) if (!Config.DisableLuaScriptsOnLoad)
{ {
luaFile.State = LuaFile.RunState.Running; luaFile.State = LuaFile.RunState.Running;
EnableLuaFile(luaFile); EnableLuaFile(luaFile);
@ -315,7 +315,7 @@ namespace BizHawk.Client.EmuHawk
luaFile.State = LuaFile.RunState.Disabled; luaFile.State = LuaFile.RunState.Disabled;
} }
if (Global.Config.LuaReloadOnScriptFileChange) if (Config.LuaReloadOnScriptFileChange)
{ {
CreateFileWatcher(processedPath); CreateFileWatcher(processedPath);
} }
@ -612,7 +612,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (!LuaImp.ScriptList.LoadLuaSession(path)) if (!LuaImp.ScriptList.LoadLuaSession(path))
{ {
Global.Config.RecentLuaSession.HandleLoadError(path); Config.RecentLuaSession.HandleLoadError(path);
} }
else else
{ {
@ -682,14 +682,14 @@ namespace BizHawk.Client.EmuHawk
{ {
RecentSessionsSubMenu.DropDownItems.Clear(); RecentSessionsSubMenu.DropDownItems.Clear();
RecentSessionsSubMenu.DropDownItems.AddRange( RecentSessionsSubMenu.DropDownItems.AddRange(
Global.Config.RecentLuaSession.RecentMenu(LoadSessionFromRecent, true)); Config.RecentLuaSession.RecentMenu(LoadSessionFromRecent, true));
} }
private void RecentScriptsSubMenu_DropDownOpened(object sender, EventArgs e) private void RecentScriptsSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
RecentScriptsSubMenu.DropDownItems.Clear(); RecentScriptsSubMenu.DropDownItems.Clear();
RecentScriptsSubMenu.DropDownItems.AddRange( RecentScriptsSubMenu.DropDownItems.AddRange(
Global.Config.RecentLua.RecentMenu(LoadLuaFile, true)); Config.RecentLua.RecentMenu(LoadLuaFile, true));
} }
private void NewSessionMenuItem_Click(object sender, EventArgs e) private void NewSessionMenuItem_Click(object sender, EventArgs e)
@ -784,7 +784,7 @@ namespace BizHawk.Client.EmuHawk
{ {
InitialDirectory = !string.IsNullOrWhiteSpace(LuaImp.ScriptList.Filename) ? InitialDirectory = !string.IsNullOrWhiteSpace(LuaImp.ScriptList.Filename) ?
Path.GetDirectoryName(LuaImp.ScriptList.Filename) : Path.GetDirectoryName(LuaImp.ScriptList.Filename) :
PathManager.MakeAbsolutePath(Global.Config.PathEntries.LuaPathFragment, null), PathManager.MakeAbsolutePath(Config.PathEntries.LuaPathFragment, null),
DefaultExt = ".lua", DefaultExt = ".lua",
FileName = !string.IsNullOrWhiteSpace(LuaImp.ScriptList.Filename) ? FileName = !string.IsNullOrWhiteSpace(LuaImp.ScriptList.Filename) ?
Path.GetFileNameWithoutExtension(LuaImp.ScriptList.Filename) : Path.GetFileNameWithoutExtension(LuaImp.ScriptList.Filename) :
@ -839,7 +839,7 @@ namespace BizHawk.Client.EmuHawk
private void ToggleScriptMenuItem_Click(object sender, EventArgs e) private void ToggleScriptMenuItem_Click(object sender, EventArgs e)
{ {
var files = !SelectedFiles.Any() && Global.Config.ToggleAllIfNoneSelected var files = !SelectedFiles.Any() && Config.ToggleAllIfNoneSelected
? LuaImp.ScriptList ? LuaImp.ScriptList
: SelectedFiles; : SelectedFiles;
foreach (var file in files) foreach (var file in files)
@ -870,7 +870,7 @@ namespace BizHawk.Client.EmuHawk
// Shenanigans // Shenanigans
// We want any gui.text messages from a script to immediately update even when paused // We want any gui.text messages from a script to immediately update even when paused
GlobalWin.OSD.ClearGuiText(); GlobalWin.OSD.ClearGuiText();
GlobalWin.Tools.UpdateToolsAfter(); Tools.UpdateToolsAfter();
LuaImp.EndLuaDrawing(); LuaImp.EndLuaDrawing();
LuaImp.StartLuaDrawing(); LuaImp.StartLuaDrawing();
} }
@ -1066,26 +1066,26 @@ namespace BizHawk.Client.EmuHawk
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e) private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
DisableScriptsOnLoadMenuItem.Checked = Global.Config.DisableLuaScriptsOnLoad; DisableScriptsOnLoadMenuItem.Checked = Config.DisableLuaScriptsOnLoad;
ReturnAllIfNoneSelectedMenuItem.Checked = Global.Config.ToggleAllIfNoneSelected; ReturnAllIfNoneSelectedMenuItem.Checked = Config.ToggleAllIfNoneSelected;
ReloadWhenScriptFileChangesMenuItem.Checked = Global.Config.LuaReloadOnScriptFileChange; ReloadWhenScriptFileChangesMenuItem.Checked = Config.LuaReloadOnScriptFileChange;
} }
private void DisableScriptsOnLoadMenuItem_Click(object sender, EventArgs e) private void DisableScriptsOnLoadMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.DisableLuaScriptsOnLoad ^= true; Config.DisableLuaScriptsOnLoad ^= true;
} }
private void ToggleAllIfNoneSelectedMenuItem_Click(object sender, EventArgs e) private void ToggleAllIfNoneSelectedMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.ToggleAllIfNoneSelected ^= true; Config.ToggleAllIfNoneSelected ^= true;
} }
private void ReloadWhenScriptFileChangesMenuItem_Click(object sender, EventArgs e) private void ReloadWhenScriptFileChangesMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.LuaReloadOnScriptFileChange ^= true; Config.LuaReloadOnScriptFileChange ^= true;
if (Global.Config.LuaReloadOnScriptFileChange) if (Config.LuaReloadOnScriptFileChange)
{ {
AddFileWatches(); AddFileWatches();
} }
@ -1161,7 +1161,7 @@ namespace BizHawk.Client.EmuHawk
private void FunctionsListMenuItem_Click(object sender, EventArgs e) private void FunctionsListMenuItem_Click(object sender, EventArgs e)
{ {
new LuaFunctionsForm().Show(); new LuaFunctionsForm(LuaImp.Docs).Show();
} }
private void OnlineDocsMenuItem_Click(object sender, EventArgs e) private void OnlineDocsMenuItem_Click(object sender, EventArgs e)
@ -1185,7 +1185,7 @@ namespace BizHawk.Client.EmuHawk
LuaImp.ScriptList.Any(file => file.Enabled); LuaImp.ScriptList.Any(file => file.Enabled);
ClearRegisteredFunctionsContextItem.Enabled = ClearRegisteredFunctionsContextItem.Enabled =
GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.Any(); LuaImp.RegisteredFunctions.Any();
} }
private void ConsoleContextMenu_Opening(object sender, CancelEventArgs e) private void ConsoleContextMenu_Opening(object sender, CancelEventArgs e)
@ -1197,7 +1197,7 @@ namespace BizHawk.Client.EmuHawk
OutputBox.Text.Any(); OutputBox.Text.Any();
ClearRegisteredFunctionsLogContextItem.Enabled = ClearRegisteredFunctionsLogContextItem.Enabled =
GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.Any(); LuaImp.RegisteredFunctions.Any();
} }
private void ClearConsoleContextItem_Click(object sender, EventArgs e) private void ClearConsoleContextItem_Click(object sender, EventArgs e)
@ -1235,7 +1235,7 @@ namespace BizHawk.Client.EmuHawk
private void ClearRegisteredFunctionsContextMenuItem_Click(object sender, EventArgs e) private void ClearRegisteredFunctionsContextMenuItem_Click(object sender, EventArgs e)
{ {
GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.Clear(); LuaImp.RegisteredFunctions.Clear();
} }
#endregion #endregion

View File

@ -10,11 +10,19 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class LuaFunctionsForm : Form public partial class LuaFunctionsForm : Form
{ {
private readonly LuaDocumentation _docs;
private readonly Sorting _columnSort = new Sorting(); private readonly Sorting _columnSort = new Sorting();
private List<LibraryFunction> _functionList = new List<LibraryFunction>(); private List<LibraryFunction> _functionList = new List<LibraryFunction>();
private List<LibraryFunction> _filteredList = new List<LibraryFunction>(); private List<LibraryFunction> _filteredList = new List<LibraryFunction>();
public LuaFunctionsForm(LuaDocumentation docs)
{
_docs = docs;
InitializeComponent();
FunctionView.RetrieveVirtualItem += FunctionView_QueryItemText;
}
private void GenerateFilteredList() private void GenerateFilteredList()
{ {
if (!string.IsNullOrWhiteSpace(FilterBox.Text)) if (!string.IsNullOrWhiteSpace(FilterBox.Text))
@ -29,15 +37,9 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public LuaFunctionsForm()
{
InitializeComponent();
FunctionView.RetrieveVirtualItem += FunctionView_QueryItemText;
}
private void LuaFunctionList_Load(object sender, EventArgs e) private void LuaFunctionList_Load(object sender, EventArgs e)
{ {
_functionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs _functionList = _docs
.OrderBy(l => l.Library) .OrderBy(l => l.Library)
.ThenBy(l => l.Name) .ThenBy(l => l.Name)
.ToList(); .ToList();
@ -183,7 +185,7 @@ namespace BizHawk.Client.EmuHawk
private void ToWikiMarkupButton_Click(object sender, EventArgs e) private void ToWikiMarkupButton_Click(object sender, EventArgs e)
{ {
Clipboard.SetDataObject(GlobalWin.Tools.LuaConsole.LuaImp.Docs.ToTASVideosWikiMarkup()); Clipboard.SetDataObject(_docs.ToTASVideosWikiMarkup());
} }
} }
} }

View File

@ -102,7 +102,7 @@ namespace BizHawk.Client.EmuHawk
private void RemoveAllBtn_Click(object sender, EventArgs e) private void RemoveAllBtn_Click(object sender, EventArgs e)
{ {
GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.ClearAll(); GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.Clear();
PopulateListView(); PopulateListView();
} }

View File

@ -20,10 +20,7 @@ namespace BizHawk.Client.EmuHawk
private readonly List<int> _unsavedZones = new List<int>(); private readonly List<int> _unsavedZones = new List<int>();
private bool _selecting = false; private bool _selecting = false;
private IMovie CurrentMovie private IMovie CurrentMovie => Global.MovieSession.Movie;
{
get { return Global.MovieSession.Movie; }
}
// Still need to make sure the user can't load and use macros that // Still need to make sure the user can't load and use macros that
// have options only available for TasMovie // have options only available for TasMovie
@ -39,7 +36,7 @@ namespace BizHawk.Client.EmuHawk
{ {
// Movie recording must be active (check TAStudio because opening a project re-loads the ROM, // Movie recording must be active (check TAStudio because opening a project re-loads the ROM,
// which resets tools before the movie session becomes active) // which resets tools before the movie session becomes active)
if (!Global.MovieSession.Movie.IsActive && !GlobalWin.Tools.IsLoaded<TAStudio>()) if (!Global.MovieSession.Movie.IsActive() && !GlobalWin.Tools.IsLoaded<TAStudio>())
{ {
MessageBox.Show("In order to use this tool you must be recording a movie."); MessageBox.Show("In order to use this tool you must be recording a movie.");
Close(); Close();

View File

@ -40,7 +40,7 @@ namespace BizHawk.Client.EmuHawk
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool RecordingMode public bool RecordingMode
{ {
get => Global.MovieSession.Movie.IsRecording; get => Global.MovieSession.Movie.IsRecording();
set set
{ {
RecordingModeCheckbox.Checked = value; RecordingModeCheckbox.Checked = value;

View File

@ -1,4 +1,6 @@
namespace BizHawk.Client.EmuHawk using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{ {
public partial class TAStudio : IControlMainform public partial class TAStudio : IControlMainform
{ {
@ -60,11 +62,11 @@
public void ToggleReadOnly() public void ToggleReadOnly()
{ {
if (CurrentTasMovie.IsPlaying) if (CurrentTasMovie.IsPlaying())
{ {
TastudioRecordMode(); TastudioRecordMode();
} }
else if (CurrentTasMovie.IsRecording) else if (CurrentTasMovie.IsRecording())
{ {
TastudioPlayMode(); TastudioPlayMode();
} }
@ -90,15 +92,15 @@
public bool Rewind() public bool Rewind()
{ {
// copy pasted from TasView_MouseWheel(), just without notch logic // copy pasted from TasView_MouseWheel(), just without notch logic
if (Mainform.IsSeeking && !Mainform.EmulatorPaused) if (MainForm.IsSeeking && !MainForm.EmulatorPaused)
{ {
Mainform.PauseOnFrame--; MainForm.PauseOnFrame--;
// that's a weird condition here, but for whatever reason it works best // that's a weird condition here, but for whatever reason it works best
if (Emulator.Frame >= Mainform.PauseOnFrame) if (Emulator.Frame >= MainForm.PauseOnFrame)
{ {
Mainform.PauseEmulator(); MainForm.PauseEmulator();
Mainform.PauseOnFrame = null; MainForm.PauseOnFrame = null;
StopSeeking(); StopSeeking();
GoToPreviousFrame(); GoToPreviousFrame();
} }

View File

@ -81,19 +81,19 @@ namespace BizHawk.Client.EmuHawk
if (!fromMiddleClick) if (!fromMiddleClick)
{ {
if (Mainform.PauseOnFrame != null) if (MainForm.PauseOnFrame != null)
{ {
StopSeeking(true); // don't restore rec mode just yet, as with heavy editing checkbox updating causes lag StopSeeking(true); // don't restore rec mode just yet, as with heavy editing checkbox updating causes lag
} }
_seekStartFrame = Emulator.Frame; _seekStartFrame = Emulator.Frame;
} }
Mainform.PauseOnFrame = frame.Value; MainForm.PauseOnFrame = frame.Value;
int? diff = Mainform.PauseOnFrame - _seekStartFrame; int? diff = MainForm.PauseOnFrame - _seekStartFrame;
WasRecording = CurrentTasMovie.IsRecording || WasRecording; WasRecording = CurrentTasMovie.IsRecording() || WasRecording;
TastudioPlayMode(); // suspend rec mode until seek ends, to allow mouse editing TastudioPlayMode(); // suspend rec mode until seek ends, to allow mouse editing
Mainform.UnpauseEmulator(); MainForm.UnpauseEmulator();
if (!_seekBackgroundWorker.IsBusy && diff > TasView.VisibleRows) if (!_seekBackgroundWorker.IsBusy && diff > TasView.VisibleRows)
{ {
@ -110,10 +110,10 @@ namespace BizHawk.Client.EmuHawk
WasRecording = false; WasRecording = false;
} }
Mainform.PauseOnFrame = null; MainForm.PauseOnFrame = null;
if (_unpauseAfterSeeking) if (_unpauseAfterSeeking)
{ {
Mainform.UnpauseEmulator(); MainForm.UnpauseEmulator();
_unpauseAfterSeeking = false; _unpauseAfterSeeking = false;
} }
@ -173,7 +173,7 @@ namespace BizHawk.Client.EmuHawk
offsetY = 5; offsetY = 5;
} }
if (index == Emulator.Frame && index == Mainform.PauseOnFrame) if (index == Emulator.Frame && index == MainForm.PauseOnFrame)
{ {
bitmap = TasView.HorizontalOrientation ? bitmap = TasView.HorizontalOrientation ?
ts_v_arrow_green_blue : ts_v_arrow_green_blue :
@ -262,11 +262,11 @@ namespace BizHawk.Client.EmuHawk
{ {
TasMovieRecord record = CurrentTasMovie[index]; TasMovieRecord record = CurrentTasMovie[index];
if (Mainform.IsSeeking && Mainform.PauseOnFrame == index) if (MainForm.IsSeeking && MainForm.PauseOnFrame == index)
{ {
color = CurrentFrame_InputLog; color = CurrentFrame_InputLog;
} }
else if (!Mainform.IsSeeking && Emulator.Frame == index) else if (!MainForm.IsSeeking && Emulator.Frame == index)
{ {
color = CurrentFrame_InputLog; color = CurrentFrame_InputLog;
} }
@ -514,7 +514,7 @@ namespace BizHawk.Client.EmuHawk
if (e.Button == MouseButtons.Middle) if (e.Button == MouseButtons.Middle)
{ {
if (Mainform.EmulatorPaused) if (MainForm.EmulatorPaused)
{ {
TasMovieRecord record = CurrentTasMovie[LastPositionFrame]; TasMovieRecord record = CurrentTasMovie[LastPositionFrame];
if (!record.Lagged.HasValue && LastPositionFrame > Emulator.Frame) if (!record.Lagged.HasValue && LastPositionFrame > Emulator.Frame)
@ -523,12 +523,12 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
Mainform.UnpauseEmulator(); MainForm.UnpauseEmulator();
} }
} }
else else
{ {
Mainform.PauseEmulator(); MainForm.PauseEmulator();
} }
return; return;
@ -541,7 +541,7 @@ namespace BizHawk.Client.EmuHawk
int frame = TasView.CurrentCell.RowIndex.Value; int frame = TasView.CurrentCell.RowIndex.Value;
string buttonName = TasView.CurrentCell.Column.Name; string buttonName = TasView.CurrentCell.Column.Name;
WasRecording = CurrentTasMovie.IsRecording || WasRecording; WasRecording = CurrentTasMovie.IsRecording() || WasRecording;
if (e.Button == MouseButtons.Left) if (e.Button == MouseButtons.Left)
{ {
@ -604,7 +604,7 @@ namespace BizHawk.Client.EmuHawk
} }
else if (TasView.CurrentCell.Column.Type != ColumnType.Text) // User changed input else if (TasView.CurrentCell.Column.Type != ColumnType.Text) // User changed input
{ {
bool wasPaused = Mainform.EmulatorPaused; bool wasPaused = MainForm.EmulatorPaused;
if (ControllerType.BoolButtons.Contains(buttonName)) if (ControllerType.BoolButtons.Contains(buttonName))
{ {
@ -713,7 +713,7 @@ namespace BizHawk.Client.EmuHawk
// taseditor behavior // taseditor behavior
if (!wasPaused) if (!wasPaused)
{ {
Mainform.UnpauseEmulator(); MainForm.UnpauseEmulator();
} }
} }
} }
@ -877,15 +877,15 @@ namespace BizHawk.Client.EmuHawk
} }
// warning: tastudio rewind hotkey/button logic is copy pasted from here! // warning: tastudio rewind hotkey/button logic is copy pasted from here!
if (Mainform.IsSeeking && !Mainform.EmulatorPaused) if (MainForm.IsSeeking && !MainForm.EmulatorPaused)
{ {
Mainform.PauseOnFrame -= notch; MainForm.PauseOnFrame -= notch;
// that's a weird condition here, but for whatever reason it works best // that's a weird condition here, but for whatever reason it works best
if (notch > 0 && Emulator.Frame >= Mainform.PauseOnFrame) if (notch > 0 && Emulator.Frame >= MainForm.PauseOnFrame)
{ {
Mainform.PauseEmulator(); MainForm.PauseEmulator();
Mainform.PauseOnFrame = null; MainForm.PauseOnFrame = null;
StopSeeking(); StopSeeking();
GoToFrame(Emulator.Frame - notch); GoToFrame(Emulator.Frame - notch);
} }
@ -953,7 +953,7 @@ namespace BizHawk.Client.EmuHawk
// skip rerecord counting on drawing entirely, mouse down is enough // skip rerecord counting on drawing entirely, mouse down is enough
// avoid introducing another global // avoid introducing another global
bool wasCountingRerecords = CurrentTasMovie.IsCountingRerecords; bool wasCountingRerecords = CurrentTasMovie.IsCountingRerecords;
WasRecording = CurrentTasMovie.IsRecording || WasRecording; WasRecording = CurrentTasMovie.IsRecording() || WasRecording;
int startVal, endVal; int startVal, endVal;
int frame = e.NewCell.RowIndex.Value; int frame = e.NewCell.RowIndex.Value;
@ -976,7 +976,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
if (_startCursorDrag && !Mainform.IsSeeking) if (_startCursorDrag && !MainForm.IsSeeking)
{ {
GoToFrame(e.NewCell.RowIndex.Value); GoToFrame(e.NewCell.RowIndex.Value);
} }

View File

@ -39,7 +39,7 @@ namespace BizHawk.Client.EmuHawk
private void NewTasMenuItem_Click(object sender, EventArgs e) private void NewTasMenuItem_Click(object sender, EventArgs e)
{ {
if (!Mainform.GameIsClosing) if (!MainForm.GameIsClosing)
{ {
StartNewTasMovie(); StartNewTasMovie();
} }
@ -60,7 +60,7 @@ namespace BizHawk.Client.EmuHawk
var ofd = new OpenFileDialog var ofd = new OpenFileDialog
{ {
FileName = filename, FileName = filename,
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null), InitialDirectory = PathManager.MakeAbsolutePath(Config.PathEntries.MoviesPathFragment, null),
Filter = string.Format( Filter = string.Format(
"All Available Files ({0})|{0}|TAS Project Files (*.{1})|*.{1}|Movie Files (*.{2})|*.{2}|All Files|*.*", "All Available Files ({0})|{0}|TAS Project Files (*.{1})|*.{1}|Movie Files (*.{2})|*.{2}|All Files|*.*",
all, TasMovie.Extension, MovieService.DefaultExtension) all, TasMovie.Extension, MovieService.DefaultExtension)
@ -78,7 +78,7 @@ namespace BizHawk.Client.EmuHawk
var result1 = MessageBox.Show("This is a regular movie, a new project must be created from it, in order to use in TAStudio\nProceed?", "Convert movie", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); var result1 = MessageBox.Show("This is a regular movie, a new project must be created from it, in order to use in TAStudio\nProceed?", "Convert movie", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (result1 == DialogResult.OK) if (result1 == DialogResult.OK)
{ {
Mainform.StartNewMovie(MovieService.Get(ofd.FileName), false); MainForm.StartNewMovie(MovieService.Get(ofd.FileName), false);
ConvertCurrentMovieToTasproj(); ConvertCurrentMovieToTasproj();
StartNewMovieWrapper(false); StartNewMovieWrapper(false);
SetUpColumns(); SetUpColumns();
@ -145,7 +145,7 @@ namespace BizHawk.Client.EmuHawk
var file = SaveFileDialog( var file = SaveFileDialog(
filename, filename,
PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null), PathManager.MakeAbsolutePath(Config.PathEntries.MoviesPathFragment, null),
"Tas Project Files", "Tas Project Files",
"tasproj"); "tasproj");
@ -168,7 +168,7 @@ namespace BizHawk.Client.EmuHawk
_autosaveTimer.Start(); _autosaveTimer.Start();
} }
Mainform.SetWindowText(); MainForm.SetWindowText();
GlobalWin.Sound.StartSound(); GlobalWin.Sound.StartSound();
} }
@ -264,7 +264,7 @@ namespace BizHawk.Client.EmuHawk
private void RecentMacrosMenuItem_DropDownOpened(object sender, EventArgs e) private void RecentMacrosMenuItem_DropDownOpened(object sender, EventArgs e)
{ {
recentMacrosToolStripMenuItem.DropDownItems.Clear(); recentMacrosToolStripMenuItem.DropDownItems.Clear();
recentMacrosToolStripMenuItem.DropDownItems.AddRange(Global.Config.RecentMacros.RecentMenu(DummyLoadMacro)); recentMacrosToolStripMenuItem.DropDownItems.AddRange(Config.RecentMacros.RecentMenu(DummyLoadMacro));
} }
private void ToBk2MenuItem_Click(object sender, EventArgs e) private void ToBk2MenuItem_Click(object sender, EventArgs e)
@ -357,16 +357,16 @@ namespace BizHawk.Client.EmuHawk
StateHistoryIntegrityCheckMenuItem.Visible = StateHistoryIntegrityCheckMenuItem.Visible =
VersionInfo.DeveloperBuild; VersionInfo.DeveloperBuild;
UndoMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Undo"].Bindings; UndoMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Undo"].Bindings;
RedoMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Redo"].Bindings; RedoMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Redo"].Bindings;
SelectBetweenMarkersMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Select between Markers"].Bindings; SelectBetweenMarkersMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Select between Markers"].Bindings;
SelectAllMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Select All"].Bindings; SelectAllMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Select All"].Bindings;
ReselectClipboardMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Reselect Clip."].Bindings; ReselectClipboardMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Reselect Clip."].Bindings;
ClearFramesMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Clear Frames"].Bindings; ClearFramesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clear Frames"].Bindings;
InsertFrameMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Insert Frame"].Bindings; InsertFrameMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Insert Frame"].Bindings;
InsertNumFramesMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Insert # Frames"].Bindings; InsertNumFramesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Insert # Frames"].Bindings;
DeleteFramesMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Delete Frames"].Bindings; DeleteFramesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Delete Frames"].Bindings;
CloneFramesMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Clone Frames"].Bindings; CloneFramesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clone Frames"].Bindings;
} }
public void ClearFramesExternal() public void ClearFramesExternal()
@ -865,7 +865,7 @@ namespace BizHawk.Client.EmuHawk
int goToFrame = CurrentTasMovie.LastStatedFrame; int goToFrame = CurrentTasMovie.LastStatedFrame;
do do
{ {
Mainform.FrameAdvance(); MainForm.FrameAdvance();
if (CurrentTasMovie.TasStateManager.HasState(Emulator.Frame)) if (CurrentTasMovie.TasStateManager.HasState(Emulator.Frame))
{ {
@ -1106,7 +1106,7 @@ namespace BizHawk.Client.EmuHawk
{ {
new MovieHeaderEditor(CurrentTasMovie) new MovieHeaderEditor(CurrentTasMovie)
{ {
Owner = Mainform, Owner = Owner,
Location = this.ChildPointToScreen(TasView) Location = this.ChildPointToScreen(TasView)
}.Show(); }.Show();
UpdateChangesIndicator(); UpdateChangesIndicator();
@ -1116,9 +1116,9 @@ namespace BizHawk.Client.EmuHawk
{ {
new StateHistorySettingsForm(CurrentTasMovie.TasStateManager.Settings) new StateHistorySettingsForm(CurrentTasMovie.TasStateManager.Settings)
{ {
Owner = Mainform, Owner = Owner,
Location = this.ChildPointToScreen(TasView), Location = this.ChildPointToScreen(TasView),
Statable = this.StatableEmulator Statable = StatableEmulator
}.ShowDialog(); }.ShowDialog();
CurrentTasMovie.TasStateManager.UpdateStateFrequency(); CurrentTasMovie.TasStateManager.UpdateStateFrequency();
UpdateChangesIndicator(); UpdateChangesIndicator();
@ -1488,20 +1488,20 @@ namespace BizHawk.Client.EmuHawk
StartFromNowSeparator.Visible = StartNewProjectFromNowMenuItem.Visible || StartANewProjectFromSaveRamMenuItem.Visible; StartFromNowSeparator.Visible = StartNewProjectFromNowMenuItem.Visible || StartANewProjectFromSaveRamMenuItem.Visible;
RemoveMarkersContextMenuItem.Enabled = CurrentTasMovie.Markers.Any(m => TasView.SelectedRows.Contains(m.Frame)); // Disable the option to remove markers if no markers are selected (FCEUX does this). RemoveMarkersContextMenuItem.Enabled = CurrentTasMovie.Markers.Any(m => TasView.SelectedRows.Contains(m.Frame)); // Disable the option to remove markers if no markers are selected (FCEUX does this).
CancelSeekContextMenuItem.Enabled = Mainform.PauseOnFrame.HasValue; CancelSeekContextMenuItem.Enabled = MainForm.PauseOnFrame.HasValue;
BranchContextMenuItem.Visible = TasView.CurrentCell?.RowIndex == Emulator.Frame; BranchContextMenuItem.Visible = TasView.CurrentCell?.RowIndex == Emulator.Frame;
SelectBetweenMarkersContextMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Sel. bet. Markers"].Bindings; SelectBetweenMarkersContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Sel. bet. Markers"].Bindings;
InsertNumFramesContextMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Insert # Frames"].Bindings; InsertNumFramesContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Insert # Frames"].Bindings;
ClearContextMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Clear Frames"].Bindings; ClearContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clear Frames"].Bindings;
InsertFrameContextMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Insert Frame"].Bindings; InsertFrameContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Insert Frame"].Bindings;
DeleteFramesContextMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Delete Frames"].Bindings; DeleteFramesContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Delete Frames"].Bindings;
CloneContextMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Clone Frames"].Bindings; CloneContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clone Frames"].Bindings;
} }
private void CancelSeekContextMenuItem_Click(object sender, EventArgs e) private void CancelSeekContextMenuItem_Click(object sender, EventArgs e)
{ {
Mainform.PauseOnFrame = null; MainForm.PauseOnFrame = null;
RefreshTasView(); RefreshTasView();
} }
@ -1519,7 +1519,7 @@ namespace BizHawk.Client.EmuHawk
TasMovie newProject = CurrentTasMovie.ConvertToSavestateAnchoredMovie( TasMovie newProject = CurrentTasMovie.ConvertToSavestateAnchoredMovie(
index, (byte[])StatableEmulator.SaveStateBinary().Clone()); index, (byte[])StatableEmulator.SaveStateBinary().Clone());
Mainform.PauseEmulator(); MainForm.PauseEmulator();
LoadFile(new FileInfo(newProject.Filename), true); LoadFile(new FileInfo(newProject.Filename), true);
} }
} }
@ -1539,7 +1539,7 @@ namespace BizHawk.Client.EmuHawk
GoToFrame(index); GoToFrame(index);
TasMovie newProject = CurrentTasMovie.ConvertToSaveRamAnchoredMovie( TasMovie newProject = CurrentTasMovie.ConvertToSaveRamAnchoredMovie(
SaveRamEmulator.CloneSaveRam()); SaveRamEmulator.CloneSaveRam());
Mainform.PauseEmulator(); MainForm.PauseEmulator();
LoadFile(new FileInfo(newProject.Filename), true); LoadFile(new FileInfo(newProject.Filename), true);
} }
else else

View File

@ -1,4 +1,6 @@
namespace BizHawk.Client.EmuHawk using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{ {
public partial class TAStudio public partial class TAStudio
{ {
@ -11,7 +13,7 @@
{ {
if (frame <= Emulator.Frame) if (frame <= Emulator.Frame)
{ {
if ((Mainform.EmulatorPaused || !Mainform.IsSeeking) if ((MainForm.EmulatorPaused || !MainForm.IsSeeking)
&& !CurrentTasMovie.LastPositionStable) && !CurrentTasMovie.LastPositionStable)
{ {
LastPositionFrame = Emulator.Frame; LastPositionFrame = Emulator.Frame;
@ -27,7 +29,7 @@
{ {
// If seeking to a frame before or at the end of the movie, use StartAtNearestFrameAndEmulate // If seeking to a frame before or at the end of the movie, use StartAtNearestFrameAndEmulate
// Otherwise, load the latest state (if not already there) and seek while recording. // Otherwise, load the latest state (if not already there) and seek while recording.
WasRecording = CurrentTasMovie.IsRecording || WasRecording; WasRecording = CurrentTasMovie.IsRecording() || WasRecording;
if (frame <= CurrentTasMovie.InputLogLength) if (frame <= CurrentTasMovie.InputLogLength)
{ {
@ -40,11 +42,11 @@
{ {
if (frame == Emulator.Frame + 1) // We are at the end of the movie and advancing one frame, therefore we are recording, simply emulate a frame if (frame == Emulator.Frame + 1) // We are at the end of the movie and advancing one frame, therefore we are recording, simply emulate a frame
{ {
bool wasPaused = Mainform.EmulatorPaused; bool wasPaused = MainForm.EmulatorPaused;
Mainform.FrameAdvance(); MainForm.FrameAdvance();
if (!wasPaused) if (!wasPaused)
{ {
Mainform.UnpauseEmulator(); MainForm.UnpauseEmulator();
} }
} }
else else

View File

@ -21,10 +21,9 @@ namespace BizHawk.Client.EmuHawk
{ {
// TODO: UI flow that conveniently allows to start from savestate // TODO: UI flow that conveniently allows to start from savestate
public TasMovie CurrentTasMovie => Global.MovieSession.Movie as TasMovie; public TasMovie CurrentTasMovie => Global.MovieSession.Movie as TasMovie;
private MainForm Mainform => GlobalWin.MainForm;
public bool IsInMenuLoop { get; private set; } public bool IsInMenuLoop { get; private set; }
public string StatesPath => PathManager.MakeAbsolutePath(Global.Config.PathEntries["Global", "TAStudio states"].Path, null); public string StatesPath => PathManager.MakeAbsolutePath(Config.PathEntries["Global", "TAStudio states"].Path, null);
private readonly List<TasClipboardEntry> _tasClipboard = new List<TasClipboardEntry>(); private readonly List<TasClipboardEntry> _tasClipboard = new List<TasClipboardEntry>();
private const string CursorColumnName = "CursorColumn"; private const string CursorColumnName = "CursorColumn";
@ -212,14 +211,14 @@ namespace BizHawk.Client.EmuHawk
this.Invoke(() => SavingProgressBar.Visible = true); this.Invoke(() => SavingProgressBar.Visible = true);
for (;;) for (;;)
{ {
if (_seekBackgroundWorker.CancellationPending || !IsHandleCreated || !Mainform.PauseOnFrame.HasValue) if (_seekBackgroundWorker.CancellationPending || !IsHandleCreated || !MainForm.PauseOnFrame.HasValue)
{ {
e.Cancel = true; e.Cancel = true;
break; break;
} }
int diff = Emulator.Frame - _seekStartFrame.Value; int diff = Emulator.Frame - _seekStartFrame.Value;
int unit = Mainform.PauseOnFrame.Value - _seekStartFrame.Value; int unit = MainForm.PauseOnFrame.Value - _seekStartFrame.Value;
double progress = 0; double progress = 0;
if (diff != 0 && unit != 0) if (diff != 0 && unit != 0)
@ -323,8 +322,8 @@ namespace BizHawk.Client.EmuHawk
private bool InitializeOnLoad() private bool InitializeOnLoad()
{ {
Mainform.PauseOnFrame = null; MainForm.PauseOnFrame = null;
Mainform.PauseEmulator(); MainForm.PauseEmulator();
// Start Scenario 0: core needs a nag // Start Scenario 0: core needs a nag
// But do not nag if auto-loading // But do not nag if auto-loading
@ -334,7 +333,7 @@ namespace BizHawk.Client.EmuHawk
} }
// Start Scenario 1: A regular movie is active // Start Scenario 1: A regular movie is active
if (Global.MovieSession.Movie.IsActive && !(Global.MovieSession.Movie is TasMovie)) if (Global.MovieSession.Movie.IsActive() && !(Global.MovieSession.Movie is TasMovie))
{ {
var result = MessageBox.Show("In order to use Tastudio, a new project must be created from the current movie\nThe current movie will be saved and closed, and a new project file will be created\nProceed?", "Convert movie", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); var result = MessageBox.Show("In order to use Tastudio, a new project must be created from the current movie\nThe current movie will be saved and closed, and a new project file will be created\nProceed?", "Convert movie", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (result == DialogResult.OK) if (result == DialogResult.OK)
@ -350,7 +349,7 @@ namespace BizHawk.Client.EmuHawk
} }
// Start Scenario 2: A tasproj is already active // Start Scenario 2: A tasproj is already active
else if (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie is TasMovie) else if (Global.MovieSession.Movie.IsActive() && Global.MovieSession.Movie is TasMovie)
{ {
bool result = LoadFile(new FileInfo(CurrentTasMovie.Filename), gotoFrame: Emulator.Frame); bool result = LoadFile(new FileInfo(CurrentTasMovie.Filename), gotoFrame: Emulator.Frame);
if (!result) if (!result)
@ -489,7 +488,7 @@ namespace BizHawk.Client.EmuHawk
BoolPatterns[BoolPatterns.Length - 2] = new AutoPatternBool(1, 0); BoolPatterns[BoolPatterns.Length - 2] = new AutoPatternBool(1, 0);
BoolPatterns[BoolPatterns.Length - 1] = new AutoPatternBool( BoolPatterns[BoolPatterns.Length - 1] = new AutoPatternBool(
Global.Config.AutofireOn, Global.Config.AutofireOff); Config.AutofireOn, Config.AutofireOff);
for (int i = fStart; i < FloatPatterns.Length - 2; i++) for (int i = fStart; i < FloatPatterns.Length - 2; i++)
{ {
@ -498,7 +497,7 @@ namespace BizHawk.Client.EmuHawk
FloatPatterns[FloatPatterns.Length - 2] = new AutoPatternFloat(new[] { 1f }); FloatPatterns[FloatPatterns.Length - 2] = new AutoPatternFloat(new[] { 1f });
FloatPatterns[FloatPatterns.Length - 1] = new AutoPatternFloat( FloatPatterns[FloatPatterns.Length - 1] = new AutoPatternFloat(
1f, Global.Config.AutofireOn, 0f, Global.Config.AutofireOff); 1f, Config.AutofireOn, 0f, Config.AutofireOff);
SetUpToolStripColumns(); SetUpToolStripColumns();
} }
@ -523,14 +522,14 @@ namespace BizHawk.Client.EmuHawk
private void EngageTastudio() private void EngageTastudio()
{ {
GlobalWin.OSD.AddMessage("TAStudio engaged"); MainForm.AddOnScreenMessage("TAStudio engaged");
SetTasMovieCallbacks(); SetTasMovieCallbacks();
SetTextProperty(); SetTextProperty();
Mainform.RelinquishControl(this); MainForm.RelinquishControl(this);
_originalEndAction = Global.Config.MovieEndAction; _originalEndAction = Config.MovieEndAction;
Mainform.ClearRewindData(); MainForm.ClearRewindData();
Global.Config.MovieEndAction = MovieEndAction.Record; Config.MovieEndAction = MovieEndAction.Record;
Mainform.SetMainformMovieInfo(); MainForm.SetMainformMovieInfo();
Global.MovieSession.ReadOnly = true; Global.MovieSession.ReadOnly = true;
SetSplicer(); SetSplicer();
} }
@ -681,7 +680,7 @@ namespace BizHawk.Client.EmuHawk
SetTasMovieCallbacks(movie as TasMovie); SetTasMovieCallbacks(movie as TasMovie);
bool result = Mainform.StartNewMovie(movie, record); bool result = MainForm.StartNewMovie(movie, record);
if (result) if (result)
{ {
CurrentTasMovie.TasStateManager.Capture(); // Capture frame 0 always. CurrentTasMovie.TasStateManager.Capture(); // Capture frame 0 always.
@ -744,17 +743,17 @@ namespace BizHawk.Client.EmuHawk
private void TastudioStopMovie() private void TastudioStopMovie()
{ {
Global.MovieSession.StopMovie(false); Global.MovieSession.StopMovie(false);
Mainform.SetMainformMovieInfo(); MainForm.SetMainformMovieInfo();
} }
private void DisengageTastudio() private void DisengageTastudio()
{ {
Mainform.PauseOnFrame = null; MainForm.PauseOnFrame = null;
GlobalWin.OSD.AddMessage("TAStudio disengaged"); MainForm.AddOnScreenMessage("TAStudio disengaged");
Global.MovieSession.Movie = MovieService.DefaultInstance; Global.MovieSession.Movie = MovieService.DefaultInstance;
Mainform.TakeBackControl(); MainForm.TakeBackControl();
Global.Config.MovieEndAction = _originalEndAction; Config.MovieEndAction = _originalEndAction;
Mainform.SetMainformMovieInfo(); MainForm.SetMainformMovieInfo();
// Do not keep TAStudio's disk save states. // Do not keep TAStudio's disk save states.
// if (Directory.Exists(statesPath)) Directory.Delete(statesPath, true); // if (Directory.Exists(statesPath)) Directory.Delete(statesPath, true);
@ -849,7 +848,7 @@ namespace BizHawk.Client.EmuHawk
if (_autoRestorePaused.HasValue && !_autoRestorePaused.Value) if (_autoRestorePaused.HasValue && !_autoRestorePaused.Value)
{ {
// this happens when we're holding the left button while unpaused - view scrolls down, new input gets drawn, seek pauses // this happens when we're holding the left button while unpaused - view scrolls down, new input gets drawn, seek pauses
Mainform.UnpauseEmulator(); MainForm.UnpauseEmulator();
} }
_autoRestorePaused = null; _autoRestorePaused = null;
@ -863,7 +862,7 @@ namespace BizHawk.Client.EmuHawk
return; return;
} }
_unpauseAfterSeeking = (fromRewinding || WasRecording) && !Mainform.EmulatorPaused; _unpauseAfterSeeking = (fromRewinding || WasRecording) && !MainForm.EmulatorPaused;
TastudioPlayMode(); TastudioPlayMode();
var closestState = CurrentTasMovie.TasStateManager.GetStateClosestToFrame(frame); var closestState = CurrentTasMovie.TasStateManager.GetStateClosestToFrame(frame);
if (closestState.Value.Length > 0 && (frame < Emulator.Frame || closestState.Key > Emulator.Frame)) if (closestState.Value.Length > 0 && (frame < Emulator.Frame || closestState.Key > Emulator.Frame))
@ -873,24 +872,24 @@ namespace BizHawk.Client.EmuHawk
if (fromLua) if (fromLua)
{ {
bool wasPaused = Mainform.EmulatorPaused; bool wasPaused = MainForm.EmulatorPaused;
// why not use this? because I'm not letting the form freely run. it all has to be under this loop. // why not use this? because I'm not letting the form freely run. it all has to be under this loop.
// i could use this and then poll StepRunLoop_Core() repeatedly, but.. that's basically what I'm doing // i could use this and then poll StepRunLoop_Core() repeatedly, but.. that's basically what I'm doing
// PauseOnFrame = frame; // PauseOnFrame = frame;
// can't re-enter lua while doing this // can't re-enter lua while doing this
Mainform.SuppressLua = true; MainForm.SuppressLua = true;
while (Emulator.Frame != frame) while (Emulator.Frame != frame)
{ {
Mainform.SeekFrameAdvance(); MainForm.SeekFrameAdvance();
} }
Mainform.SuppressLua = false; MainForm.SuppressLua = false;
if (!wasPaused) if (!wasPaused)
{ {
Mainform.UnpauseEmulator(); MainForm.UnpauseEmulator();
} }
// lua botting users will want to re-activate record mode automatically -- it should be like nothing ever happened // lua botting users will want to re-activate record mode automatically -- it should be like nothing ever happened
@ -906,7 +905,7 @@ namespace BizHawk.Client.EmuHawk
if (frame > Emulator.Frame) if (frame > Emulator.Frame)
{ {
// make seek frame keep up with emulation on fast scrolls // make seek frame keep up with emulation on fast scrolls
if (Mainform.EmulatorPaused || Mainform.IsSeeking || fromRewinding || WasRecording) if (MainForm.EmulatorPaused || MainForm.IsSeeking || fromRewinding || WasRecording)
{ {
StartSeeking(frame); StartSeeking(frame);
} }
@ -931,8 +930,8 @@ namespace BizHawk.Client.EmuHawk
} }
_hackyDontUpdate = true; _hackyDontUpdate = true;
GlobalWin.Tools.UpdateBefore(); Tools.UpdateBefore();
GlobalWin.Tools.UpdateAfter(); Tools.UpdateAfter();
_hackyDontUpdate = false; _hackyDontUpdate = false;
} }
@ -949,14 +948,14 @@ namespace BizHawk.Client.EmuHawk
private void UpdateOtherTools() // a hack probably, surely there is a better way to do this private void UpdateOtherTools() // a hack probably, surely there is a better way to do this
{ {
_hackyDontUpdate = true; _hackyDontUpdate = true;
GlobalWin.Tools.UpdateBefore(); Tools.UpdateBefore();
GlobalWin.Tools.UpdateAfter(); Tools.UpdateAfter();
_hackyDontUpdate = false; _hackyDontUpdate = false;
} }
public void TogglePause() public void TogglePause()
{ {
Mainform.TogglePause(); MainForm.TogglePause();
} }
private void SetSplicer() private void SetSplicer()

View File

@ -14,22 +14,22 @@ namespace BizHawk.Client.EmuHawk
public TI83KeyPad() public TI83KeyPad()
{ {
InitializeComponent(); InitializeComponent();
TopMost = Global.Config.TI83KeypadSettings.TopMost; TopMost = Config.TI83KeypadSettings.TopMost;
Closing += (o, e) => Closing += (o, e) =>
{ {
Global.Config.TI83KeypadSettings.Wndx = Location.X; Config.TI83KeypadSettings.Wndx = Location.X;
Global.Config.TI83KeypadSettings.Wndy = Location.Y; Config.TI83KeypadSettings.Wndy = Location.Y;
}; };
} }
private void TI83KeyPad_Load(object sender, EventArgs e) private void TI83KeyPad_Load(object sender, EventArgs e)
{ {
if (Global.Config.TI83KeypadSettings.UseWindowPosition && IsOnScreen(Global.Config.TI83KeypadSettings.TopLeft)) if (Config.TI83KeypadSettings.UseWindowPosition && IsOnScreen(Config.TI83KeypadSettings.TopLeft))
{ {
Location = Global.Config.TI83KeypadSettings.WindowPosition; Location = Config.TI83KeypadSettings.WindowPosition;
} }
if (Global.Config.TI83ToolTips) if (Config.TI83ToolTips)
{ {
SetToolTips(); SetToolTips();
} }
@ -62,7 +62,7 @@ namespace BizHawk.Client.EmuHawk
private void SetToolTips() private void SetToolTips()
{ {
// Set button hotkey mapping into tooltips // Set button hotkey mapping into tooltips
var mappings = Global.Config.AllTrollers["TI83 Controller"]; var mappings = Config.AllTrollers["TI83 Controller"];
KeyPadToolTips.SetToolTip(ZeroButton, mappings["0"]); KeyPadToolTips.SetToolTip(ZeroButton, mappings["0"]);
KeyPadToolTips.SetToolTip(OneButton, mappings["1"]); KeyPadToolTips.SetToolTip(OneButton, mappings["1"]);
KeyPadToolTips.SetToolTip(TwoButton, mappings["2"]); KeyPadToolTips.SetToolTip(TwoButton, mappings["2"]);
@ -131,17 +131,17 @@ namespace BizHawk.Client.EmuHawk
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e) private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
ShowHotkeysMenuItem.Checked = Global.Config.TI83ToolTips; ShowHotkeysMenuItem.Checked = Config.TI83ToolTips;
SaveWindowPositionMenuItem.Checked = Global.Config.TI83KeypadSettings.SaveWindowPosition; SaveWindowPositionMenuItem.Checked = Config.TI83KeypadSettings.SaveWindowPosition;
AlwaysOnTopMenuItem.Checked = Global.Config.TI83KeypadSettings.TopMost; AlwaysOnTopMenuItem.Checked = Config.TI83KeypadSettings.TopMost;
FloatingWindowMenuItem.Checked = Global.Config.TI83KeypadSettings.FloatingWindow; FloatingWindowMenuItem.Checked = Config.TI83KeypadSettings.FloatingWindow;
} }
private void ShowHotkeysMenuItem_Click(object sender, EventArgs e) private void ShowHotkeysMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.TI83ToolTips ^= true; Config.TI83ToolTips ^= true;
if (Global.Config.TI83ToolTips) if (Config.TI83ToolTips)
{ {
SetToolTips(); SetToolTips();
} }
@ -153,19 +153,19 @@ namespace BizHawk.Client.EmuHawk
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e) private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.TI83KeypadSettings.SaveWindowPosition ^= true; Config.TI83KeypadSettings.SaveWindowPosition ^= true;
} }
private void AlwaysOnTopMenuItem_Click(object sender, EventArgs e) private void AlwaysOnTopMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.TI83KeypadSettings.TopMost ^= true; Config.TI83KeypadSettings.TopMost ^= true;
TopMost = Global.Config.TI83KeypadSettings.TopMost; TopMost = Config.TI83KeypadSettings.TopMost;
} }
private void FloatingWindowMenuItem_Click(object sender, EventArgs e) private void FloatingWindowMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.TI83KeypadSettings.FloatingWindow ^= true; Config.TI83KeypadSettings.FloatingWindow ^= true;
RefreshFloatingWindowControl(Global.Config.TI83KeypadSettings.FloatingWindow); RefreshFloatingWindowControl(Config.TI83KeypadSettings.FloatingWindow);
} }
#endregion #endregion
@ -424,7 +424,7 @@ namespace BizHawk.Client.EmuHawk
protected override void OnShown(EventArgs e) protected override void OnShown(EventArgs e)
{ {
RefreshFloatingWindowControl(Global.Config.TI83KeypadSettings.FloatingWindow); RefreshFloatingWindowControl(Config.TI83KeypadSettings.FloatingWindow);
base.OnShown(e); base.OnShown(e);
} }

View File

@ -6,8 +6,6 @@ using System.Reflection;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Client.ApiHawk;
using BizHawk.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
@ -31,8 +29,8 @@ namespace BizHawk.Client.EmuHawk
public void NewUpdate(ToolFormUpdateType type) { } public void NewUpdate(ToolFormUpdateType type) { }
public bool AskSaveChanges() { return true; } public bool AskSaveChanges() => true;
public bool UpdateBefore { get { return false; } } public bool UpdateBefore => false;
public void UpdateValues() { } public void UpdateValues() { }
public void FastUpdate() public void FastUpdate()

View File

@ -1,116 +1,120 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common.IEmulatorExtensions; using BizHawk.Emulation.Common.IEmulatorExtensions;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Client.EmuHawk.WinFormExtensions; using BizHawk.Client.EmuHawk.WinFormExtensions;
using System.Drawing; using System.Drawing;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public class ToolFormBase : Form public class ToolFormBase : Form
{ {
public static FileInfo OpenFileDialog(string currentFile, string path, string fileType, string fileExt) public ToolManager Tools { get; set; }
{ public Config Config { get; set; }
if (!Directory.Exists(path)) public MainForm MainForm { get; set; }
{
Directory.CreateDirectory(path); public static FileInfo OpenFileDialog(string currentFile, string path, string fileType, string fileExt)
} {
if (!Directory.Exists(path))
using var ofd = new OpenFileDialog {
{ Directory.CreateDirectory(path);
FileName = !string.IsNullOrWhiteSpace(currentFile) }
? Path.GetFileName(currentFile)
: $"{PathManager.FilesystemSafeName(Global.Game)}.{fileExt}", using var ofd = new OpenFileDialog
InitialDirectory = path, {
Filter = string.Format("{0} (*.{1})|*.{1}|All Files|*.*", fileType, fileExt), FileName = !string.IsNullOrWhiteSpace(currentFile)
RestoreDirectory = true ? Path.GetFileName(currentFile)
}; : $"{PathManager.FilesystemSafeName(Global.Game)}.{fileExt}",
InitialDirectory = path,
var result = ofd.ShowHawkDialog(); Filter = string.Format("{0} (*.{1})|*.{1}|All Files|*.*", fileType, fileExt),
if (result != DialogResult.OK) RestoreDirectory = true
{ };
return null;
} var result = ofd.ShowHawkDialog();
if (result != DialogResult.OK)
return new FileInfo(ofd.FileName); {
} return null;
}
public static FileInfo SaveFileDialog(string currentFile, string path, string fileType, string fileExt)
{ return new FileInfo(ofd.FileName);
if (!Directory.Exists(path)) }
{
Directory.CreateDirectory(path); public static FileInfo SaveFileDialog(string currentFile, string path, string fileType, string fileExt)
} {
if (!Directory.Exists(path))
using var sfd = new SaveFileDialog {
{ Directory.CreateDirectory(path);
FileName = !string.IsNullOrWhiteSpace(currentFile) }
? Path.GetFileName(currentFile)
: $"{PathManager.FilesystemSafeName(Global.Game)}.{fileExt}", using var sfd = new SaveFileDialog
InitialDirectory = path, {
Filter = string.Format("{0} (*.{1})|*.{1}|All Files|*.*", fileType, fileExt), FileName = !string.IsNullOrWhiteSpace(currentFile)
RestoreDirectory = true, ? Path.GetFileName(currentFile)
}; : $"{PathManager.FilesystemSafeName(Global.Game)}.{fileExt}",
InitialDirectory = path,
var result = sfd.ShowHawkDialog(); Filter = string.Format("{0} (*.{1})|*.{1}|All Files|*.*", fileType, fileExt),
if (result != DialogResult.OK) RestoreDirectory = true,
{ };
return null;
} var result = sfd.ShowHawkDialog();
if (result != DialogResult.OK)
return new FileInfo(sfd.FileName); {
} return null;
}
public static FileInfo GetWatchFileFromUser(string currentFile)
{ return new FileInfo(sfd.FileName);
return OpenFileDialog(currentFile, PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPathFragment, null), "Watch Files", "wch"); }
}
public static FileInfo GetWatchFileFromUser(string currentFile)
public static FileInfo GetWatchSaveFileFromUser(string currentFile) {
{ return OpenFileDialog(currentFile, PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPathFragment, null), "Watch Files", "wch");
return SaveFileDialog(currentFile, PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPathFragment, null), "Watch Files", "wch"); }
}
public static FileInfo GetWatchSaveFileFromUser(string currentFile)
public static void UpdateCheatRelatedTools(object sender, CheatCollection.CheatListEventArgs e) {
{ return SaveFileDialog(currentFile, PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPathFragment, null), "Watch Files", "wch");
if (Global.Emulator.HasMemoryDomains()) }
{
GlobalWin.Tools.UpdateValues<RamWatch>(); public static void UpdateCheatRelatedTools(object sender, CheatCollection.CheatListEventArgs e)
GlobalWin.Tools.UpdateValues<RamSearch>(); {
GlobalWin.Tools.UpdateValues<HexEditor>(); if (Global.Emulator.HasMemoryDomains())
{
if (GlobalWin.Tools.Has<Cheats>()) GlobalWin.Tools.UpdateValues<RamWatch>();
{ GlobalWin.Tools.UpdateValues<RamSearch>();
GlobalWin.Tools.Cheats.UpdateDialog(); GlobalWin.Tools.UpdateValues<HexEditor>();
}
if (GlobalWin.Tools.Has<Cheats>())
GlobalWin.MainForm.UpdateCheatStatus(); {
} GlobalWin.Tools.Cheats.UpdateDialog();
} }
public static void ViewInHexEditor(MemoryDomain domain, IEnumerable<long> addresses, WatchSize size) GlobalWin.MainForm.UpdateCheatStatus();
{ }
GlobalWin.Tools.Load<HexEditor>(); }
GlobalWin.Tools.HexEditor.SetToAddresses(addresses, domain, size);
} public void ViewInHexEditor(MemoryDomain domain, IEnumerable<long> addresses, WatchSize size)
{
protected void GenericDragEnter(object sender, DragEventArgs e) Tools.Load<HexEditor>();
{ Tools.HexEditor.SetToAddresses(addresses, domain, size);
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; }
}
protected void GenericDragEnter(object sender, DragEventArgs e)
protected void RefreshFloatingWindowControl(bool floatingWindow) {
{ e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
Owner = floatingWindow ? null : GlobalWin.MainForm; }
}
protected void RefreshFloatingWindowControl(bool floatingWindow)
protected bool IsOnScreen(Point topLeft) {
{ Owner = floatingWindow ? null : GlobalWin.MainForm;
return ToolManager.IsOnScreen(topLeft); }
}
} protected bool IsOnScreen(Point topLeft)
} {
return Tools.IsOnScreen(topLeft);
}
}
}

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -18,7 +19,10 @@ namespace BizHawk.Client.EmuHawk
{ {
public class ToolManager public class ToolManager
{ {
private readonly Form _owner; private readonly MainForm _owner;
private readonly Config _config;
private IExternalApiProvider _apiProvider;
private IEmulator _emulator;
// TODO: merge ToolHelper code where logical // TODO: merge ToolHelper code where logical
// For instance, add an IToolForm property called UsesCheats, so that a UpdateCheatRelatedTools() method can update all tools of this type // For instance, add an IToolForm property called UsesCheats, so that a UpdateCheatRelatedTools() method can update all tools of this type
@ -28,10 +32,12 @@ namespace BizHawk.Client.EmuHawk
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ToolManager"/> class. /// Initializes a new instance of the <see cref="ToolManager"/> class.
/// </summary> /// </summary>
/// <param name="owner">Form that handle the ToolManager</param> public ToolManager(MainForm owner, Config config, IEmulator emulator)
public ToolManager(Form owner)
{ {
_owner = owner; _owner = owner;
_config = config;
_emulator = emulator;
_apiProvider = ApiManager.Restart(_emulator.ServiceProvider);
} }
/// <summary> /// <summary>
@ -54,6 +60,17 @@ namespace BizHawk.Client.EmuHawk
return (IToolForm)method.Invoke(this, new object[] { focus }); return (IToolForm)method.Invoke(this, new object[] { focus });
} }
// If the form inherits ToolFormBase, it will set base properties such as Tools, Config, etc
private void SetBaseProperties(IToolForm form)
{
if (form is ToolFormBase tool)
{
tool.Tools = this;
tool.Config = _config;
tool.MainForm = _owner;
}
}
/// <summary> /// <summary>
/// Loads the tool dialog T (T must implement <see cref="IToolForm"/>) , if it does not exist it will be created, if it is already open, it will be focused /// Loads the tool dialog T (T must implement <see cref="IToolForm"/>) , if it does not exist it will be created, if it is already open, it will be focused
/// </summary> /// </summary>
@ -125,19 +142,20 @@ namespace BizHawk.Client.EmuHawk
if (isExternal) if (isExternal)
{ {
ApiInjector.UpdateApis(GlobalWin.ApiProvider, newTool); ApiInjector.UpdateApis(_apiProvider, newTool);
} }
ServiceInjector.UpdateServices(Global.Emulator.ServiceProvider, newTool); ServiceInjector.UpdateServices(_emulator.ServiceProvider, newTool);
SetBaseProperties(newTool);
string toolType = typeof(T).ToString(); string toolType = typeof(T).ToString();
// auto settings // auto settings
if (newTool is IToolFormAutoConfig tool) if (newTool is IToolFormAutoConfig tool)
{ {
if (!Global.Config.CommonToolSettings.TryGetValue(toolType, out var settings)) if (!_config.CommonToolSettings.TryGetValue(toolType, out var settings))
{ {
settings = new ToolDialogSettings(); settings = new ToolDialogSettings();
Global.Config.CommonToolSettings[toolType] = settings; _config.CommonToolSettings[toolType] = settings;
} }
AttachSettingHooks(tool, settings); AttachSettingHooks(tool, settings);
@ -146,10 +164,10 @@ namespace BizHawk.Client.EmuHawk
// custom settings // custom settings
if (HasCustomConfig(newTool)) if (HasCustomConfig(newTool))
{ {
if (!Global.Config.CustomToolSettings.TryGetValue(toolType, out var settings)) if (!_config.CustomToolSettings.TryGetValue(toolType, out var settings))
{ {
settings = new Dictionary<string, object>(); settings = new Dictionary<string, object>();
Global.Config.CustomToolSettings[toolType] = settings; _config.CustomToolSettings[toolType] = settings;
} }
InstallCustomConfig(newTool, settings); InstallCustomConfig(newTool, settings);
@ -169,11 +187,11 @@ namespace BizHawk.Client.EmuHawk
public void AutoLoad() public void AutoLoad()
{ {
var genericSettings = Global.Config.CommonToolSettings var genericSettings = _config.CommonToolSettings
.Where(kvp => kvp.Value.AutoLoad) .Where(kvp => kvp.Value.AutoLoad)
.Select(kvp => kvp.Key); .Select(kvp => kvp.Key);
var customSettings = Global.Config.CustomToolSettings var customSettings = _config.CustomToolSettings
.Where(list => list.Value.Any(kvp => kvp.Value is ToolDialogSettings settings && settings.AutoLoad)) .Where(list => list.Value.Any(kvp => kvp.Value is ToolDialogSettings settings && settings.AutoLoad))
.Select(kvp => kvp.Key); .Select(kvp => kvp.Key);
@ -342,8 +360,7 @@ namespace BizHawk.Client.EmuHawk
foreach (var prop in props) foreach (var prop in props)
{ {
object val; if (data.TryGetValue(prop.Name, out var val))
if (data.TryGetValue(prop.Name, out val))
{ {
if (val is string str && prop.PropertyType != typeof(string)) if (val is string str && prop.PropertyType != typeof(string))
{ {
@ -354,12 +371,12 @@ namespace BizHawk.Client.EmuHawk
// back on regular object serialization when needed. so try to undo a TypeConverter // back on regular object serialization when needed. so try to undo a TypeConverter
// operation here // operation here
var converter = TypeDescriptor.GetConverter(prop.PropertyType); var converter = TypeDescriptor.GetConverter(prop.PropertyType);
val = converter.ConvertFromString(null, System.Globalization.CultureInfo.InvariantCulture, str); val = converter.ConvertFromString(null, CultureInfo.InvariantCulture, str);
} }
else if (!(val is bool) && prop.PropertyType.IsPrimitive) else if (!(val is bool) && prop.PropertyType.IsPrimitive)
{ {
// numeric constants are similarly hosed // numeric constants are similarly hosed
val = Convert.ChangeType(val, prop.PropertyType, System.Globalization.CultureInfo.InvariantCulture); val = Convert.ChangeType(val, prop.PropertyType, CultureInfo.InvariantCulture);
} }
prop.SetValue(tool, val, null); prop.SetValue(tool, val, null);
@ -374,7 +391,7 @@ namespace BizHawk.Client.EmuHawk
data.Clear(); data.Clear();
foreach (var prop in props) foreach (var prop in props)
{ {
data.Add(prop.Name, prop.GetValue(tool, BindingFlags.GetProperty, Type.DefaultBinder, null, System.Globalization.CultureInfo.InvariantCulture)); data.Add(prop.Name, prop.GetValue(tool, BindingFlags.GetProperty, Type.DefaultBinder, null, CultureInfo.InvariantCulture));
} }
} }
@ -393,7 +410,7 @@ namespace BizHawk.Client.EmuHawk
return false; return false;
} }
public static bool IsOnScreen(Point topLeft) public bool IsOnScreen(Point topLeft)
{ {
return Screen.AllScreens.Any( return Screen.AllScreens.Any(
screen => screen.WorkingArea.Contains(topLeft)); screen => screen.WorkingArea.Contains(topLeft));
@ -417,26 +434,20 @@ namespace BizHawk.Client.EmuHawk
return Load<T>(false); return Load<T>(false);
} }
public IEnumerable<Type> AvailableTools public IEnumerable<Type> AvailableTools => Assembly
{ .GetAssembly(typeof(IToolForm))
get .GetTypes()
{ .Where(t => typeof(IToolForm).IsAssignableFrom(t))
return Assembly .Where(t => !t.IsInterface)
.GetAssembly(typeof(IToolForm)) .Where(IsAvailable);
.GetTypes()
.Where(t => typeof(IToolForm).IsAssignableFrom(t))
.Where(t => !t.IsInterface)
.Where(IsAvailable);
}
}
public void UpdateBefore() public void UpdateBefore()
{ {
var beforeList = _tools.Where(t => t.UpdateBefore); var beforeList = _tools.Where(t => t.UpdateBefore);
foreach (var tool in beforeList) foreach (var tool in beforeList)
{ {
if (!tool.IsDisposed if (!tool.IsDisposed
|| (tool is RamWatch && Global.Config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed || (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed
{ {
tool.UpdateValues(); tool.UpdateValues();
} }
@ -457,7 +468,7 @@ namespace BizHawk.Client.EmuHawk
foreach (var tool in afterList) foreach (var tool in afterList)
{ {
if (!tool.IsDisposed if (!tool.IsDisposed
|| (tool is RamWatch && Global.Config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed || (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed
{ {
tool.UpdateValues(); tool.UpdateValues();
} }
@ -482,15 +493,17 @@ namespace BizHawk.Client.EmuHawk
if (tool != null) if (tool != null)
{ {
if (!tool.IsDisposed || if (!tool.IsDisposed ||
(tool is RamWatch && Global.Config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed
{ {
tool.UpdateValues(); tool.UpdateValues();
} }
} }
} }
public void Restart() public void Restart(IEmulator emulator)
{ {
_emulator = emulator;
_apiProvider = ApiManager.Restart(_emulator.ServiceProvider);
// If Cheat tool is loaded, restarting will restart the list too anyway // If Cheat tool is loaded, restarting will restart the list too anyway
if (!Has<Cheats>()) if (!Has<Cheats>())
{ {
@ -501,14 +514,14 @@ namespace BizHawk.Client.EmuHawk
foreach (var tool in _tools) foreach (var tool in _tools)
{ {
if (ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, tool.GetType())) if (ServiceInjector.IsAvailable(_emulator.ServiceProvider, tool.GetType()))
{ {
ServiceInjector.UpdateServices(Global.Emulator.ServiceProvider, tool); ServiceInjector.UpdateServices(_emulator.ServiceProvider, tool);
if ((tool.IsHandleCreated && !tool.IsDisposed) || tool is RamWatch) // Hack for RAM Watch - in display watches mode it wants to keep running even closed, it will handle disposed logic if ((tool.IsHandleCreated && !tool.IsDisposed) || tool is RamWatch) // Hack for RAM Watch - in display watches mode it wants to keep running even closed, it will handle disposed logic
{ {
if (tool is IExternalToolForm) if (tool is IExternalToolForm)
ApiInjector.UpdateApis(GlobalWin.ApiProvider, tool); ApiInjector.UpdateApis(_apiProvider, tool);
tool.Restart(); tool.Restart();
} }
} }
@ -541,7 +554,7 @@ namespace BizHawk.Client.EmuHawk
/// </summary> /// </summary>
public bool AskSave() public bool AskSave()
{ {
if (Global.Config.SuppressAskSave) // User has elected to not be nagged if (_config.SuppressAskSave) // User has elected to not be nagged
{ {
return true; return true;
} }
@ -558,18 +571,13 @@ namespace BizHawk.Client.EmuHawk
/// <typeparam name="T">Type of tool</typeparam> /// <typeparam name="T">Type of tool</typeparam>
public bool AskSave<T>() where T : IToolForm public bool AskSave<T>() where T : IToolForm
{ {
if (Global.Config.SuppressAskSave) // User has elected to not be nagged if (_config.SuppressAskSave) // User has elected to not be nagged
{ {
return true; return true;
} }
var tool = _tools.FirstOrDefault(t => t is T); var tool = _tools.FirstOrDefault(t => t is T);
if (tool != null) return tool != null && tool.AskSaveChanges();
{
return tool.AskSaveChanges();
}
return false;
} }
/// <summary> /// <summary>
@ -706,7 +714,7 @@ namespace BizHawk.Client.EmuHawk
foreach (var tool in beforeList) foreach (var tool in beforeList)
{ {
if (!tool.IsDisposed if (!tool.IsDisposed
|| (tool is RamWatch && Global.Config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed || (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed
{ {
tool.FastUpdate(); tool.FastUpdate();
} }
@ -715,7 +723,7 @@ namespace BizHawk.Client.EmuHawk
public void FastUpdateAfter(bool fromLua = false) public void FastUpdateAfter(bool fromLua = false)
{ {
if (!fromLua && Global.Config.RunLuaDuringTurbo && Has<LuaConsole>()) if (!fromLua && _config.RunLuaDuringTurbo && Has<LuaConsole>())
{ {
LuaConsole.ResumeScripts(true); LuaConsole.ResumeScripts(true);
} }
@ -724,29 +732,28 @@ namespace BizHawk.Client.EmuHawk
foreach (var tool in afterList) foreach (var tool in afterList)
{ {
if (!tool.IsDisposed if (!tool.IsDisposed
|| (tool is RamWatch && Global.Config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed || (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed
{ {
tool.FastUpdate(); tool.FastUpdate();
} }
} }
if (Global.Config.RunLuaDuringTurbo && Has<LuaConsole>()) if (_config.RunLuaDuringTurbo && Has<LuaConsole>())
{ {
LuaConsole.LuaImp.EndLuaDrawing(); LuaConsole.LuaImp.EndLuaDrawing();
} }
} }
private static readonly Lazy<List<string>> lazyAsmTypes = new Lazy<List<string>>(() => private static readonly Lazy<List<string>> LazyAsmTypes = new Lazy<List<string>>(() =>
Assembly.GetAssembly(typeof(ToolManager)) // Confining the search to only EmuHawk, for now at least, we may want to broaden for ApiHawk one day Assembly.GetAssembly(typeof(ToolManager)) // Confining the search to only EmuHawk, for now at least, we may want to broaden for ApiHawk one day
.GetTypes() .GetTypes()
.Select(t => t.AssemblyQualifiedName) .Select(t => t.AssemblyQualifiedName)
.ToList() .ToList());
);
public bool IsAvailable(Type tool) public bool IsAvailable(Type tool)
{ {
if (!ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, tool) if (!ServiceInjector.IsAvailable(_emulator.ServiceProvider, tool)
|| !lazyAsmTypes.Value.Contains(tool.AssemblyQualifiedName)) // not a tool || !LazyAsmTypes.Value.Contains(tool.AssemblyQualifiedName)) // not a tool
{ {
return false; return false;
} }
@ -757,8 +764,8 @@ namespace BizHawk.Client.EmuHawk
return true; // no ToolAttribute on given type -> assumed all supported return true; // no ToolAttribute on given type -> assumed all supported
} }
var displayName = Global.Emulator.DisplayName(); var displayName = _emulator.DisplayName();
var systemId = Global.Emulator.SystemId; var systemId = _emulator.SystemId;
return !attr.UnsupportedCores.Contains(displayName) // not unsupported return !attr.UnsupportedCores.Contains(displayName) // not unsupported
&& (!attr.SupportedSystems.Any() || attr.SupportedSystems.Contains(systemId)); // supported (no supported list -> assumed all supported) && (!attr.SupportedSystems.Any() || attr.SupportedSystems.Contains(systemId)); // supported (no supported list -> assumed all supported)
} }
@ -798,19 +805,7 @@ namespace BizHawk.Client.EmuHawk
public LuaConsole LuaConsole => GetTool<LuaConsole>(); public LuaConsole LuaConsole => GetTool<LuaConsole>();
public TAStudio TAStudio public TAStudio TAStudio => GetTool<TAStudio>();
{
get
{
// prevent nasty silent corruption
if (!IsLoaded<TAStudio>())
{
System.Diagnostics.Debug.Fail("TAStudio does not exist!");
}
return GetTool<TAStudio>();
}
}
#endregion #endregion
@ -827,9 +822,9 @@ namespace BizHawk.Client.EmuHawk
if (IsAvailable<RamWatch>()) // Just because we attempted to load it, doesn't mean it was, the current core may not have the correct dependencies if (IsAvailable<RamWatch>()) // Just because we attempted to load it, doesn't mean it was, the current core may not have the correct dependencies
{ {
if (Global.Config.RecentWatches.AutoLoad && !Global.Config.RecentWatches.Empty) if (_config.RecentWatches.AutoLoad && !_config.RecentWatches.Empty)
{ {
RamWatch.LoadFileFromRecent(Global.Config.RecentWatches.MostRecent); RamWatch.LoadFileFromRecent(_config.RecentWatches.MostRecent);
} }
if (!loadDialog) if (!loadDialog)
@ -849,10 +844,10 @@ namespace BizHawk.Client.EmuHawk
#endregion #endregion
public static string GenerateDefaultCheatFilename() public string GenerateDefaultCheatFilename()
{ {
var pathEntry = Global.Config.PathEntries[Global.Game.System, "Cheats"] var pathEntry = _config.PathEntries[Global.Game.System, "Cheats"]
?? Global.Config.PathEntries[Global.Game.System, "Base"]; ?? _config.PathEntries[Global.Game.System, "Base"];
var path = PathManager.MakeAbsolutePath(pathEntry.Path, Global.Game.System); var path = PathManager.MakeAbsolutePath(pathEntry.Path, Global.Game.System);

View File

@ -29,11 +29,7 @@ namespace BizHawk.Client.EmuHawk
public bool Readonly public bool Readonly
{ {
get get => _readOnly;
{
return _readOnly;
}
set set
{ {
_readOnly = value; _readOnly = value;
@ -149,8 +145,8 @@ namespace BizHawk.Client.EmuHawk
#region IToolForm Implementation #region IToolForm Implementation
public bool AskSaveChanges() { return true; } public bool AskSaveChanges() => true;
public bool UpdateBefore { get { return false; } } public bool UpdateBefore => false;
public void Restart() public void Restart()
{ {
@ -173,7 +169,7 @@ namespace BizHawk.Client.EmuHawk
Pads.ForEach(p => p.SetPrevious(null)); // Not the cleanest way to clear this every frame Pads.ForEach(p => p.SetPrevious(null)); // Not the cleanest way to clear this every frame
if (Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished) if (Global.MovieSession.Movie.Mode == MovieMode.Play)
{ {
Readonly = true; Readonly = true;
if (Global.MovieSession.CurrentInput != null) if (Global.MovieSession.CurrentInput != null)
@ -183,7 +179,7 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
if (Global.MovieSession.Movie.IsRecording) if (Global.MovieSession.Movie.IsRecording())
{ {
Pads.ForEach(p => p.SetPrevious(Global.MovieSession.PreviousFrame)); Pads.ForEach(p => p.SetPrevious(Global.MovieSession.PreviousFrame));
} }

View File

@ -882,8 +882,8 @@ namespace BizHawk.Client.EmuHawk
var watches = SelectedWatches.ToList(); var watches = SelectedWatches.ToList();
if (watches.Any()) if (watches.Any())
{ {
GlobalWin.Tools.LoadRamWatch(true); Tools.LoadRamWatch(true);
watches.ForEach(GlobalWin.Tools.RamWatch.AddWatch); watches.ForEach(Tools.RamWatch.AddWatch);
if (Settings.AlwaysExcludeRamWatch) if (Settings.AlwaysExcludeRamWatch)
{ {
RemoveRamWatchesFromList(); RemoveRamWatchesFromList();
@ -909,9 +909,9 @@ namespace BizHawk.Client.EmuHawk
private void RemoveRamWatchesFromList() private void RemoveRamWatchesFromList()
{ {
if (GlobalWin.Tools.Has<RamWatch>()) if (Tools.Has<RamWatch>())
{ {
_searches.RemoveSmallWatchRange(GlobalWin.Tools.RamWatch.Watches); _searches.RemoveSmallWatchRange(Tools.RamWatch.Watches);
UpdateList(); UpdateList();
} }
} }

View File

@ -131,7 +131,7 @@ namespace BizHawk.Client.EmuHawk
else else
{ {
_watches.Save(); _watches.Save();
Global.Config.RecentWatches.Add(_watches.CurrentFileName); Config.RecentWatches.Add(_watches.CurrentFileName);
} }
} }
else if (result == DialogResult.No) else if (result == DialogResult.No)
@ -161,11 +161,11 @@ namespace BizHawk.Client.EmuHawk
var loadResult = _watches.Load(path, append: false); var loadResult = _watches.Load(path, append: false);
if (!loadResult) if (!loadResult)
{ {
Global.Config.RecentWatches.HandleLoadError(path); Config.RecentWatches.HandleLoadError(path);
} }
else else
{ {
Global.Config.RecentWatches.Add(path); Config.RecentWatches.Add(path);
WatchListView.RowCount = _watches.Count; WatchListView.RowCount = _watches.Count;
UpdateWatchCount(); UpdateWatchCount();
UpdateValues(); UpdateValues();
@ -190,7 +190,7 @@ namespace BizHawk.Client.EmuHawk
_watches.Load(file.FullName, append); _watches.Load(file.FullName, append);
WatchListView.RowCount = _watches.Count; WatchListView.RowCount = _watches.Count;
UpdateWatchCount(); UpdateWatchCount();
Global.Config.RecentWatches.Add(_watches.CurrentFileName); Config.RecentWatches.Add(_watches.CurrentFileName);
UpdateStatusBar(); UpdateStatusBar();
UpdateValues(); UpdateValues();
PokeAddressToolBarItem.Enabled = PokeAddressToolBarItem.Enabled =
@ -203,7 +203,7 @@ namespace BizHawk.Client.EmuHawk
public void Restart() public void Restart()
{ {
if ((!IsHandleCreated || IsDisposed) && !Global.Config.DisplayRamWatch) if ((!IsHandleCreated || IsDisposed) && !Config.DisplayRamWatch)
{ {
return; return;
} }
@ -211,7 +211,7 @@ namespace BizHawk.Client.EmuHawk
if (_watches != null if (_watches != null
&& !string.IsNullOrWhiteSpace(_watches.CurrentFileName) && !string.IsNullOrWhiteSpace(_watches.CurrentFileName)
&& _watches.All(w => w.Domain == null || MemoryDomains.Select(m => m.Name).Contains(w.Domain.Name)) && _watches.All(w => w.Domain == null || MemoryDomains.Select(m => m.Name).Contains(w.Domain.Name))
&& (Global.Config.RecentWatches.AutoLoad || (IsHandleCreated || !IsDisposed))) && (Config.RecentWatches.AutoLoad || (IsHandleCreated || !IsDisposed)))
{ {
_watches.RefreshDomains(MemoryDomains); _watches.RefreshDomains(MemoryDomains);
_watches.Reload(); _watches.Reload();
@ -229,6 +229,27 @@ namespace BizHawk.Client.EmuHawk
{ {
} }
private void DisplayOnScreenWatches()
{
if (Config.DisplayRamWatch)
{
for (var i = 0; i < _watches.Count; i++)
{
var frozen = !_watches[i].IsSeparator && Global.CheatList.IsActive(_watches[i].Domain, _watches[i].Address);
GlobalWin.OSD.AddGuiText(
_watches[i].ToDisplayString(),
new MessagePosition
{
X = Config.RamWatches.X,
Y = Config.RamWatches.Y + (i * 14),
Anchor = Config.RamWatches.Anchor
},
Color.Black,
frozen ? Color.Cyan : Color.White);
}
}
}
public void UpdateValues() public void UpdateValues()
{ {
if (_paused) if (_paused)
@ -236,7 +257,7 @@ namespace BizHawk.Client.EmuHawk
return; return;
} }
if ((!IsHandleCreated || IsDisposed) && !Global.Config.DisplayRamWatch) if ((!IsHandleCreated || IsDisposed) && !Config.DisplayRamWatch)
{ {
return; return;
} }
@ -245,21 +266,7 @@ namespace BizHawk.Client.EmuHawk
if (_watches.Any()) if (_watches.Any())
{ {
_watches.UpdateValues(); _watches.UpdateValues();
DisplayOnScreenWatches();
if (Global.Config.DisplayRamWatch)
{
for (var i = 0; i < _watches.Count; i++)
{
var frozen = !_watches[i].IsSeparator && Global.CheatList.IsActive(_watches[i].Domain, _watches[i].Address);
GlobalWin.OSD.AddGuiText(
_watches[i].ToDisplayString(),
Global.Config.DispRamWatchx,
Global.Config.DispRamWatchy + (i * 14),
Color.Black,
frozen ? Color.Cyan : Color.White,
0);
}
}
if (!IsHandleCreated || IsDisposed) if (!IsHandleCreated || IsDisposed)
{ {
@ -277,7 +284,7 @@ namespace BizHawk.Client.EmuHawk
return; return;
} }
if ((!IsHandleCreated || IsDisposed) && !Global.Config.DisplayRamWatch) if ((!IsHandleCreated || IsDisposed) && !Config.DisplayRamWatch)
{ {
return; return;
} }
@ -285,21 +292,7 @@ namespace BizHawk.Client.EmuHawk
if (_watches.Any()) if (_watches.Any())
{ {
_watches.UpdateValues(); _watches.UpdateValues();
DisplayOnScreenWatches();
if (Global.Config.DisplayRamWatch)
{
for (var i = 0; i < _watches.Count; i++)
{
var frozen = !_watches[i].IsSeparator && Global.CheatList.IsActive(_watches[i].Domain, _watches[i].Address);
GlobalWin.OSD.AddGuiText(
_watches[i].ToDisplayString(),
Global.Config.DispRamWatchx,
Global.Config.DispRamWatchy + (i * 14),
Color.Black,
frozen ? Color.Cyan : Color.White,
0);
}
}
} }
} }
@ -529,7 +522,7 @@ namespace BizHawk.Client.EmuHawk
if (result) if (result)
{ {
UpdateStatusBar(saved: true); UpdateStatusBar(saved: true);
Global.Config.RecentWatches.Add(_watches.CurrentFileName); Config.RecentWatches.Add(_watches.CurrentFileName);
} }
} }
@ -677,7 +670,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (_watches.Save()) if (_watches.Save())
{ {
Global.Config.RecentWatches.Add(_watches.CurrentFileName); Config.RecentWatches.Add(_watches.CurrentFileName);
UpdateStatusBar(saved: true); UpdateStatusBar(saved: true);
} }
} }
@ -696,7 +689,7 @@ namespace BizHawk.Client.EmuHawk
{ {
RecentSubMenu.DropDownItems.Clear(); RecentSubMenu.DropDownItems.Clear();
RecentSubMenu.DropDownItems.AddRange( RecentSubMenu.DropDownItems.AddRange(
Global.Config.RecentWatches.RecentMenu(LoadFileFromRecent, true)); Config.RecentWatches.RecentMenu(LoadFileFromRecent, true));
} }
private void ExitMenuItem_Click(object sender, EventArgs e) private void ExitMenuItem_Click(object sender, EventArgs e)
@ -971,7 +964,7 @@ namespace BizHawk.Client.EmuHawk
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e) private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
WatchesOnScreenMenuItem.Checked = Global.Config.DisplayRamWatch; WatchesOnScreenMenuItem.Checked = Config.DisplayRamWatch;
SaveWindowPositionMenuItem.Checked = Settings.SaveWindowPosition; SaveWindowPositionMenuItem.Checked = Settings.SaveWindowPosition;
AlwaysOnTopMenuItem.Checked = Settings.TopMost; AlwaysOnTopMenuItem.Checked = Settings.TopMost;
FloatingWindowMenuItem.Checked = Settings.FloatingWindow; FloatingWindowMenuItem.Checked = Settings.FloatingWindow;
@ -979,31 +972,31 @@ namespace BizHawk.Client.EmuHawk
private void DefinePreviousValueSubMenu_DropDownOpened(object sender, EventArgs e) private void DefinePreviousValueSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
PreviousFrameMenuItem.Checked = Global.Config.RamWatchDefinePrevious == PreviousType.LastFrame; PreviousFrameMenuItem.Checked = Config.RamWatchDefinePrevious == PreviousType.LastFrame;
LastChangeMenuItem.Checked = Global.Config.RamWatchDefinePrevious == PreviousType.LastChange; LastChangeMenuItem.Checked = Config.RamWatchDefinePrevious == PreviousType.LastChange;
OriginalMenuItem.Checked = Global.Config.RamWatchDefinePrevious == PreviousType.Original; OriginalMenuItem.Checked = Config.RamWatchDefinePrevious == PreviousType.Original;
} }
private void PreviousFrameMenuItem_Click(object sender, EventArgs e) private void PreviousFrameMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.RamWatchDefinePrevious = PreviousType.LastFrame; Config.RamWatchDefinePrevious = PreviousType.LastFrame;
} }
private void LastChangeMenuItem_Click(object sender, EventArgs e) private void LastChangeMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.RamWatchDefinePrevious = PreviousType.LastChange; Config.RamWatchDefinePrevious = PreviousType.LastChange;
} }
private void OriginalMenuItem_Click(object sender, EventArgs e) private void OriginalMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.RamWatchDefinePrevious = PreviousType.Original; Config.RamWatchDefinePrevious = PreviousType.Original;
} }
private void WatchesOnScreenMenuItem_Click(object sender, EventArgs e) private void WatchesOnScreenMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.DisplayRamWatch ^= true; Config.DisplayRamWatch ^= true;
if (!Global.Config.DisplayRamWatch) if (!Config.DisplayRamWatch)
{ {
GlobalWin.OSD.ClearGuiText(); GlobalWin.OSD.ClearGuiText();
} }
@ -1041,7 +1034,7 @@ namespace BizHawk.Client.EmuHawk
RamWatchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback)); RamWatchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback));
Global.Config.DisplayRamWatch = false; Config.DisplayRamWatch = false;
RefreshFloatingWindowControl(Settings.FloatingWindow); RefreshFloatingWindowControl(Settings.FloatingWindow);
@ -1083,7 +1076,7 @@ namespace BizHawk.Client.EmuHawk
if (Path.GetExtension(filePaths[0]) == ".wch") if (Path.GetExtension(filePaths[0]) == ".wch")
{ {
_watches.Load(filePaths[0], append: false); _watches.Load(filePaths[0], append: false);
Global.Config.RecentWatches.Add(_watches.CurrentFileName); Config.RecentWatches.Add(_watches.CurrentFileName);
WatchListView.RowCount = _watches.Count; WatchListView.RowCount = _watches.Count;
UpdateValues(); UpdateValues();
} }
@ -1152,7 +1145,7 @@ namespace BizHawk.Client.EmuHawk
var selected = SelectedWatches.ToList(); var selected = SelectedWatches.ToList();
if (selected.Any()) if (selected.Any())
{ {
GlobalWin.Tools.Load<HexEditor>(); Tools.Load<HexEditor>();
if (selected.Select(x => x.Domain).Distinct().Count() > 1) if (selected.Select(x => x.Domain).Distinct().Count() > 1)
{ {
@ -1171,7 +1164,7 @@ namespace BizHawk.Client.EmuHawk
if (selected.Any()) if (selected.Any())
{ {
var debugger = GlobalWin.Tools.Load<GenericDebugger>(); var debugger = Tools.Load<GenericDebugger>();
foreach (var watch in selected) foreach (var watch in selected)
{ {
@ -1186,7 +1179,7 @@ namespace BizHawk.Client.EmuHawk
if (selected.Any()) if (selected.Any())
{ {
var debugger = GlobalWin.Tools.Load<GenericDebugger>(); var debugger = Tools.Load<GenericDebugger>();
foreach (var watch in selected) foreach (var watch in selected)
{ {

View File

@ -7,10 +7,7 @@
/// <seealso cref="IVideoProvider" /> /// <seealso cref="IVideoProvider" />
public class NullVideo : IVideoProvider public class NullVideo : IVideoProvider
{ {
public int[] GetVideoBuffer() public int[] GetVideoBuffer() => new int[BufferWidth * BufferHeight];
{
return new int[BufferWidth * BufferHeight];
}
public static NullVideo Instance { get; } = new NullVideo(); public static NullVideo Instance { get; } = new NullVideo();

View File

@ -184,7 +184,16 @@ namespace BizHawk.Emulation.Common.Components.I8048
reg_l_ad = cur_instr[instr_pntr++]; reg_l_ad = cur_instr[instr_pntr++];
reg_h_ad = cur_instr[instr_pntr++]; // direct value reg_h_ad = cur_instr[instr_pntr++]; // direct value
Regs[reg_d_ad] = (ushort)(MB | (reg_h_ad << 8) | Regs[reg_l_ad]); // bit 11 held low during interrupt
if (INT_MSTR)
{
Regs[reg_d_ad] = (ushort)(MB | (reg_h_ad << 8) | Regs[reg_l_ad]);
}
else
{
Regs[reg_d_ad] = (ushort)((reg_h_ad << 8) | Regs[reg_l_ad]);
}
break; break;
case CLRA: case CLRA:
Regs[A] = 0; Regs[A] = 0;

View File

@ -129,14 +129,14 @@ namespace BizHawk.Emulation.Common.Components.I8048
public void BUS_PORT_OUT() public void BUS_PORT_OUT()
{ {
PopulateCURINSTR(IDLE, PopulateCURINSTR(IDLE,
IDLE, IDLE,
IDLE, IDLE,
IDLE, IDLE,
IDLE, IDLE,
IDLE, IDLE,
IDLE, IDLE,
IDLE, IDLE,
WR_P, 0, A); WR_P, 0, A);
IRQS = 9; IRQS = 9;
Console.WriteLine("OUT"); Console.WriteLine("OUT");

View File

@ -18,7 +18,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
public bool FrameAdvance(IController controller, bool render, bool rendersound) public bool FrameAdvance(IController controller, bool render, bool rendersound)
{ {
// Console.WriteLine("-----------------------FRAME-----------------------"); //Console.WriteLine("-----------------------FRAME-----------------------");
if (_tracer.Enabled) if (_tracer.Enabled)
{ {
@ -62,7 +62,6 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{ {
ppu.tick(); ppu.tick();
ppu.tick(); ppu.tick();
ppu.DMA_tick();
serialport.serial_transfer_tick(); serialport.serial_transfer_tick();
ppu.Audio_tick(); ppu.Audio_tick();
cpu.ExecuteOne(); cpu.ExecuteOne();
@ -80,10 +79,10 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{ {
ppu.tick(); ppu.tick();
ppu.tick(); ppu.tick();
ppu.DMA_tick();
serialport.serial_transfer_tick(); serialport.serial_transfer_tick();
ppu.Audio_tick(); ppu.Audio_tick();
cpu.ExecuteOne(); cpu.ExecuteOne();
} }
public void GetControllerState(IController controller) public void GetControllerState(IController controller)

View File

@ -43,6 +43,11 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
[DefaultValue(true)] [DefaultValue(true)]
public bool Show_Chars { get; set; } public bool Show_Chars { get; set; }
[DisplayName("Display Quad Characters")]
[Description("When true, displays quad character.")]
[DefaultValue(true)]
public bool Show_Quads { get; set; }
[DisplayName("Display Sprites")] [DisplayName("Display Sprites")]
[Description("When true, displays sprites.")] [Description("When true, displays sprites.")]
[DefaultValue(true)] [DefaultValue(true)]

View File

@ -1,4 +1,6 @@
using System; using System;
using System.Diagnostics.Eventing.Reader;
using System.Runtime.InteropServices;
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Common.NumberExtensions; using BizHawk.Common.NumberExtensions;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
@ -18,8 +20,11 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
public byte[] Grid_V = new byte[10]; public byte[] Grid_V = new byte[10];
public byte VDC_ctrl, VDC_status, VDC_collision, VDC_col_ret, VDC_color; public byte VDC_ctrl, VDC_status, VDC_collision, VDC_col_ret, VDC_color;
public byte Frame_Col, Pixel_Stat; public byte Pixel_Stat;
public int bg_brightness;
public int grid_fill;
public byte grid_fill_col;
public int LY; public int LY;
public int cycle; public int cycle;
public bool VBL; public bool VBL;
@ -126,6 +131,9 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
else if (addr == 0xA3) else if (addr == 0xA3)
{ {
VDC_color = value; VDC_color = value;
//Console.WriteLine("VDC_color: " + value + " " + Core.cpu.TotalExecutedCycles);
bg_brightness = VDC_color.Bit(6) ? 8 : 0;
//VDC_color |= 3;
} }
else if (addr == 0xA4) else if (addr == 0xA4)
{ {
@ -175,6 +183,21 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
if (LY < 240) if (LY < 240)
{ {
// background // background
Core._vidbuffer[LY * 186 + (cycle - 43)] = (int)Color_Palette_BG[((VDC_color >> 3) & 0x7) + bg_brightness];
// grid
if (grid_fill > 0)
{
Core._vidbuffer[LY * 186 + (cycle - 43)] = (int)Color_Palette_BG[(VDC_color & 0x7) + bg_brightness];
Pixel_Stat |= grid_fill_col;
grid_fill--;
}
if (VDC_ctrl.Bit(6))
{
}
if ((((cycle - 43) % 16) == 8) && ((LY - 24) >= 0)) if ((((cycle - 43) % 16) == 8) && ((LY - 24) >= 0))
{ {
int k = (int)Math.Floor((cycle - 43) / 16.0); int k = (int)Math.Floor((cycle - 43) / 16.0);
@ -183,8 +206,11 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{ {
if (Grid_V[k].Bit(j)) if (Grid_V[k].Bit(j))
{ {
Core._vidbuffer[LY * 186 + (cycle - 43)] = (int)Color_Palette_BG[VDC_color & 0x7]; Core._vidbuffer[LY * 186 + (cycle - 43)] = (int)Color_Palette_BG[(VDC_color & 0x7) + bg_brightness];
Pixel_Stat |= 0x10; Pixel_Stat |= 0x10;
if (VDC_ctrl.Bit(7)) { grid_fill = 15; }
else { grid_fill = 1; }
grid_fill_col = 0x10;
} }
} }
} }
@ -200,50 +226,24 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{ {
if (Grid_H[k + 9].Bit(0)) if (Grid_H[k + 9].Bit(0))
{ {
Core._vidbuffer[LY * 186 + (cycle - 43)] = (int)Color_Palette_BG[VDC_color & 0x7]; Core._vidbuffer[LY * 186 + (cycle - 43)] = (int)Color_Palette_BG[(VDC_color & 0x7) + bg_brightness];
Pixel_Stat |= 0x20; Pixel_Stat |= 0x20;
if (((cycle - 43 - 8) % 16) == 15) { grid_fill = 2; grid_fill_col = 0x20; }
} }
} }
else else
{ {
if (Grid_H[k].Bit(j)) if (Grid_H[k].Bit(j))
{ {
Core._vidbuffer[LY * 186 + (cycle - 43)] = (int)Color_Palette_BG[VDC_color & 0x7]; Core._vidbuffer[LY * 186 + (cycle - 43)] = (int)Color_Palette_BG[(VDC_color & 0x7) + bg_brightness];
Pixel_Stat |= 0x20; Pixel_Stat |= 0x20;
} if (((cycle - 43 - 8) % 16) == 15) { grid_fill = 2; grid_fill_col = 0x20; }
}
}
}
// sprites
for (int i = 3; i >= 0; i--)
{
int double_size = Sprites[i * 4 + 2].Bit(2) ? 4 : 2;
if ((LY >= Sprites[i * 4]) && (LY < (Sprites[i * 4] + 8 * double_size)))
{
if (((cycle - 43) >= Sprites[i * 4 + 1]) && ((cycle - 43) < (Sprites[i * 4 + 1] + 8 * (double_size / 2))))
{
// character is in drawing region, pick a pixel
int offset_y = (LY - Sprites[i * 4]) >> (double_size / 2);
int offset_x = ((cycle - 43) - Sprites[i * 4 + 1]) >> (double_size / 2 - 1);
int pixel_pick = (Sprite_Shapes[i * 8 + offset_y] >> offset_x) & 1;
if (pixel_pick == 1)
{
if (Core._settings.Show_Sprites)
{
Core._vidbuffer[LY * 186 + (cycle - 43)] = (int) Color_Palette_SPR[(Sprites[i * 4 + 2] >> 3) & 0x7];
}
Pixel_Stat |= (byte)(1 << i);
} }
} }
} }
} }
// single characters // single characters
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
{ {
@ -319,7 +319,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
if (char_pick < 0) if (char_pick < 0)
{ {
char_pick &= 0xFF; char_pick &= 0xFF;
char_pick |= (Quad_Chars[i * 16 + 4 * quad_num + 3] & 1) << 7; char_pick |= (Quad_Chars[i * 16 + 4 * quad_num + 3] & 1) << 8;
} }
else else
{ {
@ -332,7 +332,11 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
if (pixel_pick == 1) if (pixel_pick == 1)
{ {
Core._vidbuffer[LY * 186 + (cycle - 43)] = (int) Color_Palette_SPR[(Quad_Chars[i * 16 + 4 * quad_num + 3] >> 1) & 0x7]; if (Core._settings.Show_Quads)
{
Core._vidbuffer[LY * 186 + (cycle - 43)] = (int) Color_Palette_SPR[(Quad_Chars[i * 16 + 4 * quad_num + 3] >> 1) & 0x7];
}
Pixel_Stat |= 0x80; Pixel_Stat |= 0x80;
} }
} }
@ -340,6 +344,34 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
} }
} }
// sprites
for (int i = 3; i >= 0; i--)
{
int double_size = Sprites[i * 4 + 2].Bit(2) ? 4 : 2;
if ((LY >= Sprites[i * 4]) && (LY < (Sprites[i * 4] + 8 * double_size)))
{
if (((cycle - 43) >= Sprites[i * 4 + 1]) && ((cycle - 43) < (Sprites[i * 4 + 1] + 8 * (double_size / 2))))
{
// character is in drawing region, pick a pixel
int offset_y = (LY - Sprites[i * 4]) >> (double_size / 2);
int offset_x = ((cycle - 43) - Sprites[i * 4 + 1]) >> (double_size / 2 - 1);
int pixel_pick = (Sprite_Shapes[i * 8 + offset_y] >> offset_x) & 1;
if (pixel_pick == 1)
{
if (Core._settings.Show_Sprites)
{
Core._vidbuffer[LY * 186 + (cycle - 43)] = (int)Color_Palette_SPR[(Sprites[i * 4 + 2] >> 3) & 0x7];
}
Pixel_Stat |= (byte)(1 << i);
}
}
}
}
// calculate collision // calculate collision
int col_bit = 0; int col_bit = 0;
for (int i = 7; i >= 0; i--) for (int i = 7; i >= 0; i--)
@ -365,12 +397,10 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{ {
cycle = 0; cycle = 0;
HBL = true; HBL = true;
// send T1 pulses
Core.cpu.T1 = true;
LY++; LY++;
if (LY == 240) if (LY == 240)
{ {
VBL = true; VBL = true;
@ -388,8 +418,11 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
VBL = false; VBL = false;
VDC_col_ret = 0; VDC_col_ret = 0;
Core.in_vblank = false; Core.in_vblank = false;
if (!VDC_ctrl.Bit(0)) { Core.cpu.IRQPending = false; } }
Frame_Col = 0; if (LY < 240)
{
// send T1 pulses
Core.cpu.T1 = true;
} }
} }
} }
@ -400,28 +433,11 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
} }
public void render(int render_cycle)
{
}
public void process_sprite() public void process_sprite()
{ {
} }
// normal DMA moves twice as fast in double speed mode on GBC
// So give it it's own function so we can seperate it from PPU tick
public void DMA_tick()
{
}
public void OAM_scan(int OAM_cycle)
{
}
public void Reset() public void Reset()
{ {
AudioReset(); AudioReset();
@ -474,7 +490,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x18, 00, // Y 0x2C 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x18, 00, // Y 0x2C
0xC6, 0xE6, 0xF6, 0xFE, 0xDE, 0xCE, 0xC6, 00, // N 0x2D 0xC6, 0xE6, 0xF6, 0xFE, 0xDE, 0xCE, 0xC6, 00, // N 0x2D
0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 00, // / 0x2E 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 00, // / 0x2E
0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 00, // (box) 0x2F 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 00, // (box) 0x2F
0xCE, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xCE, 00, // 10 0x30 0xCE, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xCE, 00, // 10 0x30
0x00, 0x00, 0x3C, 0x7E, 0x7E, 0x7E, 0x3C, 00, // (ball) 0x31 0x00, 0x00, 0x3C, 0x7E, 0x7E, 0x7E, 0x3C, 00, // (ball) 0x31
0x38, 0x38, 0x30, 0x3C, 0x30, 0x30, 0x38, 00, // (person R) 0x32 0x38, 0x38, 0x30, 0x3C, 0x30, 0x30, 0x38, 00, // (person R) 0x32
@ -496,11 +512,11 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
public static readonly uint[] Color_Palette_SPR = public static readonly uint[] Color_Palette_SPR =
{ {
0xFF676767, // grey 0xFF676767, // grey
0xFF790000, // red
0xFF006D07, // green
0xFFC75151, // light red 0xFFC75151, // light red
0xFF1A37BE, // blue 0xFF56C469, // light green
0xFF94309F, // violet 0xFFC6B869, // light yellow
0xFF5C80F6, // light blue
0xFFDC84D4, // light violet
0xFFCECECE, // light grey 0xFFCECECE, // light grey
0xFFFFFFFF, // white 0xFFFFFFFF, // white
}; };
@ -510,19 +526,19 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
0xFF000000, // black 0xFF000000, // black
0xFF1A37BE, // blue 0xFF1A37BE, // blue
0xFF006D07, // green 0xFF006D07, // green
0xFF56C469, // light green 0xFF2AAABE, // blue-green
0xFF790000, // red 0xFF790000, // red
0xFF94309F, // violet 0xFF94309F, // violet
0xFFC75151, // light red 0xFF77670B, // yellow
0xFF676767, // grey 0xFF676767, // grey
0xFF000000, // black
0xFF5C80F6, // light blue
0xFF56C469, // light green
0xFF77E6EB, // light blue-green
0xFFC75151, // light red
0xFFDC84D4, // light violet
0xFFC6B869, // light yellow 0xFFC6B869, // light yellow
0xFFCECECE, // light grey 0xFFCECECE, // light grey
0xFF2AAABE, // blue-green
0xFF77E6EB, // light blue-green
0xFF5C80F6, // light blue
0xFFDC84D4, // light violet
0xFF77670B, // yellow
0xFFFFFFFF, // white
}; };
@ -540,9 +556,11 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
ser.Sync(nameof(VDC_collision), ref VDC_collision); ser.Sync(nameof(VDC_collision), ref VDC_collision);
ser.Sync(nameof(VDC_col_ret), ref VDC_col_ret); ser.Sync(nameof(VDC_col_ret), ref VDC_col_ret);
ser.Sync(nameof(VDC_color), ref VDC_color); ser.Sync(nameof(VDC_color), ref VDC_color);
ser.Sync(nameof(Frame_Col), ref Frame_Col);
ser.Sync(nameof(Pixel_Stat), ref Pixel_Stat); ser.Sync(nameof(Pixel_Stat), ref Pixel_Stat);
ser.Sync(nameof(bg_brightness), ref bg_brightness);
ser.Sync(nameof(grid_fill), ref grid_fill);
ser.Sync(nameof(grid_fill_col), ref grid_fill_col);
ser.Sync(nameof(LY), ref LY); ser.Sync(nameof(LY), ref LY);
ser.Sync(nameof(cycle), ref cycle); ser.Sync(nameof(cycle), ref cycle);
ser.Sync(nameof(VBL), ref VBL); ser.Sync(nameof(VBL), ref VBL);

View File

@ -190,8 +190,10 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=automagically/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=automagically/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=autorestore/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=autorestore/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Autosave/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Autosave/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=backbuffer/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=backcolor/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=backcolor/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bezier/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Bezier/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=bicubic/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=bilinear/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=bilinear/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bizware/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Bizware/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=blitter/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=blitter/@EntryIndexedValue">True</s:Boolean>
@ -216,6 +218,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dega/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Dega/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=delaminated/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=delaminated/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dendy/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Dendy/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=desmume/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=desync/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=desync/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dipswitch/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Dipswitch/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Disasm/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Disasm/@EntryIndexedValue">True</s:Boolean>
@ -242,6 +245,8 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Frameskip/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Frameskip/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Frameskipping/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Frameskipping/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=framestart/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=framestart/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Frugalizer/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Frugalizers/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=gambatte/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=gambatte/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gameboy/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Gameboy/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=gamedb/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=gamedb/@EntryIndexedValue">True</s:Boolean>
@ -261,6 +266,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=ints/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=ints/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=INTV/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=INTV/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Joypad/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Joypad/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=jumplist/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Justifier/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Justifier/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=keepalives/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=keepalives/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=KEYMENU/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=KEYMENU/@EntryIndexedValue">True</s:Boolean>
@ -311,6 +317,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Prefs/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Prefs/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=preload/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=preload/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Prereqs/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Prereqs/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=prescale/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=quickload/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=quickload/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=quicknes/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=quicknes/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=quicksave/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=quicksave/@EntryIndexedValue">True</s:Boolean>
@ -318,6 +325,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=regs/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=regs/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=resizer/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=resizer/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Rewinder/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Rewinder/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Roms/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=samp/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=samp/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Saturnus/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Saturnus/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=saveram/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=saveram/@EntryIndexedValue">True</s:Boolean>
@ -361,6 +369,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unregister/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Unregister/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unthrottle/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Unthrottle/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unthrottled/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Unthrottled/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Untransform/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=vals/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=vals/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Vectrex/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Vectrex/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Virtua/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Virtua/@EntryIndexedValue">True</s:Boolean>