biz side vb nyma

This commit is contained in:
CasualPokePlayer 2022-05-29 19:46:38 -07:00
parent 3b09f822b7
commit 583f0f61cc
6 changed files with 63 additions and 340 deletions

View File

@ -322,7 +322,7 @@ while sys == 'GB' or sys == 'GBC' do
end
while sys == 'VB' do
if movie.mode() == 'PLAY' then c = movie.getinput(emu.framecount() - 1)
if movie.mode() == 'PLAY' then c = movie.getinput(emu.framecount() - 1, 1)
else c = joypad.get() end
x = xpos

View File

@ -970,20 +970,20 @@
"Caps Lock": "CapsLock"
},
"VirtualBoy Controller": {
"L_Up": "Up, X1 DpadUp, X1 LStickUp",
"L_Down": "Down, X1 DpadDown, X1 LStickDown",
"L_Left": "Left, X1 DpadLeft, X1 LStickLeft",
"L_Right": "Right, X1 DpadRight, X1 LStickRight",
"R_Up": "Keypad8, X1 RStickUp",
"R_Down": "Keypad2, X1 RStickDown",
"R_Left": "Keypad4, X1 RStickLeft",
"R_Right": "Keypad6, X1 RStickRight",
"B": "Z, X1 X",
"A": "X, X1 A",
"R": "W, X1 LeftShoulder",
"L": "E, X1 RightShoulder",
"Select": "Space, X1 Back",
"Start": "Enter, X1 Start"
"P1 L_Up": "Up, X1 DpadUp, X1 LStickUp",
"P1 L_Down": "Down, X1 DpadDown, X1 LStickDown",
"P1 L_Left": "Left, X1 DpadLeft, X1 LStickLeft",
"P1 L_Right": "Right, X1 DpadRight, X1 LStickRight",
"P1 R_Up": "Keypad8, X1 RStickUp",
"P1 R_Down": "Keypad2, X1 RStickDown",
"P1 R_Left": "Keypad4, X1 RStickLeft",
"P1 R_Right": "Keypad6, X1 RStickRight",
"P1 B": "Z, X1 X",
"P1 A": "X, X1 A",
"P1 R": "W, X1 LeftShoulder",
"P1 L": "E, X1 RightShoulder",
"P1 Select": "Space, X1 Back",
"P1 Start": "Enter, X1 Start"
},
"NeoGeo Portable Controller": {
"P1 Up": "Up, X1 DpadUp, X1 LStickUp",

View File

@ -443,6 +443,8 @@ namespace BizHawk.Client.Common
["R_Down"] = 'd',
["R_Left"] = 'l',
["R_Right"] = 'r',
["Battery Voltage: Set Normal"] = '+',
["Battery Voltage: Set Low"] = '-',
},
[VSystemID.Raw.PCFX] = new()
{

View File

@ -1,96 +0,0 @@
using BizHawk.BizInvoke;
using BizHawk.Emulation.Cores.Waterbox;
using System.Drawing;
using System.Runtime.InteropServices;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
{
public abstract class LibVirtualBoyee : LibWaterboxCore
{
public enum Buttons : int
{
Up = 0x200,
Down = 0x100,
Left = 0x80,
Right = 0x40,
Select = 0x800,
Start = 0x400,
B = 0x2,
A = 0x1,
Up_R = 0x10,
Down_R = 0x200,
Left_R = 0x1000,
Right_R = 0x2000,
L = 0x8,
R = 0x4
}
[StructLayout(LayoutKind.Sequential)]
public new class FrameInfo : LibWaterboxCore.FrameInfo
{
public Buttons Buttons;
}
[StructLayout(LayoutKind.Sequential)]
public class NativeSyncSettings
{
public int InstantReadHack;
public int DisableParallax;
public static NativeSyncSettings FromFrontendSettings(VirtualBoyee.SyncSettings ss)
{
return new NativeSyncSettings
{
InstantReadHack = ss.InstantReadHack ? 1 : 0,
DisableParallax = ss.DisableParallax ? 1 : 0,
};
}
}
public class NativeSettings
{
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)
{
return c.ToArgb();
}
public static NativeSettings FromFrontendSettings(VirtualBoyee.Settings s)
{
return new NativeSettings
{
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
};
}
}
[BizImport(CC)]
public abstract bool Load(byte[] rom, int length, NativeSyncSettings settings);
[BizImport(CC)]
public abstract void SetSettings(NativeSettings settings);
[BizImport(CC)]
public abstract void HardReset();
[BizImport(CC)]
public abstract void PredictFrameSize([In, Out]FrameInfo frame);
}
}

View File

@ -1,247 +1,45 @@
using BizHawk.Common;
using System.Collections.Generic;
using System.IO;
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.Linq;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
{
[PortedCore(CoreNames.VirtualBoyee, "Mednafen Team", portedUrl: "https://mednafen.github.io/releases/")]
public class VirtualBoyee : WaterboxCore, ISettable<VirtualBoyee.Settings, VirtualBoyee.SyncSettings>
[PortedCore(CoreNames.VirtualBoyee, "Mednafen Team", "1.29.0", "https://mednafen.github.io/releases/")]
public class VirtualBoyee : NymaCore
{
private readonly LibVirtualBoyee _boyee;
[CoreConstructor(VSystemID.Raw.VB)]
public VirtualBoyee(CoreComm comm, byte[] rom, Settings settings, SyncSettings syncSettings)
: base(comm, new Configuration
{
DefaultFpsNumerator = 20000000,
DefaultFpsDenominator = 397824,
DefaultWidth = 384,
DefaultHeight = 224,
MaxWidth = 1024,
MaxHeight = 1024,
MaxSamples = 8192,
SystemId = VSystemID.Raw.VB,
})
public VirtualBoyee(CoreLoadParameters<NymaSettings, NymaSyncSettings> lp)
: base(lp.Comm, VSystemID.Raw.VB, "VirtualBoy Controller", lp.Settings, lp.SyncSettings)
{
_settings = settings ?? new Settings();
_syncSettings = syncSettings ?? new SyncSettings();
_boyee = PreInit<LibVirtualBoyee>(new WaterboxOptions
{
Filename = "vb.wbx",
SbrkHeapSizeKB = 256,
SealedHeapSizeKB = 4 * 1024,
InvisibleHeapSizeKB = 256,
PlainHeapSizeKB = 256,
SkipCoreConsistencyCheck = comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxCoreConsistencyCheck),
SkipMemoryConsistencyCheck = comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxMemoryConsistencyCheck),
});
if (!_boyee.Load(rom, rom.Length, LibVirtualBoyee.NativeSyncSettings.FromFrontendSettings(_syncSettings)))
throw new InvalidOperationException("Core rejected the rom");
// do a quick hack up for frame zero size
var tmp = new LibVirtualBoyee.FrameInfo();
_boyee.PredictFrameSize(tmp);
BufferWidth = tmp.Width;
BufferHeight = tmp.Height;
PostInit();
_boyee.SetSettings(LibVirtualBoyee.NativeSettings.FromFrontendSettings(_settings));
DoInit<LibNymaCore>(lp, "vb.wbx");
}
protected override LibWaterboxCore.FrameInfo FrameAdvancePrep(IController controller, bool render, bool rendersound)
protected override IDictionary<string, SettingOverride> SettingOverrides { get; } = new Dictionary<string, SettingOverride>
{
if (controller.IsPressed("Power"))
_boyee.HardReset();
{ "vb.cpu_emulation", new() { Default = "accurate" } },
{ "vb.input.instant_read_hack", new() { Default = "0" } },
return new LibVirtualBoyee.FrameInfo { Buttons = GetButtons(controller) };
}
{ "vb.3dmode", new() { NonSync = true/*, NoRestart = true*/ } }, // fixme: a restart shouldn't be needed, yet upstream doesn't allow that?
{ "vb.3dreverse", new() { NonSync = true } },
{ "vb.anaglyph.lcolor", new() { NonSync = true, NoRestart = true } },
{ "vb.anaglyph.preset", new() { NonSync = true, NoRestart = true } },
{ "vb.anaglyph.rcolor", new() { NonSync = true, NoRestart = true } },
{ "vb.default_color", new() { NonSync = true, NoRestart = true } },
{ "vb.instant_display_hack", new() { NonSync = true, NoRestart = true } },
{ "vb.ledonscale", new() { NonSync = true, NoRestart = true } },
{ "vb.liprescale", new() { NonSync = true } },
{ "vb.sidebyside.separation", new() { NonSync = true } },
private LibVirtualBoyee.Buttons GetButtons(IController c)
{
var ret = 0;
var val = 1;
foreach (var s in CoreButtons)
{
if (c.IsPressed(s))
ret |= val;
val <<= 1;
}
return (LibVirtualBoyee.Buttons)ret;
}
private static readonly string[] CoreButtons =
{
"A", "B", "R", "L",
"R_Up", "R_Right",
"L_Right", "L_Left", "L_Down", "L_Up",
"Start", "Select", "R_Left", "R_Down"
{ "nyma.rtcinitialtime", new() { Hide = true } },
{ "nyma.rtcrealtime", new() { Hide = true } },
};
private static readonly Dictionary<string, int> _buttonOrdinals = new Dictionary<string, int>
{
["L_Up"] = 1,
["L_Down"] = 2,
["L_Left"] = 3,
["L_Right"] = 4,
["R_Up"] = 5,
["R_Down"] = 6,
["R_Left"] = 7,
["R_Right"] = 8,
["B"] = 9,
["A"] = 10,
["L"] = 11,
["R"] = 12,
["Select"] = 13,
["Start"] = 14
};
// needed if 3d mode changes can happen mid-emulation
private static readonly ControllerDefinition VirtualBoyController = new ControllerDefinition("VirtualBoy Controller")
{
BoolButtons = CoreButtons
.OrderBy(b => _buttonOrdinals[b])
.Concat(new[] { "Power" })
.ToList()
}.MakeImmutable();
/*public override int VirtualHeight => BufferHeight;
public override ControllerDefinition ControllerDefinition => VirtualBoyController;
public class SyncSettings
{
[DefaultValue(false)]
[Description("Reduce input latency. Works with all known commercial games, may have homebrew issues.")]
public bool InstantReadHack { get; set; }
[DefaultValue(false)]
[Description("Disable parallax for rendering.")]
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,
OnlyLeft = 6,
OnlyRight = 7
}
[DefaultValue(ThreeDeeModes.Anaglyph)]
[Description("How to display the 3d image. Use whichever method works with your VR hardware.")]
public ThreeDeeModes ThreeDeeMode { get; set; }
[DefaultValue(false)]
[Description("Swap the left and right views.")]
public bool SwapViews { get; set; }
public enum AnaglyphPresets : int
{
Custom,
RedBlue,
RedCyan,
RedElectricCyan,
RedGreen,
GreenMagneto,
YellowBlue
}
[DefaultValue(AnaglyphPresets.RedBlue)]
[Description("Color preset for Anaglyph mode.")]
public AnaglyphPresets AnaglyphPreset { get; set; }
[DefaultValue(typeof(Color), "Green")]
[Description("Left anaglyph color. Ignored unless Preset is Custom.")]
public Color AnaglyphCustomLeftColor { get; set; }
[DefaultValue(typeof(Color), "Purple")]
[Description("Right anaglyph color. Ignored unless Preset is Custom.")]
public Color AnaglyphCustomRightColor { get; set; }
[DefaultValue(typeof(Color), "White")]
[Description("Display color for all of the non-anaglyph modes. Real hardware was red, but other colors may be easier on your eyes.")]
public Color NonAnaglyphColor { get; set; }
[DefaultValue(1750)]
[Range(1000, 2000)]
[Description("LED gamma ramp. Range of 1000 to 2000")]
public int LedOnScale { get; set; }
[DefaultValue(2)]
[Range(1, 10)]
public int InterlacePrescale { get; set; }
[DefaultValue(0)]
[Range(0, 1024)]
[Description("How many pixels to put between views in Side By Side mode")]
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 PutSettingsDirtyBits PutSettings(Settings o)
{
var ret = Settings.NeedsReboot(_settings, o);
_settings = o;
return ret ? PutSettingsDirtyBits.RebootCore : PutSettingsDirtyBits.None;
}
public PutSettingsDirtyBits PutSyncSettings(SyncSettings o)
{
var ret = SyncSettings.NeedsReboot(_syncSettings, o);
_syncSettings = o;
return ret ? PutSettingsDirtyBits.RebootCore : PutSettingsDirtyBits.None;
}
public override int VirtualWidth => BufferWidth;*/
}
}

View File

@ -13,7 +13,20 @@ namespace BizHawk.Emulation.Cores.Waterbox
private static readonly Dictionary<string, string> ButtonNameOverrides = new Dictionary<string, string>
{
["Left Shoulder"] = "L",
["Right Shoulder"] = "R"
["Right Shoulder"] = "R",
["Left-Back"] = "L",
["Right-Back"] = "R",
// VB specific hack
// needed like this as otherwise left and right dpads have the same
["UP ↑ (Left D-Pad)"] = "L_Up",
["DOWN ↓ (Left D-Pad)"] = "L_Down",
["LEFT ← (Left D-Pad)"] = "L_Left",
["RIGHT → (Left D-Pad)"] = "L_Right",
["UP ↑ (Right D-Pad)"] = "R_Up",
["DOWN ↓ (Right D-Pad)"] = "R_Down",
["LEFT ← (Right D-Pad)"] = "R_Left",
["RIGHT → (Right D-Pad)"] = "R_Right",
};
/// <summary>
@ -22,6 +35,12 @@ namespace BizHawk.Emulation.Cores.Waterbox
/// </summary>
private string OverrideButtonName(string original)
{
// VB hack
if (ButtonNameOverrides.ContainsKey(original))
{
original = ButtonNameOverrides[original];
}
original = Regex.Replace(original, @"\s*(↑|↓|←|→)\s*", "");
original = Regex.Replace(original, @"\s*\([^\)]+\)\s*", "");
if (!IsRomanNumeral(original))