virtual boyee: make frame 0 size match other frame sizes
This commit is contained in:
parent
9ad4c32b73
commit
db73b7f275
|
@ -81,5 +81,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
|
||||||
|
|
||||||
[BizImport(CC)]
|
[BizImport(CC)]
|
||||||
public abstract void HardReset();
|
public abstract void HardReset();
|
||||||
|
|
||||||
|
[BizImport(CC)]
|
||||||
|
public abstract void PredictFrameSize([In, Out]FrameInfo frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
using BizHawk.Common;
|
using BizHawk.Common;
|
||||||
using BizHawk.Common.BizInvoke;
|
using BizHawk.Common.BizInvoke;
|
||||||
using BizHawk.Common.BufferExtensions;
|
using BizHawk.Common.BufferExtensions;
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
using BizHawk.Emulation.Cores.Waterbox;
|
using BizHawk.Emulation.Cores.Waterbox;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
|
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
|
||||||
{
|
{
|
||||||
[CoreAttributes("Virtual Boyee", "Ryphecha", true, true, "0.9.44.1",
|
[CoreAttributes("Virtual Boyee", "Ryphecha", true, true, "0.9.44.1",
|
||||||
"https://mednafen.github.io/releases/", false)]
|
"https://mednafen.github.io/releases/", false)]
|
||||||
public class VirtualBoyee : WaterboxCore, ISettable<VirtualBoyee.Settings, VirtualBoyee.SyncSettings>
|
public class VirtualBoyee : WaterboxCore, ISettable<VirtualBoyee.Settings, VirtualBoyee.SyncSettings>
|
||||||
{
|
{
|
||||||
private LibVirtualBoyee _boyee;
|
private LibVirtualBoyee _boyee;
|
||||||
|
|
||||||
[CoreConstructor("VB")]
|
[CoreConstructor("VB")]
|
||||||
public VirtualBoyee(CoreComm comm, byte[] rom, Settings settings, SyncSettings syncSettings)
|
public VirtualBoyee(CoreComm comm, byte[] rom, Settings settings, SyncSettings syncSettings)
|
||||||
:base(comm, new Configuration
|
:base(comm, new Configuration
|
||||||
{
|
{
|
||||||
DefaultFpsNumerator = 20000000,
|
DefaultFpsNumerator = 20000000,
|
||||||
|
@ -34,220 +34,226 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
|
||||||
MaxHeight = 1024,
|
MaxHeight = 1024,
|
||||||
MaxSamples = 8192,
|
MaxSamples = 8192,
|
||||||
SystemId = "VB"
|
SystemId = "VB"
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
_settings = settings ?? new Settings();
|
_settings = settings ?? new Settings();
|
||||||
_syncSettings = syncSettings ?? new SyncSettings();
|
_syncSettings = syncSettings ?? new SyncSettings();
|
||||||
// TODO: the way settings work in this core, changing the non-sync ones will invalidate savestates
|
// TODO: the way settings work in this core, changing the non-sync ones will invalidate savestates
|
||||||
var nativeSettings = LibVirtualBoyee.NativeSettings.FromFrontendSettings(_settings, _syncSettings);
|
var nativeSettings = LibVirtualBoyee.NativeSettings.FromFrontendSettings(_settings, _syncSettings);
|
||||||
|
|
||||||
_boyee = PreInit<LibVirtualBoyee>(new PeRunnerOptions
|
_boyee = PreInit<LibVirtualBoyee>(new PeRunnerOptions
|
||||||
{
|
{
|
||||||
Filename = "vb.wbx",
|
Filename = "vb.wbx",
|
||||||
SbrkHeapSizeKB = 256,
|
SbrkHeapSizeKB = 256,
|
||||||
SealedHeapSizeKB = 4 * 1024,
|
SealedHeapSizeKB = 4 * 1024,
|
||||||
InvisibleHeapSizeKB = 256,
|
InvisibleHeapSizeKB = 256,
|
||||||
PlainHeapSizeKB = 256
|
PlainHeapSizeKB = 256
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!_boyee.Load(rom, rom.Length, nativeSettings))
|
if (!_boyee.Load(rom, rom.Length, nativeSettings))
|
||||||
throw new InvalidOperationException("Core rejected the rom");
|
throw new InvalidOperationException("Core rejected the rom");
|
||||||
|
|
||||||
PostInit();
|
// do a quick hack up for frame zero size
|
||||||
}
|
var tmp = new LibVirtualBoyee.FrameInfo();
|
||||||
|
_boyee.PredictFrameSize(tmp);
|
||||||
|
BufferWidth = tmp.Width;
|
||||||
|
BufferHeight = tmp.Height;
|
||||||
|
|
||||||
|
PostInit();
|
||||||
|
}
|
||||||
|
|
||||||
protected override LibWaterboxCore.FrameInfo FrameAdvancePrep(IController controller, bool render, bool rendersound)
|
protected override LibWaterboxCore.FrameInfo FrameAdvancePrep(IController controller, bool render, bool rendersound)
|
||||||
{
|
{
|
||||||
if (controller.IsPressed("Power"))
|
if (controller.IsPressed("Power"))
|
||||||
_boyee.HardReset();
|
_boyee.HardReset();
|
||||||
|
|
||||||
return new LibVirtualBoyee.FrameInfo { Buttons = GetButtons(controller) };
|
return new LibVirtualBoyee.FrameInfo { Buttons = GetButtons(controller) };
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Controller
|
#region Controller
|
||||||
|
|
||||||
private LibVirtualBoyee.Buttons GetButtons(IController c)
|
private LibVirtualBoyee.Buttons GetButtons(IController c)
|
||||||
{
|
{
|
||||||
var ret = 0;
|
var ret = 0;
|
||||||
var val = 1;
|
var val = 1;
|
||||||
foreach (var s in CoreButtons)
|
foreach (var s in CoreButtons)
|
||||||
{
|
{
|
||||||
if (c.IsPressed(s))
|
if (c.IsPressed(s))
|
||||||
ret |= val;
|
ret |= val;
|
||||||
val <<= 1;
|
val <<= 1;
|
||||||
}
|
}
|
||||||
return (LibVirtualBoyee.Buttons)ret;
|
return (LibVirtualBoyee.Buttons)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly string[] CoreButtons =
|
private static readonly string[] CoreButtons =
|
||||||
{
|
{
|
||||||
"A", "B", "R", "L",
|
"A", "B", "R", "L",
|
||||||
"R_Up", "R_Right",
|
"R_Up", "R_Right",
|
||||||
"L_Right", "L_Left", "L_Down", "L_Up",
|
"L_Right", "L_Left", "L_Down", "L_Up",
|
||||||
"Start", "Select", "R_Left", "R_Down"
|
"Start", "Select", "R_Left", "R_Down"
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly Dictionary<string, int> _buttonOrdinals = new Dictionary<string, int>
|
private static readonly Dictionary<string, int> _buttonOrdinals = new Dictionary<string, int>
|
||||||
{
|
{
|
||||||
["L_Up"] = 1,
|
["L_Up"] = 1,
|
||||||
["L_Down"] = 2,
|
["L_Down"] = 2,
|
||||||
["L_Left"] = 3,
|
["L_Left"] = 3,
|
||||||
["L_Right"] = 4,
|
["L_Right"] = 4,
|
||||||
["R_Up"] = 5,
|
["R_Up"] = 5,
|
||||||
["R_Down"] = 6,
|
["R_Down"] = 6,
|
||||||
["R_Left"] = 7,
|
["R_Left"] = 7,
|
||||||
["R_Right"] = 8,
|
["R_Right"] = 8,
|
||||||
["B"] = 9,
|
["B"] = 9,
|
||||||
["A"] = 10,
|
["A"] = 10,
|
||||||
["L"] = 11,
|
["L"] = 11,
|
||||||
["R"] = 12,
|
["R"] = 12,
|
||||||
["Select"] = 13,
|
["Select"] = 13,
|
||||||
["Start"] = 14
|
["Start"] = 14
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly ControllerDefinition VirtualBoyController = new ControllerDefinition
|
private static readonly ControllerDefinition VirtualBoyController = new ControllerDefinition
|
||||||
{
|
{
|
||||||
Name = "VirtualBoy Controller",
|
Name = "VirtualBoy Controller",
|
||||||
BoolButtons = CoreButtons
|
BoolButtons = CoreButtons
|
||||||
.OrderBy(b => _buttonOrdinals[b])
|
.OrderBy(b => _buttonOrdinals[b])
|
||||||
.Concat(new[] { "Power" })
|
.Concat(new[] { "Power" })
|
||||||
.ToList()
|
.ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
public override ControllerDefinition ControllerDefinition => VirtualBoyController;
|
public override ControllerDefinition ControllerDefinition => VirtualBoyController;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ISettable
|
#region ISettable
|
||||||
|
|
||||||
public class SyncSettings
|
public class SyncSettings
|
||||||
{
|
{
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
[Description("Reduce input latency. Works with all known commercial games, may have homebrew issues.")]
|
[Description("Reduce input latency. Works with all known commercial games, may have homebrew issues.")]
|
||||||
public bool InstantReadHack { get; set; }
|
public bool InstantReadHack { get; set; }
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
[Description("Disable parallax for rendering.")]
|
[Description("Disable parallax for rendering.")]
|
||||||
public bool DisableParallax { get; set; }
|
public bool DisableParallax { get; set; }
|
||||||
|
|
||||||
public SyncSettings Clone()
|
public SyncSettings Clone()
|
||||||
{
|
{
|
||||||
return (SyncSettings)MemberwiseClone();
|
return (SyncSettings)MemberwiseClone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool NeedsReboot(SyncSettings x, SyncSettings y)
|
public static bool NeedsReboot(SyncSettings x, SyncSettings y)
|
||||||
{
|
{
|
||||||
return !DeepEquality.DeepEquals(x, y);
|
return !DeepEquality.DeepEquals(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SyncSettings()
|
public SyncSettings()
|
||||||
{
|
{
|
||||||
SettingsUtil.SetDefaultValues(this);
|
SettingsUtil.SetDefaultValues(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Settings
|
public class Settings
|
||||||
{
|
{
|
||||||
public enum ThreeDeeModes : int
|
public enum ThreeDeeModes : int
|
||||||
{
|
{
|
||||||
Anaglyph = 0,
|
Anaglyph = 0,
|
||||||
CyberScope = 1,
|
CyberScope = 1,
|
||||||
SideBySide = 2,
|
SideBySide = 2,
|
||||||
//OverUnder,
|
//OverUnder,
|
||||||
VerticalInterlaced = 4,
|
VerticalInterlaced = 4,
|
||||||
HorizontalInterlaced = 5
|
HorizontalInterlaced = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
[DefaultValue(ThreeDeeModes.Anaglyph)]
|
[DefaultValue(ThreeDeeModes.Anaglyph)]
|
||||||
[Description("How to display the 3d image. Use whichever method works with your VR hardware.")]
|
[Description("How to display the 3d image. Use whichever method works with your VR hardware.")]
|
||||||
public ThreeDeeModes ThreeDeeMode { get; set; }
|
public ThreeDeeModes ThreeDeeMode { get; set; }
|
||||||
|
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
[Description("Swap the left and right views.")]
|
[Description("Swap the left and right views.")]
|
||||||
public bool SwapViews { get; set; }
|
public bool SwapViews { get; set; }
|
||||||
|
|
||||||
public enum AnaglyphPresets : int
|
public enum AnaglyphPresets : int
|
||||||
{
|
{
|
||||||
Custom,
|
Custom,
|
||||||
RedBlue,
|
RedBlue,
|
||||||
RedCyan,
|
RedCyan,
|
||||||
RedElectricCyan,
|
RedElectricCyan,
|
||||||
RedGreen,
|
RedGreen,
|
||||||
GreenMagneto,
|
GreenMagneto,
|
||||||
YellowBlue
|
YellowBlue
|
||||||
}
|
}
|
||||||
|
|
||||||
[DefaultValue(AnaglyphPresets.RedBlue)]
|
[DefaultValue(AnaglyphPresets.RedBlue)]
|
||||||
[Description("Color preset for Anaglyph mode.")]
|
[Description("Color preset for Anaglyph mode.")]
|
||||||
public AnaglyphPresets AnaglyphPreset { get; set; }
|
public AnaglyphPresets AnaglyphPreset { get; set; }
|
||||||
|
|
||||||
[DefaultValue(typeof(Color), "Green")]
|
[DefaultValue(typeof(Color), "Green")]
|
||||||
[Description("Left anaglyph color. Ignored unless Preset is Custom.")]
|
[Description("Left anaglyph color. Ignored unless Preset is Custom.")]
|
||||||
public Color AnaglyphCustomLeftColor { get; set; }
|
public Color AnaglyphCustomLeftColor { get; set; }
|
||||||
[DefaultValue(typeof(Color), "Purple")]
|
[DefaultValue(typeof(Color), "Purple")]
|
||||||
[Description("Right anaglyph color. Ignored unless Preset is Custom.")]
|
[Description("Right anaglyph color. Ignored unless Preset is Custom.")]
|
||||||
public Color AnaglyphCustomRightColor { get; set; }
|
public Color AnaglyphCustomRightColor { get; set; }
|
||||||
|
|
||||||
[DefaultValue(typeof(Color), "White")]
|
[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.")]
|
[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; }
|
public Color NonAnaglyphColor { get; set; }
|
||||||
|
|
||||||
[DefaultValue(1750)]
|
[DefaultValue(1750)]
|
||||||
[Range(1000, 2000)]
|
[Range(1000, 2000)]
|
||||||
[Description("LED gamma ramp. Range of 1000 to 2000")]
|
[Description("LED gamma ramp. Range of 1000 to 2000")]
|
||||||
public int LedOnScale { get; set; }
|
public int LedOnScale { get; set; }
|
||||||
|
|
||||||
[DefaultValue(2)]
|
[DefaultValue(2)]
|
||||||
[Range(1, 10)]
|
[Range(1, 10)]
|
||||||
public int InterlacePrescale { get; set; }
|
public int InterlacePrescale { get; set; }
|
||||||
|
|
||||||
[DefaultValue(0)]
|
[DefaultValue(0)]
|
||||||
[Range(0, 1024)]
|
[Range(0, 1024)]
|
||||||
[Description("How many pixels to put between views in Side By Side mode")]
|
[Description("How many pixels to put between views in Side By Side mode")]
|
||||||
public int SideBySideSeparation { get; set; }
|
public int SideBySideSeparation { get; set; }
|
||||||
|
|
||||||
public Settings Clone()
|
public Settings Clone()
|
||||||
{
|
{
|
||||||
return (Settings)MemberwiseClone();
|
return (Settings)MemberwiseClone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool NeedsReboot(Settings x, Settings y)
|
public static bool NeedsReboot(Settings x, Settings y)
|
||||||
{
|
{
|
||||||
return !DeepEquality.DeepEquals(x, y);
|
return !DeepEquality.DeepEquals(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Settings()
|
public Settings()
|
||||||
{
|
{
|
||||||
SettingsUtil.SetDefaultValues(this);
|
SettingsUtil.SetDefaultValues(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Settings _settings;
|
private Settings _settings;
|
||||||
private SyncSettings _syncSettings;
|
private SyncSettings _syncSettings;
|
||||||
|
|
||||||
public Settings GetSettings()
|
public Settings GetSettings()
|
||||||
{
|
{
|
||||||
return _settings.Clone();
|
return _settings.Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SyncSettings GetSyncSettings()
|
public SyncSettings GetSyncSettings()
|
||||||
{
|
{
|
||||||
return _syncSettings.Clone();
|
return _syncSettings.Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool PutSettings(Settings o)
|
public bool PutSettings(Settings o)
|
||||||
{
|
{
|
||||||
var ret = Settings.NeedsReboot(_settings, o);
|
var ret = Settings.NeedsReboot(_settings, o);
|
||||||
_settings = o;
|
_settings = o;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool PutSyncSettings(SyncSettings o)
|
public bool PutSyncSettings(SyncSettings o)
|
||||||
{
|
{
|
||||||
var ret = SyncSettings.NeedsReboot(_syncSettings, o);
|
var ret = SyncSettings.NeedsReboot(_syncSettings, o);
|
||||||
_syncSettings = o;
|
_syncSettings = o;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -779,6 +779,11 @@ EXPORT void FrameAdvance(MyFrameInfo* frame)
|
||||||
VB_V810->ResetTS(0);
|
VB_V810->ResetTS(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EXPORT void PredictFrameSize(MyFrameInfo* frame)
|
||||||
|
{
|
||||||
|
VIP_CalcFrameSize(frame);
|
||||||
|
}
|
||||||
|
|
||||||
EXPORT void HardReset()
|
EXPORT void HardReset()
|
||||||
{
|
{
|
||||||
VB_Power();
|
VB_Power();
|
||||||
|
|
|
@ -864,18 +864,8 @@ MDFN_FASTCALL void VIP_Write16(int32 ×tamp, uint32 A, uint16 V)
|
||||||
static MDFN_Surface real_surface;
|
static MDFN_Surface real_surface;
|
||||||
static MDFN_Surface *surface;
|
static MDFN_Surface *surface;
|
||||||
|
|
||||||
void VIP_StartFrame(MyFrameInfo* frame)
|
void VIP_CalcFrameSize(MyFrameInfo* frame)
|
||||||
{
|
{
|
||||||
// puts("Start frame");
|
|
||||||
|
|
||||||
if (VidSettingsDirty)
|
|
||||||
{
|
|
||||||
MakeColorLUT();
|
|
||||||
Recalc3DModeStuff();
|
|
||||||
|
|
||||||
VidSettingsDirty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (VB3DMode)
|
switch (VB3DMode)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
@ -903,6 +893,22 @@ void VIP_StartFrame(MyFrameInfo* frame)
|
||||||
frame->Height = 224;
|
frame->Height = 224;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VIP_StartFrame(MyFrameInfo* frame)
|
||||||
|
{
|
||||||
|
// puts("Start frame");
|
||||||
|
|
||||||
|
if (VidSettingsDirty)
|
||||||
|
{
|
||||||
|
MakeColorLUT();
|
||||||
|
Recalc3DModeStuff();
|
||||||
|
|
||||||
|
VidSettingsDirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
VIP_CalcFrameSize(frame);
|
||||||
|
|
||||||
|
|
||||||
surface = &real_surface;
|
surface = &real_surface;
|
||||||
real_surface.pixels = frame->VideoBuffer;
|
real_surface.pixels = frame->VideoBuffer;
|
||||||
|
|
|
@ -38,6 +38,7 @@ v810_timestamp_t MDFN_FASTCALL VIP_Update(const v810_timestamp_t timestamp);
|
||||||
void VIP_ResetTS(void);
|
void VIP_ResetTS(void);
|
||||||
|
|
||||||
void VIP_StartFrame(MyFrameInfo* frame);
|
void VIP_StartFrame(MyFrameInfo* frame);
|
||||||
|
void VIP_CalcFrameSize(MyFrameInfo* frame);
|
||||||
|
|
||||||
MDFN_FASTCALL uint8 VIP_Read8(v810_timestamp_t ×tamp, uint32 A);
|
MDFN_FASTCALL uint8 VIP_Read8(v810_timestamp_t ×tamp, uint32 A);
|
||||||
MDFN_FASTCALL uint16 VIP_Read16(v810_timestamp_t ×tamp, uint32 A);
|
MDFN_FASTCALL uint16 VIP_Read16(v810_timestamp_t ×tamp, uint32 A);
|
||||||
|
|
Loading…
Reference in New Issue