diff --git a/Assets/dll/dsda.wbx.zst b/Assets/dll/dsda.wbx.zst index 906e2d75e5..50854fa449 100644 Binary files a/Assets/dll/dsda.wbx.zst and b/Assets/dll/dsda.wbx.zst differ diff --git a/src/BizHawk.Emulation.Cores/Computers/Doom/DSDA.IVideoProvider.cs b/src/BizHawk.Emulation.Cores/Computers/Doom/DSDA.IVideoProvider.cs index f8f3aec22e..11aa92ee1f 100644 --- a/src/BizHawk.Emulation.Cores/Computers/Doom/DSDA.IVideoProvider.cs +++ b/src/BizHawk.Emulation.Cores/Computers/Doom/DSDA.IVideoProvider.cs @@ -15,11 +15,38 @@ namespace BizHawk.Emulation.Cores.Computers.Doom public int VsyncDenominator { get; } public int[] GetVideoBuffer() => _vidBuff; - private unsafe void UpdateVideo(int gamma = -1) + private void InitVideo() + { + var renderInfo = new LibDSDA.PackedRenderInfo() + { + SfxVolume = _settings.SfxVolume, + MusicVolume = _settings.MusicVolume, + Gamma = _settings.Gamma, + HeadsUpMode = (int) _settings.HeadsUpMode, + MapDetails = (int) _settings.MapDetails, + MapOverlay = (int) _settings.MapOverlay, + RenderVideo = 1, + RenderAudio = 1, + ShowMessages = Convert.ToInt32(_settings.ShowMessages), + ReportSecrets = Convert.ToInt32(_settings.ReportSecrets), + DsdaExHud = Convert.ToInt32(_settings.DsdaExHud), + DisplayCoordinates = Convert.ToInt32(_settings.DisplayCoordinates), + DisplayCommands = Convert.ToInt32(_settings.DisplayCommands), + MapTotals = Convert.ToInt32(_settings.MapTotals), + MapTime = Convert.ToInt32(_settings.MapTime), + MapCoordinates = Convert.ToInt32(_settings.MapCoordinates), + PlayerPointOfView = _settings.DisplayPlayer - 1, + }; + + _core.dsda_init_video(ref renderInfo); + _vidBuff = new int[BufferWidth * BufferHeight]; + } + + private unsafe void UpdateVideo(bool init = false) { using (_elf.EnterExit()) { - _core.dsda_get_video(gamma, out var vi); + _core.dsda_get_video(out var vi); int[] _palBuffer = [ ]; var videoBuffer = (byte*)vi.VideoBuffer.ToPointer(); diff --git a/src/BizHawk.Emulation.Cores/Computers/Doom/DSDA.cs b/src/BizHawk.Emulation.Cores/Computers/Doom/DSDA.cs index cbb34ec5bd..2f5d0c92f9 100644 --- a/src/BizHawk.Emulation.Cores/Computers/Doom/DSDA.cs +++ b/src/BizHawk.Emulation.Cores/Computers/Doom/DSDA.cs @@ -216,10 +216,9 @@ namespace BizHawk.Emulation.Cores.Computers.Doom _elf.Seal(); } - // we have to set gamma after the core is sealed to ensure states don't depend on its initial value - // but if we set it during frame advance, first frame won't have it set - // so we set gamma here and force a video update, and other UpdateVideo() calls are blank - UpdateVideo(_settings.Gamma); + // we have to set render info after the core is sealed to ensure + // states don't depend on its initial value + InitVideo(); // Registering memory domains SetupMemoryDomains(); diff --git a/src/BizHawk.Emulation.Cores/Computers/Doom/LibDSDA.cs b/src/BizHawk.Emulation.Cores/Computers/Doom/LibDSDA.cs index 7731113efc..31f27b39e6 100644 --- a/src/BizHawk.Emulation.Cores/Computers/Doom/LibDSDA.cs +++ b/src/BizHawk.Emulation.Cores/Computers/Doom/LibDSDA.cs @@ -119,7 +119,10 @@ namespace BizHawk.Emulation.Cores.Computers.Doom public abstract bool dsda_init(ref InitSettings settings, int argc, string[] argv); [BizImport(CallingConvention.Cdecl)] - public abstract void dsda_get_video(int gamma, out VideoInfo info); + public abstract void dsda_init_video(ref PackedRenderInfo renderInfo); + + [BizImport(CallingConvention.Cdecl)] + public abstract void dsda_get_video(out VideoInfo videoInfo); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate int load_archive_cb(string filename, IntPtr buffer, int maxsize); diff --git a/waterbox/dsda/BizhawkInterface.c b/waterbox/dsda/BizhawkInterface.c index a7075aec5b..c90cec70eb 100644 --- a/waterbox/dsda/BizhawkInterface.c +++ b/waterbox/dsda/BizhawkInterface.c @@ -222,14 +222,8 @@ ECL_EXPORT void dsda_get_audio(int *n, void **buffer) *buffer = audioBuffer; } -ECL_EXPORT void dsda_get_video(int gamma, struct VideoInfo* vi) +ECL_EXPORT void dsda_get_video(struct VideoInfo* vi) { - if (gamma != -1) - { - dsda_UpdateIntConfig(dsda_config_usegamma, gamma, true); - headlessUpdateVideo(); - } - vi->buffer = (uint8_t *)headlessGetVideoBuffer(); vi->width = headlessGetVideoWidth(); vi->height = headlessGetVideoHeight(); @@ -250,9 +244,14 @@ ECL_EXPORT void dsda_get_video(int gamma, struct VideoInfo* vi) vi->paletteBuffer = _convertedPaletteBuffer; } +ECL_EXPORT void dsda_init_video(struct PackedRenderInfo *renderInfo) +{ + render_updates(renderInfo); + headlessUpdateVideo(); +} + ECL_EXPORT bool dsda_frame_advance(AutomapButtons buttons, struct PackedPlayerInput *player1Inputs, struct PackedPlayerInput *player2Inputs, struct PackedPlayerInput *player3Inputs, struct PackedPlayerInput *player4Inputs, struct PackedRenderInfo *renderInfo) { - // Live render changes if (renderInfo->RenderVideo) render_updates(renderInfo);