diff --git a/BizHawk.Client.EmuHawk/MainForm.Designer.cs b/BizHawk.Client.EmuHawk/MainForm.Designer.cs index 31c1a0b0cb..61cca7e7df 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Designer.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Designer.cs @@ -357,6 +357,10 @@ this.C64SettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.IntvSubMenu = new System.Windows.Forms.ToolStripMenuItem(); this.IntVControllerSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.sNESToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.preferencesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.virtualBoyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.preferencesToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.HelpSubMenu = new System.Windows.Forms.ToolStripMenuItem(); this.OnlineHelpMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ForumsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -436,8 +440,6 @@ this.ShowMenuContextMenuSeparator = new System.Windows.Forms.ToolStripSeparator(); this.ShowMenuContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.timerMouseIdle = new System.Windows.Forms.Timer(this.components); - this.sNESToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.preferencesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.MainformMenu.SuspendLayout(); this.MainStatusBar.SuspendLayout(); this.MainFormContextMenu.SuspendLayout(); @@ -470,8 +472,9 @@ this.AppleSubMenu, this.C64SubMenu, this.IntvSubMenu, - this.HelpSubMenu, - this.sNESToolStripMenuItem}); + this.sNESToolStripMenuItem, + this.virtualBoyToolStripMenuItem, + this.HelpSubMenu}); this.MainformMenu.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow; this.MainformMenu.Location = new System.Drawing.Point(0, 0); this.MainformMenu.Name = "MainformMenu"; @@ -2720,7 +2723,7 @@ this.GBAmGBAMenuItem, this.GBAVBANextMenuItem}); this.GBACoreSelectionSubMenu.Name = "GBACoreSelectionSubMenu"; - this.GBACoreSelectionSubMenu.Size = new System.Drawing.Size(152, 22); + this.GBACoreSelectionSubMenu.Size = new System.Drawing.Size(129, 22); this.GBACoreSelectionSubMenu.Text = "&Core"; this.GBACoreSelectionSubMenu.DropDownOpened += new System.EventHandler(this.GBACoreSelectionSubMenu_DropDownOpened); // @@ -2741,19 +2744,19 @@ // GBAcoresettingsToolStripMenuItem1 // this.GBAcoresettingsToolStripMenuItem1.Name = "GBAcoresettingsToolStripMenuItem1"; - this.GBAcoresettingsToolStripMenuItem1.Size = new System.Drawing.Size(152, 22); + this.GBAcoresettingsToolStripMenuItem1.Size = new System.Drawing.Size(129, 22); this.GBAcoresettingsToolStripMenuItem1.Text = "&Settings..."; this.GBAcoresettingsToolStripMenuItem1.Click += new System.EventHandler(this.GBAcoresettingsToolStripMenuItem1_Click); // // toolStripSeparator33 // this.toolStripSeparator33.Name = "toolStripSeparator33"; - this.toolStripSeparator33.Size = new System.Drawing.Size(149, 6); + this.toolStripSeparator33.Size = new System.Drawing.Size(126, 6); // // GbaGpuViewerMenuItem // this.GbaGpuViewerMenuItem.Name = "GbaGpuViewerMenuItem"; - this.GbaGpuViewerMenuItem.Size = new System.Drawing.Size(152, 22); + this.GbaGpuViewerMenuItem.Size = new System.Drawing.Size(129, 22); this.GbaGpuViewerMenuItem.Text = "GPU Viewer"; this.GbaGpuViewerMenuItem.Click += new System.EventHandler(this.GbaGpuViewerMenuItem_Click); // @@ -3025,7 +3028,7 @@ // SaturnPreferencesMenuItem // this.SaturnPreferencesMenuItem.Name = "SaturnPreferencesMenuItem"; - this.SaturnPreferencesMenuItem.Size = new System.Drawing.Size(152, 22); + this.SaturnPreferencesMenuItem.Size = new System.Drawing.Size(144, 22); this.SaturnPreferencesMenuItem.Text = "Preferences..."; this.SaturnPreferencesMenuItem.Click += new System.EventHandler(this.SaturnPreferencesMenuItem_Click); // @@ -3174,6 +3177,36 @@ this.IntVControllerSettingsMenuItem.Text = "Controller Settings..."; this.IntVControllerSettingsMenuItem.Click += new System.EventHandler(this.IntVControllerSettingsMenuItem_Click); // + // sNESToolStripMenuItem + // + this.sNESToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.preferencesToolStripMenuItem}); + this.sNESToolStripMenuItem.Name = "sNESToolStripMenuItem"; + this.sNESToolStripMenuItem.Size = new System.Drawing.Size(44, 17); + this.sNESToolStripMenuItem.Text = "&SNES"; + // + // preferencesToolStripMenuItem + // + this.preferencesToolStripMenuItem.Name = "preferencesToolStripMenuItem"; + this.preferencesToolStripMenuItem.Size = new System.Drawing.Size(144, 22); + this.preferencesToolStripMenuItem.Text = "Preferences..."; + this.preferencesToolStripMenuItem.Click += new System.EventHandler(this.preferencesToolStripMenuItem_Click); + // + // virtualBoyToolStripMenuItem + // + this.virtualBoyToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.preferencesToolStripMenuItem1}); + this.virtualBoyToolStripMenuItem.Name = "virtualBoyToolStripMenuItem"; + this.virtualBoyToolStripMenuItem.Size = new System.Drawing.Size(67, 17); + this.virtualBoyToolStripMenuItem.Text = "&VirtualBoy"; + // + // preferencesToolStripMenuItem1 + // + this.preferencesToolStripMenuItem1.Name = "preferencesToolStripMenuItem1"; + this.preferencesToolStripMenuItem1.Size = new System.Drawing.Size(152, 22); + this.preferencesToolStripMenuItem1.Text = "Preferences..."; + this.preferencesToolStripMenuItem1.Click += new System.EventHandler(this.preferencesToolStripMenuItem1_Click); + // // HelpSubMenu // this.HelpSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -3190,7 +3223,7 @@ // this.OnlineHelpMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Help; this.OnlineHelpMenuItem.Name = "OnlineHelpMenuItem"; - this.OnlineHelpMenuItem.Size = new System.Drawing.Size(152, 22); + this.OnlineHelpMenuItem.Size = new System.Drawing.Size(140, 22); this.OnlineHelpMenuItem.Text = "&Online Help..."; this.OnlineHelpMenuItem.Click += new System.EventHandler(this.OnlineHelpMenuItem_Click); // @@ -3198,7 +3231,7 @@ // this.ForumsMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.TAStudio; this.ForumsMenuItem.Name = "ForumsMenuItem"; - this.ForumsMenuItem.Size = new System.Drawing.Size(152, 22); + this.ForumsMenuItem.Size = new System.Drawing.Size(140, 22); this.ForumsMenuItem.Text = "Forums..."; this.ForumsMenuItem.Click += new System.EventHandler(this.ForumsMenuItem_Click); // @@ -3206,7 +3239,7 @@ // this.FeaturesMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.kitchensink; this.FeaturesMenuItem.Name = "FeaturesMenuItem"; - this.FeaturesMenuItem.Size = new System.Drawing.Size(152, 22); + this.FeaturesMenuItem.Size = new System.Drawing.Size(140, 22); this.FeaturesMenuItem.Text = "&Features"; this.FeaturesMenuItem.Click += new System.EventHandler(this.FeaturesMenuItem_Click); // @@ -3214,7 +3247,7 @@ // this.AboutMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.CorpHawkSmall; this.AboutMenuItem.Name = "AboutMenuItem"; - this.AboutMenuItem.Size = new System.Drawing.Size(152, 22); + this.AboutMenuItem.Size = new System.Drawing.Size(140, 22); this.AboutMenuItem.Text = "&About"; this.AboutMenuItem.Click += new System.EventHandler(this.AboutMenuItem_Click); // @@ -3863,21 +3896,6 @@ this.timerMouseIdle.Interval = 2000; this.timerMouseIdle.Tick += new System.EventHandler(this.timerMouseIdle_Tick); // - // sNESToolStripMenuItem - // - this.sNESToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.preferencesToolStripMenuItem}); - this.sNESToolStripMenuItem.Name = "sNESToolStripMenuItem"; - this.sNESToolStripMenuItem.Size = new System.Drawing.Size(44, 17); - this.sNESToolStripMenuItem.Text = "&SNES"; - // - // preferencesToolStripMenuItem - // - this.preferencesToolStripMenuItem.Name = "preferencesToolStripMenuItem"; - this.preferencesToolStripMenuItem.Size = new System.Drawing.Size(152, 22); - this.preferencesToolStripMenuItem.Text = "Preferences..."; - this.preferencesToolStripMenuItem.Click += new System.EventHandler(this.preferencesToolStripMenuItem_Click); - // // MainForm // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; @@ -4327,5 +4345,7 @@ private System.Windows.Forms.ToolStripSeparator toolStripSeparator36; private System.Windows.Forms.ToolStripMenuItem sNESToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem preferencesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem virtualBoyToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem preferencesToolStripMenuItem1; } } diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 49ac649b77..6254823ef4 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -1676,6 +1676,7 @@ namespace BizHawk.Client.EmuHawk C64SubMenu.Visible = false; IntvSubMenu.Visible = false; sNESToolStripMenuItem.Visible = false; + virtualBoyToolStripMenuItem.Visible = false; switch (system) { @@ -1761,6 +1762,9 @@ namespace BizHawk.Client.EmuHawk case "INTV": IntvSubMenu.Visible = true; break; + case "VB": + virtualBoyToolStripMenuItem.Visible = true; + break; } } @@ -4275,6 +4279,11 @@ namespace BizHawk.Client.EmuHawk GenericCoreConfig.DoDialog(this, "Snes9x settings"); } + private void preferencesToolStripMenuItem1_Click(object sender, EventArgs e) + { + GenericCoreConfig.DoDialog(this, "VirtualBoy Settings"); + } + private void CreateMultigameFileMenuItem_Click(object sender, EventArgs e) { GlobalWin.Tools.Load(); diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index f84c59f64e..236ff7cce9 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -118,6 +118,7 @@ ..\References\PeNet.dll + 3.5 diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/LibVirtualBoyee.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/LibVirtualBoyee.cs index d41b77ec6e..5a5b3d9341 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/LibVirtualBoyee.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/LibVirtualBoyee.cs @@ -1,6 +1,7 @@ using BizHawk.Common.BizInvoke; using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; @@ -87,11 +88,53 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB R = 0x4 } + [StructLayout(LayoutKind.Sequential)] + public class NativeSettings + { + public int InstantReadHack; + public int DisableParallax; + public int ThreeDeeMode; + public int SwapViews; + public int AnaglyphPreset; + public int AnaglyphCustomLeftColor; + public int AnaglyphCustomRightColor; + public int NonAnaglyphColor; + public int LedOnScale; + public int InterlacePrescale; + public int SideBySideSeparation; + + private static int ConvertColor(Color c) + { + var v = c.ToArgb(); + return v & 0xff00 + | v << 16 & 0xff0000 + | v >> 16 & 0xff; + } + + public static NativeSettings FromFrontendSettings(VirtualBoyee.Settings s, VirtualBoyee.SyncSettings ss) + { + return new NativeSettings + { + InstantReadHack = ss.InstantReadHack ? 1 : 0, + DisableParallax = ss.DisableParallax ? 1 : 0, + ThreeDeeMode = (int)s.ThreeDeeMode, + SwapViews = s.SwapViews ? 1 : 0, + AnaglyphPreset = (int)s.AnaglyphPreset, + AnaglyphCustomLeftColor = ConvertColor(s.AnaglyphCustomLeftColor), + AnaglyphCustomRightColor = ConvertColor(s.AnaglyphCustomRightColor), + NonAnaglyphColor = ConvertColor(s.NonAnaglyphColor), + LedOnScale = s.LedOnScale, + InterlacePrescale = s.InterlacePrescale, + SideBySideSeparation = s.SideBySideSeparation + }; + } + } + [UnmanagedFunctionPointer(CC)] public delegate void InputCallback(); [BizImport(CC)] - public abstract bool Load(byte[] rom, int length); + public abstract bool Load(byte[] rom, int length, [In]NativeSettings settings); [BizImport(CC)] public abstract void GetMemoryArea(MemoryArea which, ref IntPtr ptr, ref int size); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs index 10a3a21d6b..41cbdcf5be 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs @@ -5,6 +5,9 @@ using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Waterbox; using System; using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Drawing; using System.IO; using System.Linq; using System.Runtime.InteropServices; @@ -16,17 +19,21 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB [CoreAttributes("Virtual Boyee", "???", true, false, "0.9.44.1", "https://mednafen.github.io/releases/", false)] public class VirtualBoyee : IEmulator, IVideoProvider, ISoundProvider, IStatable, - IInputPollable, ISaveRam + IInputPollable, ISaveRam, ISettable { private PeRunner _exe; private LibVirtualBoyee _boyee; [CoreConstructor("VB")] - public VirtualBoyee(CoreComm comm, byte[] rom) + public VirtualBoyee(CoreComm comm, byte[] rom, Settings settings, SyncSettings syncSettings) { ServiceProvider = new BasicServiceProvider(this); CoreComm = comm; + _settings = settings ?? new Settings(); + _syncSettings = syncSettings ?? new SyncSettings(); + var nativeSettings = LibVirtualBoyee.NativeSettings.FromFrontendSettings(_settings, _syncSettings); + _exe = new PeRunner(new PeRunnerOptions { Path = comm.CoreFileProvider.DllPath(), @@ -39,7 +46,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB _boyee = BizInvoker.GetInvoker(_exe, _exe); - if (!_boyee.Load(rom, rom.Length)) + if (!_boyee.Load(rom, rom.Length, nativeSettings)) { throw new InvalidOperationException("Core rejected the rom"); } @@ -48,6 +55,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB _inputCallback = InputCallbacks.Call; InitMemoryDomains(); + InitSaveram(); } private bool _disposed = false; @@ -288,6 +296,130 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB (ServiceProvider as BasicServiceProvider).Register(new MemoryDomainList(domains)); } + #endregion + + #region ISettable + + public class SyncSettings + { + [DefaultValue(false)] + public bool InstantReadHack { get; set; } + [DefaultValue(false)] + public bool DisableParallax { get; set; } + + public SyncSettings Clone() + { + return (SyncSettings)MemberwiseClone(); + } + + public static bool NeedsReboot(SyncSettings x, SyncSettings y) + { + return !DeepEquality.DeepEquals(x, y); + } + + public SyncSettings() + { + SettingsUtil.SetDefaultValues(this); + } + } + + public class Settings + { + public enum ThreeDeeModes : int + { + Anaglyph = 0, + CyberScope = 1, + SideBySide = 2, + //OverUnder, + VerticalInterlaced = 4, + HorizontalInterlaced = 5 + } + + [DefaultValue(ThreeDeeModes.Anaglyph)] + public ThreeDeeModes ThreeDeeMode { get; set; } + + [DefaultValue(false)] + public bool SwapViews { get; set; } + + public enum AnaglyphPresets : int + { + Custom, + RedBlue, + RedCyan, + RedElectricCyan, + RedGreen, + GreenMagneto, + YellowBlue + } + + [DefaultValue(AnaglyphPresets.RedBlue)] + public AnaglyphPresets AnaglyphPreset { get; set; } + + [DefaultValue(typeof(Color), "Green")] + public Color AnaglyphCustomLeftColor { get; set; } + [DefaultValue(typeof(Color), "Purple")] + public Color AnaglyphCustomRightColor { get; set; } + + [DefaultValue(typeof(Color), "White")] + public Color NonAnaglyphColor { get; set; } + + [DefaultValue(1750)] + [Range(1000, 2000)] + public int LedOnScale { get; set; } + + [DefaultValue(2)] + [Range(1, 10)] + public int InterlacePrescale { get; set; } + + [DefaultValue(0)] + [Range(0, 1024)] + public int SideBySideSeparation { get; set; } + + public Settings Clone() + { + return (Settings)MemberwiseClone(); + } + + public static bool NeedsReboot(Settings x, Settings y) + { + return !DeepEquality.DeepEquals(x, y); + } + + public Settings() + { + SettingsUtil.SetDefaultValues(this); + } + } + + private Settings _settings; + private SyncSettings _syncSettings; + + public Settings GetSettings() + { + return _settings.Clone(); + } + + public SyncSettings GetSyncSettings() + { + return _syncSettings.Clone(); + } + + public bool PutSettings(Settings o) + { + var ret = Settings.NeedsReboot(_settings, o); + _settings = o; + return ret; + } + + public bool PutSyncSettings(SyncSettings o) + { + var ret = SyncSettings.NeedsReboot(_syncSettings, o); + _syncSettings = o; + return ret; + } + + + #endregion #region ISaveRam diff --git a/output64/dll/vb.wbx b/output64/dll/vb.wbx index 34b3f7d413..c0b40a17fd 100644 Binary files a/output64/dll/vb.wbx and b/output64/dll/vb.wbx differ diff --git a/waterbox/vb/vb.cpp b/waterbox/vb/vb.cpp index 8e79dc7671..5c8a46fdcf 100644 --- a/waterbox/vb/vb.cpp +++ b/waterbox/vb/vb.cpp @@ -25,6 +25,21 @@ namespace MDFN_IEN_VB { +struct NativeSettings +{ + int InstantReadHack; + int DisableParallax; + int ThreeDeeMode; + int SwapViews; + int AnaglyphPreset; + int AnaglyphCustomLeftColor; + int AnaglyphCustomRightColor; + int NonAnaglyphColor; + int LedOnScale; + int InterlacePrescale; + int SideBySideSeparation; +}; + static void (*input_callback)(); static bool lagged; @@ -40,14 +55,14 @@ enum }; static const uint32 AnaglyphPreset_Colors[][2] = - { - {0, 0}, - {0xFF0000, 0x0000FF}, - {0xFF0000, 0x00B7EB}, - {0xFF0000, 0x00FFFF}, - {0xFF0000, 0x00FF00}, - {0x00FF00, 0xFF00FF}, - {0xFFFF00, 0x0000FF}, +{ + {0, 0}, + {0xFF0000, 0x0000FF}, + {0xFF0000, 0x00B7EB}, + {0xFF0000, 0x00FFFF}, + {0xFF0000, 0x00FF00}, + {0x00FF00, 0xFF00FF}, + {0xFFFF00, 0x0000FF}, }; int32 VB_InDebugPeek; @@ -538,7 +553,7 @@ void VB_ExitLoop(void) using namespace MDFN_IEN_VB; -EXPORT int Load(const uint8 *rom, int length) +EXPORT int Load(const uint8 *rom, int length, const NativeSettings* settings) { const uint64 rom_size = length; V810_Emu_Mode cpu_mode = V810_EMU_MODE_ACCURATE; @@ -648,19 +663,20 @@ EXPORT int Load(const uint8 *rom, int length) VB_VSU = new VSU(); VBINPUT_Init(); - VB3DMode = VB3DMODE_ANAGLYPH; - uint32 prescale = 2; - uint32 sbs_separation = 0; - bool reverse = false; + VB3DMode = settings->ThreeDeeMode; + uint32 prescale = settings->InterlacePrescale; + uint32 sbs_separation = settings->SideBySideSeparation; + bool reverse = settings->SwapViews; VIP_Set3DMode(VB3DMode, reverse, prescale, sbs_separation); - VIP_SetParallaxDisable(false); + VIP_SetParallaxDisable(settings->DisableParallax); { - auto presetColor = ANAGLYPH_PRESET_RED_BLUE; + auto presetColor = settings->AnaglyphPreset; - uint32 lcolor, rcolor; + uint32 lcolor = settings->AnaglyphCustomLeftColor; + uint32 rcolor = settings->AnaglyphCustomRightColor; if (presetColor != ANAGLYPH_PRESET_DISABLED) { @@ -668,12 +684,12 @@ EXPORT int Load(const uint8 *rom, int length) rcolor = AnaglyphPreset_Colors[presetColor][1]; } VIP_SetAnaglyphColors(lcolor, rcolor); - VIP_SetDefaultColor(0xf0f0f0); + VIP_SetDefaultColor(settings->NonAnaglyphColor); } - VBINPUT_SetInstantReadHack(true); + VBINPUT_SetInstantReadHack(settings->InstantReadHack); - VIP_SetLEDOnScale(1.75); + VIP_SetLEDOnScale(settings->LedOnScale / 1000.0); VB_Power();