Skip to content

Commit

Permalink
BSNESv115+: add option for disabling ppu sprite limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Morilli committed Nov 10, 2022
1 parent 066297d commit c21fedc
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 102 deletions.
Binary file modified Assets/dll/bsnes.wbx.zst
Binary file not shown.
137 changes: 75 additions & 62 deletions src/BizHawk.Client.EmuHawk/config/SNES/BSNESOptions.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/BizHawk.Client.EmuHawk/config/SNES/BSNESOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static DialogResult DoSettingsDialog(IDialogParent dialogParent, ISetting
{
AlwaysDoubleSize = s.AlwaysDoubleSize,
CropSGBFrame = s.CropSGBFrame,
NoPPUSpriteLimit = s.NoPPUSpriteLimit,
Entropy = ss.Entropy,
RegionOverride = ss.RegionOverride,
Hotfixes = ss.Hotfixes,
Expand All @@ -48,6 +49,7 @@ public static DialogResult DoSettingsDialog(IDialogParent dialogParent, ISetting

s.AlwaysDoubleSize = dlg.AlwaysDoubleSize;
s.CropSGBFrame = dlg.CropSGBFrame;
s.NoPPUSpriteLimit = dlg.NoPPUSpriteLimit;
ss.Entropy = dlg.Entropy;
ss.RegionOverride = dlg.RegionOverride;
ss.Hotfixes = dlg.Hotfixes;
Expand Down Expand Up @@ -84,6 +86,12 @@ private bool CropSGBFrame
init => cbCropSGBFrame.Checked = value;
}

private bool NoPPUSpriteLimit
{
get => cbNoPPUSpriteLimit.Checked;
init => cbNoPPUSpriteLimit.Checked = value;
}

private bool Hotfixes
{
get => cbGameHotfixes.Checked;
Expand All @@ -93,7 +101,7 @@ private bool Hotfixes
private bool FastPPU
{
get => cbFastPPU.Checked;
init => cbDoubleSize.Enabled = cbFastPPU.Checked = value;
init => cbDoubleSize.Enabled = cbNoPPUSpriteLimit.Enabled = cbFastPPU.Checked = value;
}

private bool FastDSP
Expand Down Expand Up @@ -154,7 +162,7 @@ private void BtnCancel_Click(object sender, EventArgs e)

private void FastPPU_CheckedChanged(object sender, EventArgs e)
{
cbDoubleSize.Enabled = cbFastPPU.Checked;
cbDoubleSize.Enabled = cbNoPPUSpriteLimit.Enabled = cbFastPPU.Checked;
}
}
}
19 changes: 9 additions & 10 deletions src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public abstract class BsnesCoreImpl
public abstract void snes_set_trace_enabled(bool enabled);
[BizImport(CallingConvention.Cdecl)]
public abstract void snes_set_hooks_enabled(bool readHookEnabled, bool writeHookEnabled, bool executeHookEnabled);
[BizImport(CallingConvention.Cdecl)]
public abstract void snes_set_ppu_sprite_limit_enabled(bool enabled);

[BizImport(CallingConvention.Cdecl)]
public abstract IntPtr snes_get_audiobuffer_and_size(out int size);
Expand Down Expand Up @@ -178,7 +180,6 @@ public void Dispose()
exe.Dispose();
exe = null;
core = null;
// serializedSize = 0;
}
}

Expand Down Expand Up @@ -283,27 +284,25 @@ public void Seal()
_readonlyFiles.RemoveAll(s => !s.StartsWith("msu1/"));
}

// TODO: confirm that the serializedSize is CONSTANT for any given game,
// else this might be problematic
// private int serializedSize;// = 284275;
// private int serializedSize;

public void SaveStateBinary(BinaryWriter writer)
{
// if (serializedSize == 0)
// serializedSize = _core.snes_serialized_size();
// TODO: do some profiling and testing to check whether this is actually better than _exe.SaveStateBinary(writer);
// re-adding bsnes's own serialization will need to be done once it's confirmed to be deterministic, aka after libco update
// commented code left for debug purposes; created savestates are native bsnes savestates
// and therefor compatible across minor core updates

// if (serializedSize == 0) serializedSize = core.snes_serialized_size();
// byte[] serializedData = new byte[serializedSize];
// _core.snes_serialize(serializedData, serializedSize);
// core.snes_serialize(serializedData, serializedSize);
// writer.Write(serializedData);
exe.SaveStateBinary(writer);
}

public void LoadStateBinary(BinaryReader reader)
{
// if (serializedSize == 0) serializedSize = core.snes_serialized_size();
// byte[] serializedData = reader.ReadBytes(serializedSize);
// _core.snes_unserialize(serializedData, serializedSize);
// core.snes_unserialize(serializedData, serializedSize);
exe.LoadStateBinary(reader);
core.snes_msu_sync();
}
Expand Down
Loading

0 comments on commit c21fedc

Please sign in to comment.