dsda: fix settings changes dying on loadstate

handle gamma changes on the hawk side
DoUpdate is no longer needed
This commit is contained in:
feos 2025-05-02 09:32:47 +03:00
parent 1ec5d2e81c
commit 8a70238e75
8 changed files with 83 additions and 85 deletions

Binary file not shown.

View File

@ -46,19 +46,25 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
| Convert.ToInt32(_syncSettings.Player3Present) << 2 | Convert.ToInt32(_syncSettings.Player3Present) << 2
| Convert.ToInt32(_syncSettings.Player4Present) << 3; | Convert.ToInt32(_syncSettings.Player4Present) << 3;
if (controller.IsPressed("Change Gamma")) commonButtons |= (1 << 0); if (controller.IsPressed("Change Gamma") && !_lastGammaInput)
if (controller.IsPressed("Automap Toggle")) commonButtons |= (1 << 1); {
if (controller.IsPressed("Automap +")) commonButtons |= (1 << 2); // cycle through [0 - 4]
if (controller.IsPressed("Automap -")) commonButtons |= (1 << 3); _settings.Gamma++;
if (controller.IsPressed("Automap Full/Zoom")) commonButtons |= (1 << 4); _settings.Gamma %= 5;
if (controller.IsPressed("Automap Follow")) commonButtons |= (1 << 5); }
if (controller.IsPressed("Automap Up")) commonButtons |= (1 << 6);
if (controller.IsPressed("Automap Down")) commonButtons |= (1 << 7); if (controller.IsPressed("Automap Toggle")) commonButtons |= (1 << 0);
if (controller.IsPressed("Automap Right")) commonButtons |= (1 << 8); if (controller.IsPressed("Automap +")) commonButtons |= (1 << 1);
if (controller.IsPressed("Automap Left")) commonButtons |= (1 << 9); if (controller.IsPressed("Automap -")) commonButtons |= (1 << 2);
if (controller.IsPressed("Automap Grid")) commonButtons |= (1 << 10); if (controller.IsPressed("Automap Full/Zoom")) commonButtons |= (1 << 3);
if (controller.IsPressed("Automap Mark")) commonButtons |= (1 << 11); if (controller.IsPressed("Automap Follow")) commonButtons |= (1 << 4);
if (controller.IsPressed("Automap Clear Marks")) commonButtons |= (1 << 12); if (controller.IsPressed("Automap Up")) commonButtons |= (1 << 5);
if (controller.IsPressed("Automap Down")) commonButtons |= (1 << 6);
if (controller.IsPressed("Automap Right")) commonButtons |= (1 << 7);
if (controller.IsPressed("Automap Left")) commonButtons |= (1 << 8);
if (controller.IsPressed("Automap Grid")) commonButtons |= (1 << 9);
if (controller.IsPressed("Automap Mark")) commonButtons |= (1 << 10);
if (controller.IsPressed("Automap Clear Marks")) commonButtons |= (1 << 11);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
@ -170,7 +176,6 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
MapOverlay = (int)_settings.MapOverlay, MapOverlay = (int)_settings.MapOverlay,
RenderVideo = renderVideo ? 1 : 0, RenderVideo = renderVideo ? 1 : 0,
RenderAudio = renderAudio ? 1 : 0, RenderAudio = renderAudio ? 1 : 0,
DoUpdate = _settings.DoUpdate ? 1 : 0,
ShowMessages = _settings.ShowMessages ? 1 : 0, ShowMessages = _settings.ShowMessages ? 1 : 0,
ReportSecrets = _settings.ReportSecrets ? 1 : 0, ReportSecrets = _settings.ReportSecrets ? 1 : 0,
DsdaExHud = _settings.DsdaExHud ? 1 : 0, DsdaExHud = _settings.DsdaExHud ? 1 : 0,
@ -190,11 +195,6 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
ref players[3], ref players[3],
ref renderInfo); ref renderInfo);
if (_settings.DoUpdate)
{
_settings.DoUpdate = false;
}
if (renderVideo) if (renderVideo)
UpdateVideo(); UpdateVideo();
@ -208,6 +208,8 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
LagCount++; LagCount++;
} }
_lastGammaInput = controller.IsPressed("Change Gamma");
return true; return true;
} }

View File

@ -146,9 +146,6 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
[CoreSettings] [CoreSettings]
public class DoomSettings public class DoomSettings
{ {
[JsonIgnore]
public bool DoUpdate = false;
[DisplayName("Internal Resolution Scale Factor")] [DisplayName("Internal Resolution Scale Factor")]
[Description("Which factor to increase internal resolution by [1 - 12]. Improves \"quality\" of the rendered image at the cost of accuracy.\n\nVanilla resolution is 320x200 resized to 4:3 DAR on a CRT monitor.\n\nRequires restart.")] [Description("Which factor to increase internal resolution by [1 - 12]. Improves \"quality\" of the rendered image at the cost of accuracy.\n\nVanilla resolution is 320x200 resized to 4:3 DAR on a CRT monitor.\n\nRequires restart.")]
[Range(1, 12)] [Range(1, 12)]
@ -156,18 +153,21 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
[TypeConverter(typeof(ConstrainedIntConverter))] [TypeConverter(typeof(ConstrainedIntConverter))]
public int ScaleFactor { get; set; } public int ScaleFactor { get; set; }
[JsonIgnore]
[DisplayName("Sfx Volume")] [DisplayName("Sfx Volume")]
[Description("Sound effects volume [0 - 15].")] [Description("Sound effects volume [0 - 15].")]
[Range(0, 15)] [Range(0, 15)]
[DefaultValue(8)] [DefaultValue(8)]
public int SfxVolume { get; set; } public int SfxVolume { get; set; }
[JsonIgnore]
[DisplayName("Music Volume")] [DisplayName("Music Volume")]
[Description("[0 - 15]")] [Description("[0 - 15]")]
[Range(0, 15)] [Range(0, 15)]
[DefaultValue(8)] [DefaultValue(8)]
public int MusicVolume { get; set; } public int MusicVolume { get; set; }
[JsonIgnore]
[DisplayName("Gamma Correction Level")] [DisplayName("Gamma Correction Level")]
[Description("Increases brightness [0 - 4].\n\nDefault value in vanilla is \"OFF\" (0).")] [Description("Increases brightness [0 - 4].\n\nDefault value in vanilla is \"OFF\" (0).")]
[Range(0, 4)] [Range(0, 4)]
@ -175,56 +175,67 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
[TypeConverter(typeof(ConstrainedIntConverter))] [TypeConverter(typeof(ConstrainedIntConverter))]
public int Gamma { get; set; } public int Gamma { get; set; }
[JsonIgnore]
[DisplayName("Show Messages")] [DisplayName("Show Messages")]
[Description("Displays messages about items you pick up.\n\nDefault value in vanilla is \"ON\".")] [Description("Displays messages about items you pick up.\n\nDefault value in vanilla is \"ON\".")]
[DefaultValue(true)] [DefaultValue(true)]
public bool ShowMessages { get; set; } public bool ShowMessages { get; set; }
[JsonIgnore]
[DisplayName("Report Revealed Secrets")] [DisplayName("Report Revealed Secrets")]
[Description("Shows an on-screen notification when revealing a secret.")] [Description("Shows an on-screen notification when revealing a secret.")]
[DefaultValue(false)] [DefaultValue(false)]
public bool ReportSecrets { get; set; } public bool ReportSecrets { get; set; }
[JsonIgnore]
[DisplayName("HUD Mode")] [DisplayName("HUD Mode")]
[Description("Sets heads-up display mode.")] [Description("Sets heads-up display mode.")]
[DefaultValue(HudMode.Vanilla)] [DefaultValue(HudMode.Vanilla)]
public HudMode HeadsUpMode { get; set; } public HudMode HeadsUpMode { get; set; }
[JsonIgnore]
[DisplayName("Extended HUD")] [DisplayName("Extended HUD")]
[Description("Shows DSDA-Doom-specific information above vanilla heads-up-display.")] [Description("Shows DSDA-Doom-specific information above vanilla heads-up-display.")]
[DefaultValue(false)] [DefaultValue(false)]
public bool DsdaExHud { get; set; } public bool DsdaExHud { get; set; }
[JsonIgnore]
[DisplayName("Display Coordinates")] [DisplayName("Display Coordinates")]
[Description("Shows player position, angle, velocity, and distance travelled per frame. Color indicates movement tiers: green - SR40, blue - SR50, red - turbo/wallrun.\n\nAvailable in vanilla via the IDMYPOS cheat code, however vanilla only shows angle, X, and Y.")] [Description("Shows player position, angle, velocity, and distance travelled per frame. Color indicates movement tiers: green - SR40, blue - SR50, red - turbo/wallrun.\n\nAvailable in vanilla via the IDMYPOS cheat code, however vanilla only shows angle, X, and Y.")]
[DefaultValue(false)] [DefaultValue(false)]
public bool DisplayCoordinates { get; set; } public bool DisplayCoordinates { get; set; }
[JsonIgnore]
[DisplayName("Display Commands")] [DisplayName("Display Commands")]
[Description("Shows input history on the screen. History size is 10, empty commands are excluded.")] [Description("Shows input history on the screen. History size is 10, empty commands are excluded.")]
[DefaultValue(false)] [DefaultValue(false)]
public bool DisplayCommands { get; set; } public bool DisplayCommands { get; set; }
[JsonIgnore]
[DisplayName("Automap Totals")] [DisplayName("Automap Totals")]
[Description("Shows counts for kills, items, and secrets on automap.")] [Description("Shows counts for kills, items, and secrets on automap.")]
[DefaultValue(false)] [DefaultValue(false)]
public bool MapTotals { get; set; } public bool MapTotals { get; set; }
[JsonIgnore]
[DisplayName("Automap Time")] [DisplayName("Automap Time")]
[Description("Shows elapsed time on automap.")] [Description("Shows elapsed time on automap.")]
[DefaultValue(false)] [DefaultValue(false)]
public bool MapTime { get; set; } public bool MapTime { get; set; }
[JsonIgnore]
[DisplayName("Automap Coordinates")] [DisplayName("Automap Coordinates")]
[Description("Shows in-level coordinates on automap.")] [Description("Shows in-level coordinates on automap.")]
[DefaultValue(false)] [DefaultValue(false)]
public bool MapCoordinates { get; set; } public bool MapCoordinates { get; set; }
[JsonIgnore]
[DisplayName("Automap Overlay")] [DisplayName("Automap Overlay")]
[Description("Shows automap on top of gameplay.")] [Description("Shows automap on top of gameplay.")]
[DefaultValue(MapOverlays.Disabled)] [DefaultValue(MapOverlays.Disabled)]
public MapOverlays MapOverlay { get; set; } public MapOverlays MapOverlay { get; set; }
[JsonIgnore]
[DisplayName("Automap Details")] [DisplayName("Automap Details")]
[Description("Exposes all linedefs and things.\n\nAvailable in vanilla via the IDDT cheat code.")] [Description("Exposes all linedefs and things.\n\nAvailable in vanilla via the IDDT cheat code.")]
[DefaultValue(MapDetail.Normal)] [DefaultValue(MapDetail.Normal)]
@ -255,7 +266,6 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
if (_settings.DisplayPlayer == 2 && !_syncSettings.Player2Present) throw new Exception($"Trying to set display player '{_settings.DisplayPlayer}' but it is not active in this movie."); if (_settings.DisplayPlayer == 2 && !_syncSettings.Player2Present) throw new Exception($"Trying to set display player '{_settings.DisplayPlayer}' but it is not active in this movie.");
if (_settings.DisplayPlayer == 3 && !_syncSettings.Player3Present) throw new Exception($"Trying to set display player '{_settings.DisplayPlayer}' but it is not active in this movie."); if (_settings.DisplayPlayer == 3 && !_syncSettings.Player3Present) throw new Exception($"Trying to set display player '{_settings.DisplayPlayer}' but it is not active in this movie.");
if (_settings.DisplayPlayer == 4 && !_syncSettings.Player4Present) throw new Exception($"Trying to set display player '{_settings.DisplayPlayer}' but it is not active in this movie."); if (_settings.DisplayPlayer == 4 && !_syncSettings.Player4Present) throw new Exception($"Trying to set display player '{_settings.DisplayPlayer}' but it is not active in this movie.");
_settings.DoUpdate = true;
return ret; return ret;
} }

View File

@ -12,15 +12,15 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
{ {
_elf.LoadStateBinary(reader); _elf.LoadStateBinary(reader);
_turnHeld[0] = reader.ReadInt32(); _turnHeld[0] = reader.ReadInt32();
_turnHeld[1] = reader.ReadInt32(); _turnHeld[1] = reader.ReadInt32();
_turnHeld[2] = reader.ReadInt32(); _turnHeld[2] = reader.ReadInt32();
_turnHeld[3] = reader.ReadInt32(); _turnHeld[3] = reader.ReadInt32();
_turnCarry = reader.ReadInt32(); _turnCarry = reader.ReadInt32();
_lastGammaInput = reader.ReadBoolean();
Frame = reader.ReadInt32(); Frame = reader.ReadInt32();
LagCount = reader.ReadInt32(); LagCount = reader.ReadInt32();
IsLagFrame = reader.ReadBoolean(); IsLagFrame = reader.ReadBoolean();
// any managed pointers that we sent to the core need to be resent now! // any managed pointers that we sent to the core need to be resent now!
UpdateVideo(); UpdateVideo();
@ -35,7 +35,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
writer.Write(_turnHeld[2]); writer.Write(_turnHeld[2]);
writer.Write(_turnHeld[3]); writer.Write(_turnHeld[3]);
writer.Write(_turnCarry); writer.Write(_turnCarry);
writer.Write(_lastGammaInput);
writer.Write(Frame); writer.Write(Frame);
writer.Write(LagCount); writer.Write(LagCount);
writer.Write(IsLagFrame); writer.Write(IsLagFrame);

View File

@ -107,6 +107,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
+ $"dsda_command_display { (_settings.DisplayCommands ? 1 : 0)}\n" + $"dsda_command_display { (_settings.DisplayCommands ? 1 : 0)}\n"
+ $"render_wipescreen { (_syncSettings.RenderWipescreen ? 1 : 0)}\n" + $"render_wipescreen { (_syncSettings.RenderWipescreen ? 1 : 0)}\n"
+ "render_stretchsky 0\n" + "render_stretchsky 0\n"
+ "boom_translucent_sprites 0\n"
+ "render_doom_lightmaps 1\n" + "render_doom_lightmaps 1\n"
+ "render_aspect 3\n" // 4:3, controls FOV on higher resolutions (see SetRatio() in the core) + "render_aspect 3\n" // 4:3, controls FOV on higher resolutions (see SetRatio() in the core)
+ "render_stretch_hud 0\n" + "render_stretch_hud 0\n"
@ -228,6 +229,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
private readonly byte[] _configFile; private readonly byte[] _configFile;
private int[] _turnHeld = [ 0, 0, 0, 0 ]; private int[] _turnHeld = [ 0, 0, 0, 0 ];
private int _turnCarry = 0; // Chocolate Doom mouse behaviour (enabled in upstream by default) private int _turnCarry = 0; // Chocolate Doom mouse behaviour (enabled in upstream by default)
private bool _lastGammaInput = false;
private List<string> _args; private List<string> _args;
private List<IRomAsset> _wadFiles; private List<IRomAsset> _wadFiles;
private LibDSDA.GameMode _gameMode; private LibDSDA.GameMode _gameMode;

View File

@ -59,7 +59,6 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct PackedRenderInfo public struct PackedRenderInfo
{ {
public int DoUpdate;
public int RenderVideo; public int RenderVideo;
public int RenderAudio; public int RenderAudio;
public int SfxVolume; public int SfxVolume;

View File

@ -2,56 +2,13 @@
bool foundIWAD = false; bool foundIWAD = false;
bool wipeDone = true; bool wipeDone = true;
CommonButtons last_buttons = { 0 }; AutomapButtons last_buttons = { 0 };
void render_updates(struct PackedRenderInfo *renderInfo) void render_updates(struct PackedRenderInfo *renderInfo)
{ {
if (renderInfo->DoUpdate) if (renderInfo->Gamma != dsda_IntConfig(dsda_config_usegamma))
{ {
if (renderInfo->Gamma != dsda_IntConfig(dsda_config_usegamma)) dsda_UpdateIntConfig(dsda_config_usegamma, renderInfo->Gamma, true);
{
dsda_UpdateIntConfig(dsda_config_usegamma, renderInfo->Gamma, true);
dsda_AddMessage(usegamma == 0 ? GAMMALVL0 :
usegamma == 1 ? GAMMALVL1 :
usegamma == 2 ? GAMMALVL2 :
usegamma == 3 ? GAMMALVL3 :
GAMMALVL4);
}
if (renderInfo->MapOverlay != dsda_IntConfig(dsda_config_automap_overlay))
{
dsda_UpdateIntConfig(dsda_config_automap_overlay, renderInfo->MapOverlay, true);
dsda_AddMessage(automap_overlay == 0 ? AMSTR_OVERLAYOFF :
automap_overlay == 1 ? AMSTR_OVERLAYON :
"Overlay Mode Dark");
}
if (renderInfo->ShowMessages != dsda_ShowMessages())
dsda_UpdateIntConfig(dsda_config_show_messages, renderInfo->ShowMessages, true);
dsda_UpdateIntConfig(dsda_config_screenblocks, renderInfo->HeadsUpMode != HUD_VANILLA ? 11 : 10, true);
dsda_UpdateIntConfig(dsda_config_hud_displayed, renderInfo->HeadsUpMode == HUD_NONE ? 0 : 1, true);
dsda_UpdateIntConfig(dsda_config_sfx_volume, renderInfo->SfxVolume, true);
dsda_UpdateIntConfig(dsda_config_music_volume, renderInfo->MusicVolume, true);
dsda_UpdateIntConfig(dsda_config_hudadd_secretarea, renderInfo->ReportSecrets, true);
dsda_UpdateIntConfig(dsda_config_exhud, renderInfo->DsdaExHud, true);
dsda_UpdateIntConfig(dsda_config_coordinate_display, renderInfo->DisplayCoordinates, true);
dsda_UpdateIntConfig(dsda_config_command_display, renderInfo->DisplayCommands, true);
dsda_UpdateIntConfig(dsda_config_map_totals, renderInfo->MapTotals, true);
dsda_UpdateIntConfig(dsda_config_map_time, renderInfo->MapTime, true);
dsda_UpdateIntConfig(dsda_config_map_coordinates, renderInfo->MapCoordinates, true);
}
}
void common_input(CommonButtons buttons)
{
static int bigstate = 0;
m_paninc.y = 0;
m_paninc.x = 0;
if (buttons.ChangeGamma && !last_buttons.ChangeGamma)
{
dsda_CycleConfig(dsda_config_usegamma, true);
dsda_AddMessage(usegamma == 0 ? GAMMALVL0 : dsda_AddMessage(usegamma == 0 ? GAMMALVL0 :
usegamma == 1 ? GAMMALVL1 : usegamma == 1 ? GAMMALVL1 :
usegamma == 2 ? GAMMALVL2 : usegamma == 2 ? GAMMALVL2 :
@ -59,6 +16,36 @@ void common_input(CommonButtons buttons)
GAMMALVL4); GAMMALVL4);
} }
if (renderInfo->MapOverlay != dsda_IntConfig(dsda_config_automap_overlay))
{
dsda_UpdateIntConfig(dsda_config_automap_overlay, renderInfo->MapOverlay, true);
dsda_AddMessage(automap_overlay == 0 ? AMSTR_OVERLAYOFF :
automap_overlay == 1 ? AMSTR_OVERLAYON :
"Overlay Mode Dark");
}
if (renderInfo->ShowMessages != dsda_ShowMessages())
dsda_UpdateIntConfig(dsda_config_show_messages, renderInfo->ShowMessages, true);
dsda_UpdateIntConfig(dsda_config_screenblocks, renderInfo->HeadsUpMode != HUD_VANILLA ? 11 : 10, true);
dsda_UpdateIntConfig(dsda_config_hud_displayed, renderInfo->HeadsUpMode == HUD_NONE ? 0 : 1, true);
dsda_UpdateIntConfig(dsda_config_sfx_volume, renderInfo->SfxVolume, true);
dsda_UpdateIntConfig(dsda_config_music_volume, renderInfo->MusicVolume, true);
dsda_UpdateIntConfig(dsda_config_hudadd_secretarea, renderInfo->ReportSecrets, true);
dsda_UpdateIntConfig(dsda_config_exhud, renderInfo->DsdaExHud, true);
dsda_UpdateIntConfig(dsda_config_coordinate_display, renderInfo->DisplayCoordinates, true);
dsda_UpdateIntConfig(dsda_config_command_display, renderInfo->DisplayCommands, true);
dsda_UpdateIntConfig(dsda_config_map_totals, renderInfo->MapTotals, true);
dsda_UpdateIntConfig(dsda_config_map_time, renderInfo->MapTime, true);
dsda_UpdateIntConfig(dsda_config_map_coordinates, renderInfo->MapCoordinates, true);
}
void automap_inputs(AutomapButtons buttons)
{
static int bigstate = 0;
m_paninc.y = 0;
m_paninc.x = 0;
if (buttons.AutomapToggle && !last_buttons.AutomapToggle) if (buttons.AutomapToggle && !last_buttons.AutomapToggle)
{ {
if (automap_active) if (automap_active)
@ -196,14 +183,14 @@ ECL_EXPORT void dsda_get_video(int *w, int *h, int *pitch, uint8_t **buffer, int
*paletteBuffer = _convertedPaletteBuffer; *paletteBuffer = _convertedPaletteBuffer;
} }
ECL_EXPORT bool dsda_frame_advance(CommonButtons commonButtons, struct PackedPlayerInput *player1Inputs, struct PackedPlayerInput *player2Inputs, struct PackedPlayerInput *player3Inputs, struct PackedPlayerInput *player4Inputs, struct PackedRenderInfo *renderInfo) ECL_EXPORT bool dsda_frame_advance(AutomapButtons buttons, struct PackedPlayerInput *player1Inputs, struct PackedPlayerInput *player2Inputs, struct PackedPlayerInput *player3Inputs, struct PackedPlayerInput *player4Inputs, struct PackedRenderInfo *renderInfo)
{ {
// On-the-fly render changes // On-the-fly render changes
render_updates(renderInfo); render_updates(renderInfo);
// Setting inputs // Setting inputs
headlessClearTickCommand(); headlessClearTickCommand();
common_input(commonButtons); automap_inputs(buttons);
dsda_reveal_map = renderInfo->MapDetails; dsda_reveal_map = renderInfo->MapDetails;

View File

@ -112,7 +112,6 @@ typedef union
{ {
struct struct
{ {
bool ChangeGamma:1;
bool AutomapToggle:1; bool AutomapToggle:1;
bool AutomapZoomIn:1; bool AutomapZoomIn:1;
bool AutomapZoomOut:1; bool AutomapZoomOut:1;
@ -127,7 +126,7 @@ typedef union
bool AutomapClearMarks:1; bool AutomapClearMarks:1;
}; };
uint32_t data; uint32_t data;
} CommonButtons; } AutomapButtons;
struct InitSettings struct InitSettings
{ {
@ -158,7 +157,6 @@ struct PackedPlayerInput
struct PackedRenderInfo struct PackedRenderInfo
{ {
int DoUpdate;
int RenderVideo; int RenderVideo;
int RenderAudio; int RenderAudio;
int SfxVolume; int SfxVolume;