diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/LibVirtualBoyee.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/LibVirtualBoyee.cs index 89beef4e9a..619f304736 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/LibVirtualBoyee.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/LibVirtualBoyee.cs @@ -37,10 +37,23 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB } [StructLayout(LayoutKind.Sequential)] - public class NativeSettings + 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; @@ -56,12 +69,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB return c.ToArgb(); } - public static NativeSettings FromFrontendSettings(VirtualBoyee.Settings s, VirtualBoyee.SyncSettings ss) + public static NativeSettings FromFrontendSettings(VirtualBoyee.Settings s) { 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, @@ -77,7 +88,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB [BizImport(CC)] - public abstract bool Load(byte[] rom, int length, [In]NativeSettings settings); + public abstract bool Load(byte[] rom, int length, NativeSyncSettings settings); + + [BizImport(CC)] + public abstract void SetSettings(NativeSettings settings); [BizImport(CC)] public abstract void HardReset(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs index 43b7e26ada..2b564a11e3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs @@ -24,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB [CoreConstructor("VB")] public VirtualBoyee(CoreComm comm, byte[] rom, Settings settings, SyncSettings syncSettings) - :base(comm, new Configuration + : base(comm, new Configuration { DefaultFpsNumerator = 20000000, DefaultFpsDenominator = 397824, @@ -38,8 +38,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB { _settings = settings ?? new Settings(); _syncSettings = syncSettings ?? new SyncSettings(); - // TODO: the way settings work in this core, changing the non-sync ones will invalidate savestates - var nativeSettings = LibVirtualBoyee.NativeSettings.FromFrontendSettings(_settings, _syncSettings); _boyee = PreInit(new PeRunnerOptions { @@ -50,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB PlainHeapSizeKB = 256 }); - if (!_boyee.Load(rom, rom.Length, nativeSettings)) + 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 @@ -60,6 +58,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB BufferHeight = tmp.Height; PostInit(); + + _boyee.SetSettings(LibVirtualBoyee.NativeSettings.FromFrontendSettings(_settings)); } protected override LibWaterboxCore.FrameInfo FrameAdvancePrep(IController controller, bool render, bool rendersound) diff --git a/output/dll/vb.wbx.gz b/output/dll/vb.wbx.gz index cda73284d9..cec6e7d75b 100644 Binary files a/output/dll/vb.wbx.gz and b/output/dll/vb.wbx.gz differ diff --git a/waterbox/vb/vb.cpp b/waterbox/vb/vb.cpp index 9087ea46dd..b70042ae89 100644 --- a/waterbox/vb/vb.cpp +++ b/waterbox/vb/vb.cpp @@ -26,10 +26,13 @@ namespace MDFN_IEN_VB { -struct NativeSettings +struct NativeSyncSettings { int InstantReadHack; int DisableParallax; +}; +struct NativeSettings +{ int ThreeDeeMode; int SwapViews; int AnaglyphPreset; @@ -56,14 +59,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}, }; static uint32 VB3DMode; @@ -501,7 +504,6 @@ void VB_ExitLoop(void) VB_V810->Exit(); } - /*MDFNGI EmulatedVB = { @@ -552,7 +554,7 @@ void VB_ExitLoop(void) using namespace MDFN_IEN_VB; -EXPORT int Load(const uint8 *rom, int length, const NativeSettings* settings) +EXPORT int Load(const uint8 *rom, int length, const NativeSyncSettings *syncSettings) { const uint64 rom_size = length; V810_Emu_Mode cpu_mode = V810_EMU_MODE_ACCURATE; @@ -660,20 +662,20 @@ EXPORT int Load(const uint8 *rom, int length, const NativeSettings* settings) VB_VSU = new VSU(); VBINPUT_Init(); - VB3DMode = settings->ThreeDeeMode; - uint32 prescale = settings->InterlacePrescale; - uint32 sbs_separation = settings->SideBySideSeparation; - bool reverse = settings->SwapViews; + VB3DMode = 0; + uint32 prescale = 1; + uint32 sbs_separation = 0; + bool reverse = false; VIP_Set3DMode(VB3DMode, reverse, prescale, sbs_separation); - VIP_SetParallaxDisable(settings->DisableParallax); + VIP_SetParallaxDisable(syncSettings->DisableParallax); { - auto presetColor = settings->AnaglyphPreset; + auto presetColor = 1; - uint32 lcolor = settings->AnaglyphCustomLeftColor; - uint32 rcolor = settings->AnaglyphCustomRightColor; + uint32 lcolor = 0xff0000; + uint32 rcolor = 0x00ff00; if (presetColor != ANAGLYPH_PRESET_DISABLED) { @@ -681,12 +683,12 @@ EXPORT int Load(const uint8 *rom, int length, const NativeSettings* settings) rcolor = AnaglyphPreset_Colors[presetColor][1]; } VIP_SetAnaglyphColors(lcolor, rcolor); - VIP_SetDefaultColor(settings->NonAnaglyphColor); + VIP_SetDefaultColor(0xffffff); } - VBINPUT_SetInstantReadHack(settings->InstantReadHack); + VBINPUT_SetInstantReadHack(syncSettings->InstantReadHack); - VIP_SetLEDOnScale(settings->LedOnScale / 1000.0); + VIP_SetLEDOnScale(1750 / 1000.0); VB_Power(); @@ -731,7 +733,34 @@ EXPORT int Load(const uint8 *rom, int length, const NativeSettings* settings) return 1; } -EXPORT void GetMemoryAreas(MemoryArea* m) +EXPORT void SetSettings(const NativeSettings *settings) +{ + VB3DMode = settings->ThreeDeeMode; + uint32 prescale = settings->InterlacePrescale; + uint32 sbs_separation = settings->SideBySideSeparation; + bool reverse = settings->SwapViews; + + VIP_Set3DMode(VB3DMode, reverse, prescale, sbs_separation); + + { + auto presetColor = settings->AnaglyphPreset; + + uint32 lcolor = settings->AnaglyphCustomLeftColor; + uint32 rcolor = settings->AnaglyphCustomRightColor; + + if (presetColor != ANAGLYPH_PRESET_DISABLED) + { + lcolor = AnaglyphPreset_Colors[presetColor][0]; + rcolor = AnaglyphPreset_Colors[presetColor][1]; + } + VIP_SetAnaglyphColors(lcolor, rcolor); + VIP_SetDefaultColor(settings->NonAnaglyphColor); + } + + VIP_SetLEDOnScale(settings->LedOnScale / 1000.0); +} + +EXPORT void GetMemoryAreas(MemoryArea *m) { m[0].Data = WRAM; m[0].Name = "WRAM"; @@ -749,7 +778,7 @@ EXPORT void GetMemoryAreas(MemoryArea* m) m[2].Flags = MEMORYAREA_FLAGS_WORDSIZE4; } -EXPORT void FrameAdvance(MyFrameInfo* frame) +EXPORT void FrameAdvance(MyFrameInfo *frame) { v810_timestamp_t v810_timestamp; lagged = true; @@ -779,7 +808,7 @@ EXPORT void FrameAdvance(MyFrameInfo* frame) VB_V810->ResetTS(0); } -EXPORT void PredictFrameSize(MyFrameInfo* frame) +EXPORT void PredictFrameSize(MyFrameInfo *frame) { VIP_CalcFrameSize(frame); } diff --git a/waterbox/vb/vip.cpp b/waterbox/vb/vip.cpp index abb7635b53..9810130362 100644 --- a/waterbox/vb/vip.cpp +++ b/waterbox/vb/vip.cpp @@ -21,6 +21,7 @@ #include "vb.h" #include +#include "../emulibc/emulibc.h" #define VIP_DBGMSG(format, ...) \ { \ @@ -67,8 +68,8 @@ static uint32 ColorLUT[2][256]; static int32 BrightnessCache[4]; static uint32 BrightCLUT[2][4]; -static float ColorLUTNoGC[2][256][3]; -static uint32 AnaSlowColorLUT[256][256]; +static float ECL_INVISIBLE ColorLUTNoGC[2][256][3]; +static uint32 ECL_INVISIBLE AnaSlowColorLUT[256][256]; static bool VidSettingsDirty; static bool ParallaxDisabled;