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:
parent
94c397a4f8
commit
fbf7be92d5
|
@ -61,20 +61,20 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
|
||||||
|
|
||||||
public enum Buttons : int
|
public enum Buttons : int
|
||||||
{
|
{
|
||||||
Up = 0x1,
|
Up = 0x200,
|
||||||
Down = 0x2,
|
Down = 0x100,
|
||||||
Left = 0x4,
|
Left = 0x80,
|
||||||
Right = 0x8,
|
Right = 0x40,
|
||||||
Select = 0x10,
|
Select = 0x800,
|
||||||
Start = 0x20,
|
Start = 0x400,
|
||||||
B = 0x40,
|
B = 0x2,
|
||||||
A = 0x80,
|
A = 0x1,
|
||||||
Up_R = 0x100,
|
Up_R = 0x10,
|
||||||
Down_R = 0x200,
|
Down_R = 0x200,
|
||||||
Left_R = 0x400,
|
Left_R = 0x1000,
|
||||||
Right_R = 0x800,
|
Right_R = 0x2000,
|
||||||
L = 0x1000,
|
L = 0x8,
|
||||||
R = 0x2000
|
R = 0x4
|
||||||
}
|
}
|
||||||
|
|
||||||
[BizImport(CC)]
|
[BizImport(CC)]
|
||||||
|
|
|
@ -9,8 +9,9 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
|
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
|
||||||
{
|
{
|
||||||
[CoreAttributes("Virtual Boyee", "???", true, false, "0.9.44.1", "https://mednafen.github.io/releases/", false)]
|
[CoreAttributes("Virtual Boyee", "???", true, false, "0.9.44.1",
|
||||||
public class VirtualBoyee : IEmulator, IVideoProvider
|
"https://mednafen.github.io/releases/", false)]
|
||||||
|
public class VirtualBoyee : IEmulator, IVideoProvider, ISoundProvider
|
||||||
{
|
{
|
||||||
private PeRunner _exe;
|
private PeRunner _exe;
|
||||||
private LibVirtualBoyee _boyee;
|
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)
|
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 (int* vp = _videoBuffer)
|
||||||
fixed(short*sp = scratch)
|
fixed (short* sp = _soundBuffer)
|
||||||
{
|
{
|
||||||
var spec = new LibVirtualBoyee.EmulateSpec
|
var spec = new LibVirtualBoyee.EmulateSpec
|
||||||
{
|
{
|
||||||
Pixels = (IntPtr)vp,
|
Pixels = (IntPtr)vp,
|
||||||
SoundBuf = (IntPtr)sp,
|
SoundBuf = (IntPtr)sp,
|
||||||
SoundBufMaxSize = 8192
|
SoundBufMaxSize = _soundBuffer.Length / 2,
|
||||||
|
Buttons = GetButtons(controller)
|
||||||
};
|
};
|
||||||
|
|
||||||
_boyee.Emulate(spec);
|
_boyee.Emulate(spec);
|
||||||
VirtualWidth = BufferWidth = spec.DisplayRect.W;
|
BufferWidth = spec.DisplayRect.W;
|
||||||
VirtualWidth = BufferHeight = spec.DisplayRect.H;
|
BufferHeight = spec.DisplayRect.H;
|
||||||
Console.WriteLine(spec.SoundBufSize);
|
_numSamples = spec.SoundBufSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
Frame++;
|
Frame++;
|
||||||
|
|
||||||
/*_core.biz_set_input_callback(InputCallbacks.Count > 0 ? _inputCallback : null);
|
/*_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);
|
UpdateControls(controller);
|
||||||
Frame++;
|
Frame++;
|
||||||
LibSnes9x.frame_info frame = new LibSnes9x.frame_info();
|
LibSnes9x.frame_info frame = new LibSnes9x.frame_info();
|
||||||
|
@ -90,12 +88,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
|
||||||
_core.biz_run(frame, _inputState);
|
_core.biz_run(frame, _inputState);
|
||||||
IsLagFrame = frame.padread == 0;
|
IsLagFrame = frame.padread == 0;
|
||||||
if (IsLagFrame)
|
if (IsLagFrame)
|
||||||
LagCount++;
|
LagCount++;*/
|
||||||
using (_exe.EnterExit())
|
|
||||||
{
|
|
||||||
Blit(frame);
|
|
||||||
Sblit(frame);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Frame { get; private set; }
|
public int Frame { get; private set; }
|
||||||
|
@ -109,29 +102,94 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
|
||||||
public bool DeterministicEmulation { get { return true; } }
|
public bool DeterministicEmulation { get { return true; } }
|
||||||
public CoreComm CoreComm { get; private set; }
|
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
|
#region IVideoProvider
|
||||||
|
|
||||||
private int[] _videoBuffer = new int[256 * 192];
|
private int[] _videoBuffer = new int[1024 * 1024];
|
||||||
|
|
||||||
public int[] GetVideoBuffer()
|
public int[] GetVideoBuffer()
|
||||||
{
|
{
|
||||||
return _videoBuffer;
|
return _videoBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int VirtualWidth { get; private set; } = 256;
|
public int VirtualWidth => BufferWidth;
|
||||||
public int VirtualHeight { get; private set; } = 192;
|
public int VirtualHeight => BufferWidth;
|
||||||
|
|
||||||
public int BufferWidth { get; private set; } = 256;
|
public int BufferWidth { get; private set; } = 384;
|
||||||
public int BufferHeight { get; private set; } = 192;
|
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);
|
public int BackgroundColor => unchecked((int)0xff000000);
|
||||||
|
|
||||||
#endregion
|
#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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -650,6 +650,7 @@ EXPORT int Load(const uint8 *rom, int length)
|
||||||
VIP_Set3DMode(VB3DMode, reverse, prescale, sbs_separation);
|
VIP_Set3DMode(VB3DMode, reverse, prescale, sbs_separation);
|
||||||
|
|
||||||
VIP_SetParallaxDisable(false);
|
VIP_SetParallaxDisable(false);
|
||||||
|
|
||||||
{
|
{
|
||||||
auto presetColor = ANAGLYPH_PRESET_RED_BLUE;
|
auto presetColor = ANAGLYPH_PRESET_RED_BLUE;
|
||||||
|
|
||||||
|
@ -668,15 +669,8 @@ EXPORT int Load(const uint8 *rom, int length)
|
||||||
|
|
||||||
VIP_SetLEDOnScale(1.75);
|
VIP_SetLEDOnScale(1.75);
|
||||||
|
|
||||||
//MDFNGameInfo->fps = (int64)20000000 * 65536 * 256 / (259 * 384 * 4);
|
|
||||||
|
|
||||||
VB_Power();
|
VB_Power();
|
||||||
|
|
||||||
/*MDFNGameInfo->nominal_width = 384;
|
|
||||||
MDFNGameInfo->nominal_height = 224;
|
|
||||||
MDFNGameInfo->fb_width = 384;
|
|
||||||
MDFNGameInfo->fb_height = 224;*/
|
|
||||||
|
|
||||||
/*switch (VB3DMode)
|
/*switch (VB3DMode)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue