VirtualBoyee: Hookup video, input, and sound. 3D Tetris appears to be working, but only the alternate dump of merio tenis works

This commit is contained in:
nattthebear 2017-05-29 08:16:56 -04:00
parent 94c397a4f8
commit fbf7be92d5
3 changed files with 100 additions and 48 deletions

View File

@ -61,20 +61,20 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
public enum Buttons : int
{
Up = 0x1,
Down = 0x2,
Left = 0x4,
Right = 0x8,
Select = 0x10,
Start = 0x20,
B = 0x40,
A = 0x80,
Up_R = 0x100,
Up = 0x200,
Down = 0x100,
Left = 0x80,
Right = 0x40,
Select = 0x800,
Start = 0x400,
B = 0x2,
A = 0x1,
Up_R = 0x10,
Down_R = 0x200,
Left_R = 0x400,
Right_R = 0x800,
L = 0x1000,
R = 0x2000
Left_R = 0x1000,
Right_R = 0x2000,
L = 0x8,
R = 0x4
}
[BizImport(CC)]

View File

@ -9,8 +9,9 @@ using System.Threading.Tasks;
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
[CoreAttributes("Virtual Boyee", "???", true, false, "0.9.44.1",
"https://mednafen.github.io/releases/", false)]
public class VirtualBoyee : IEmulator, IVideoProvider, ISoundProvider
{
private PeRunner _exe;
private LibVirtualBoyee _boyee;
@ -56,33 +57,30 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
public unsafe void FrameAdvance(IController controller, bool render, bool rendersound = true)
{
var scratch = new short[16384];
if (controller.IsPressed("Power"))
_boyee.HardReset();
fixed(int*vp = _videoBuffer)
fixed(short*sp = scratch)
fixed (int* vp = _videoBuffer)
fixed (short* sp = _soundBuffer)
{
var spec = new LibVirtualBoyee.EmulateSpec
{
Pixels = (IntPtr)vp,
SoundBuf = (IntPtr)sp,
SoundBufMaxSize = 8192
SoundBufMaxSize = _soundBuffer.Length / 2,
Buttons = GetButtons(controller)
};
_boyee.Emulate(spec);
VirtualWidth = BufferWidth = spec.DisplayRect.W;
VirtualWidth = BufferHeight = spec.DisplayRect.H;
Console.WriteLine(spec.SoundBufSize);
BufferWidth = spec.DisplayRect.W;
BufferHeight = spec.DisplayRect.H;
_numSamples = spec.SoundBufSize;
}
Frame++;
/*_core.biz_set_input_callback(InputCallbacks.Count > 0 ? _inputCallback : null);
if (controller.IsPressed("Power"))
_core.biz_hard_reset();
else if (controller.IsPressed("Reset"))
_core.biz_soft_reset();
UpdateControls(controller);
Frame++;
LibSnes9x.frame_info frame = new LibSnes9x.frame_info();
@ -90,12 +88,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
_core.biz_run(frame, _inputState);
IsLagFrame = frame.padread == 0;
if (IsLagFrame)
LagCount++;
using (_exe.EnterExit())
{
Blit(frame);
Sblit(frame);
}*/
LagCount++;*/
}
public int Frame { get; private set; }
@ -109,29 +102,94 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
public bool DeterministicEmulation { get { return true; } }
public CoreComm CoreComm { get; private set; }
public ControllerDefinition ControllerDefinition => NullController.Instance.Definition;
#region Controller
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",
"Up_R", "Right_R",
"Right", "Left", "Down", "Up",
"Start", "Select", "Left_R", "Down_R"
};
private static readonly ControllerDefinition VirtualBoyController = new ControllerDefinition
{
Name = "VirtualBoy Controller",
BoolButtons = CoreButtons.Concat(new[] { "Power" }).ToList()
};
public ControllerDefinition ControllerDefinition => VirtualBoyController;
#endregion
#region IVideoProvider
private int[] _videoBuffer = new int[256 * 192];
private int[] _videoBuffer = new int[1024 * 1024];
public int[] GetVideoBuffer()
{
return _videoBuffer;
}
public int VirtualWidth { get; private set; } = 256;
public int VirtualHeight { get; private set; } = 192;
public int VirtualWidth => BufferWidth;
public int VirtualHeight => BufferWidth;
public int BufferWidth { get; private set; } = 256;
public int BufferHeight { get; private set; } = 192;
public int BufferWidth { get; private set; } = 384;
public int BufferHeight { get; private set; } = 224;
public int VsyncNumerator { get; private set; } = 60;
public int VsyncNumerator { get; private set; } = 20000000;
public int VsyncDenominator { get; private set; } = 1;
public int VsyncDenominator { get; private set; } = 397824;
public int BackgroundColor => unchecked((int)0xff000000);
#endregion
#region ISoundProvider
private short[] _soundBuffer = new short[16384];
private int _numSamples;
public void SetSyncMode(SyncSoundMode mode)
{
if (mode == SyncSoundMode.Async)
{
throw new NotSupportedException("Async mode is not supported.");
}
}
public void GetSamplesSync(out short[] samples, out int nsamp)
{
samples = _soundBuffer;
nsamp = _numSamples;
}
public void GetSamplesAsync(short[] samples)
{
throw new InvalidOperationException("Async mode is not supported.");
}
public void DiscardSamples()
{
}
public bool CanProvideAsync => false;
public SyncSoundMode SyncMode => SyncSoundMode.Sync;
#endregion
}
}

View File

@ -650,6 +650,7 @@ EXPORT int Load(const uint8 *rom, int length)
VIP_Set3DMode(VB3DMode, reverse, prescale, sbs_separation);
VIP_SetParallaxDisable(false);
{
auto presetColor = ANAGLYPH_PRESET_RED_BLUE;
@ -668,15 +669,8 @@ EXPORT int Load(const uint8 *rom, int length)
VIP_SetLEDOnScale(1.75);
//MDFNGameInfo->fps = (int64)20000000 * 65536 * 256 / (259 * 384 * 4);
VB_Power();
/*MDFNGameInfo->nominal_width = 384;
MDFNGameInfo->nominal_height = 224;
MDFNGameInfo->fb_width = 384;
MDFNGameInfo->fb_height = 224;*/
/*switch (VB3DMode)
{
default: