Correct neutral Y position for SNES lightguns (fixes old BSNES lightguns), add in a controller button for offscreen shots for Snes9x and new BSNES, add UI option to disable drawing lightgun cursor for new BSNES

This commit is contained in:
CasualPokePlayer 2023-03-30 20:25:26 -07:00
parent 6ea7fd04d8
commit c7ea4cbd0e
7 changed files with 471 additions and 440 deletions

View File

@ -57,6 +57,7 @@
this.cbNoPPUSpriteLimit = new System.Windows.Forms.CheckBox();
this.AspectRatioCorrectionBox = new System.Windows.Forms.ComboBox();
this.cbShowOverscan = new System.Windows.Forms.CheckBox();
this.cbShowCursor = new System.Windows.Forms.CheckBox();
this.SatellaviewCartridgeBox = new System.Windows.Forms.ComboBox();
this.lblSatellaviewCartridge = new BizHawk.WinForms.Controls.LocLabelEx();
this.lblAspectRatioCorrection = new BizHawk.WinForms.Controls.LocLabelEx();
@ -69,7 +70,7 @@
// btnOk
//
this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnOk.Location = new System.Drawing.Point(136, 392);
this.btnOk.Location = new System.Drawing.Point(136, 405);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(75, 23);
this.btnOk.TabIndex = 26;
@ -81,7 +82,7 @@
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(217, 392);
this.btnCancel.Location = new System.Drawing.Point(217, 405);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 0;
@ -117,7 +118,7 @@
this.groupBox1.Controls.Add(this.Obj3Checkbox);
this.groupBox1.Controls.Add(this.Obj2Checkbox);
this.groupBox1.Controls.Add(this.Obj1Checkbox);
this.groupBox1.Location = new System.Drawing.Point(18, 269);
this.groupBox1.Location = new System.Drawing.Point(18, 282);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(274, 115);
this.groupBox1.TabIndex = 13;
@ -263,7 +264,7 @@
//
this.EntropyBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.EntropyBox.FormattingEnabled = true;
this.EntropyBox.Location = new System.Drawing.Point(17, 198);
this.EntropyBox.Location = new System.Drawing.Point(16, 215);
this.EntropyBox.Name = "EntropyBox";
this.EntropyBox.Size = new System.Drawing.Size(128, 21);
this.EntropyBox.TabIndex = 10;
@ -272,7 +273,7 @@
//
this.RegionBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.RegionBox.FormattingEnabled = true;
this.RegionBox.Location = new System.Drawing.Point(162, 243);
this.RegionBox.Location = new System.Drawing.Point(162, 255);
this.RegionBox.Name = "RegionBox";
this.RegionBox.Size = new System.Drawing.Size(128, 21);
this.RegionBox.TabIndex = 13;
@ -352,7 +353,7 @@
//
this.AspectRatioCorrectionBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.AspectRatioCorrectionBox.FormattingEnabled = true;
this.AspectRatioCorrectionBox.Location = new System.Drawing.Point(162, 198);
this.AspectRatioCorrectionBox.Location = new System.Drawing.Point(161, 215);
this.AspectRatioCorrectionBox.Name = "AspectRatioCorrectionBox";
this.AspectRatioCorrectionBox.Size = new System.Drawing.Size(128, 21);
this.AspectRatioCorrectionBox.TabIndex = 11;
@ -367,36 +368,46 @@
this.cbShowOverscan.Text = "Show Overscan";
this.cbShowOverscan.UseVisualStyleBackColor = true;
//
// cbShowCursor
//
this.cbShowCursor.AutoSize = true;
this.cbShowCursor.Location = new System.Drawing.Point(16, 176);
this.cbShowCursor.Name = "cbShowCursor";
this.cbShowCursor.Size = new System.Drawing.Size(130, 17);
this.cbShowCursor.TabIndex = 27;
this.cbShowCursor.Text = "Show Lightgun Cursor";
this.cbShowCursor.UseVisualStyleBackColor = true;
//
// SatellaviewCartridgeBox
//
this.SatellaviewCartridgeBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.SatellaviewCartridgeBox.FormattingEnabled = true;
this.SatellaviewCartridgeBox.Location = new System.Drawing.Point(17, 243);
this.SatellaviewCartridgeBox.Location = new System.Drawing.Point(16, 255);
this.SatellaviewCartridgeBox.Name = "SatellaviewCartridgeBox";
this.SatellaviewCartridgeBox.Size = new System.Drawing.Size(128, 21);
this.SatellaviewCartridgeBox.TabIndex = 12;
//
// lblSatellaviewCartridge
//
this.lblSatellaviewCartridge.Location = new System.Drawing.Point(14, 227);
this.lblSatellaviewCartridge.Location = new System.Drawing.Point(14, 239);
this.lblSatellaviewCartridge.Name = "lblSatellaviewCartridge";
this.lblSatellaviewCartridge.Text = "Satellaview cartridge";
//
// lblAspectRatioCorrection
//
this.lblAspectRatioCorrection.Location = new System.Drawing.Point(159, 182);
this.lblAspectRatioCorrection.Location = new System.Drawing.Point(159, 198);
this.lblAspectRatioCorrection.Name = "lblAspectRatioCorrection";
this.lblAspectRatioCorrection.Text = "Aspect Ratio Correction";
//
// lblRegion
//
this.lblRegion.Location = new System.Drawing.Point(159, 227);
this.lblRegion.Location = new System.Drawing.Point(159, 239);
this.lblRegion.Name = "lblRegion";
this.lblRegion.Text = "Region";
//
// lblEntropy
//
this.lblEntropy.Location = new System.Drawing.Point(14, 182);
this.lblEntropy.Location = new System.Drawing.Point(13, 198);
this.lblEntropy.Name = "lblEntropy";
this.lblEntropy.Text = "Entropy";
//
@ -414,9 +425,10 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(304, 423);
this.ClientSize = new System.Drawing.Size(304, 436);
this.Controls.Add(this.SatellaviewCartridgeBox);
this.Controls.Add(this.lblSatellaviewCartridge);
this.Controls.Add(this.cbShowCursor);
this.Controls.Add(this.cbShowOverscan);
this.Controls.Add(this.AspectRatioCorrectionBox);
this.Controls.Add(this.lblAspectRatioCorrection);
@ -486,6 +498,7 @@
private System.Windows.Forms.ComboBox AspectRatioCorrectionBox;
private WinForms.Controls.LocLabelEx lblAspectRatioCorrection;
private System.Windows.Forms.CheckBox cbShowOverscan;
private System.Windows.Forms.CheckBox cbShowCursor;
private WinForms.Controls.LocLabelEx lblSatellaviewCartridge;
private System.Windows.Forms.ComboBox SatellaviewCartridgeBox;
}

View File

@ -37,6 +37,7 @@ namespace BizHawk.Client.EmuHawk
CropSGBFrame = s.CropSGBFrame,
NoPPUSpriteLimit = s.NoPPUSpriteLimit,
ShowOverscan = s.ShowOverscan,
ShowCursor = s.ShowCursor,
Hotfixes = ss.Hotfixes,
FastPPU = ss.FastPPU,
FastDSP = ss.FastDSP,
@ -63,6 +64,7 @@ namespace BizHawk.Client.EmuHawk
s.CropSGBFrame = dlg.CropSGBFrame;
s.NoPPUSpriteLimit = dlg.NoPPUSpriteLimit;
s.ShowOverscan = dlg.ShowOverscan;
s.ShowCursor = dlg.ShowCursor;
s.AspectRatioCorrection = dlg.AspectRatioCorrection;
ss.Entropy = dlg.Entropy;
ss.RegionOverride = dlg.RegionOverride;
@ -113,6 +115,12 @@ namespace BizHawk.Client.EmuHawk
init => cbShowOverscan.Checked = value;
}
private bool ShowCursor
{
get => cbShowCursor.Checked;
init => cbShowCursor.Checked = value;
}
private BsnesApi.ASPECT_RATIO_CORRECTION AspectRatioCorrection => (BsnesApi.ASPECT_RATIO_CORRECTION)AspectRatioCorrectionBox.SelectedIndex;
private bool Hotfixes

View File

@ -27,6 +27,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
public abstract void snes_set_ppu_sprite_limit_enabled(bool enabled);
[BizImport(CallingConvention.Cdecl)]
public abstract void snes_set_overscan_enabled(bool enabled);
[BizImport(CallingConvention.Cdecl)]
public abstract void snes_set_cursor_enabled(bool enabled);
[BizImport(CallingConvention.Cdecl)]
public abstract IntPtr snes_get_audiobuffer_and_size(out int size);

View File

@ -303,13 +303,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
internal class BsnesSuperScopeController : IBsnesController
{
private static readonly ControllerDefinition _definition = new ControllerDefinition("(SNES Controller fragment)")
{ BoolButtons = { "0Trigger", "0Cursor", "0Turbo", "0Pause" } }
{ BoolButtons = { "0Trigger", "0Cursor", "0Turbo", "0Pause", "0Offscreen" } }
.AddLightGun("0Scope {0}");
public ControllerDefinition Definition => _definition;
public short GetState(IController controller, int index, int id)
{
if (id is 0 or 1 && controller.IsPressed("0Offscreen"))
return -1;
return id switch
{
0 => (short) controller.AxisValue("0Scope X"),
@ -326,11 +329,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
{
Definition = chained
? new ControllerDefinition("(SNES Controller fragment)")
{ BoolButtons = { "0Trigger", "0Start", "1Trigger", "1Start" } }
{ BoolButtons = { "0Trigger", "0Start", "0Offscreen", "1Trigger", "1Start", "1Offscreen" } }
.AddLightGun("0Justifier {0}")
.AddLightGun("1Justifier {0}")
: new ControllerDefinition("(SNES Controller fragment)")
{BoolButtons = { "0Trigger", "0Start"} }
{ BoolButtons = { "0Trigger", "0Start", "0Offscreen" } }
.AddLightGun("0Justifier {0}");
_chained = chained;
}
@ -344,11 +347,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
if (index == 1 && !_chained)
return 0;
if (id is 0 or 1 && controller.IsPressed($"{index}Offscreen"))
return -1;
return id switch
{
0 => (short) controller.AxisValue($"{index}Justifier X"),
1 => (short) controller.AxisValue($"{index}Justifier Y"),
2 or 3 => (short) (controller.IsPressed(Definition.BoolButtons[index * 2 + id - 2]) ? 1 : 0),
2 or 3 => (short) (controller.IsPressed(Definition.BoolButtons[index * 3 + id - 2]) ? 1 : 0),
_ => 0
};
}

View File

@ -54,6 +54,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
Api.core.snes_set_layer_enables(ref enables);
Api.core.snes_set_ppu_sprite_limit_enabled(!o.NoPPUSpriteLimit);
Api.core.snes_set_overscan_enabled(o.ShowOverscan);
Api.core.snes_set_cursor_enabled(o.ShowCursor);
}
_settings = o;
@ -92,6 +93,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
public bool CropSGBFrame { get; set; }
public bool NoPPUSpriteLimit { get; set; }
public bool ShowOverscan { get; set; }
public bool ShowCursor { get; set; }
public BsnesApi.ASPECT_RATIO_CORRECTION AspectRatioCorrection { get; set; } = BsnesApi.ASPECT_RATIO_CORRECTION.Auto;
}

View File

@ -90,12 +90,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
internal static class SNESControllerDefExtensions
{
/// <remarks>
/// problem: when you're in 240 line mode, the limit on Y needs to be 240. when you're in 224 mode, it needs to be 224.
/// problem: when you're in 240 line mode, the limit on Y needs to be 0-239. when you're in 224 mode, it needs to be 0-224.
/// perhaps the deck needs to account for this...
/// for reference Snes9x is always in 224 mode
/// </remarks>
public static ControllerDefinition AddLightGun(this ControllerDefinition def, string nameFormat)
=> def.AddXYPair(nameFormat, AxisPairOrientation.RightAndUp, 0.RangeTo(256), 128, 0.RangeTo(240), 0); //TODO verify direction against hardware
=> def.AddXYPair(nameFormat, AxisPairOrientation.RightAndDown, 0.RangeTo(255), 128, 0.RangeTo(239), 120); //TODO verify direction against hardware
}
public interface ILibsnesController
@ -331,7 +331,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public LibsnesApi.SNES_INPUT_PORT PortType => LibsnesApi.SNES_INPUT_PORT.SuperScope;
private static readonly ControllerDefinition _definition
= new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Cursor", "0Turbo", "0Pause" } }
= new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Cursor", "0Turbo", "0Pause", "0Offscreen" } }
.AddLightGun("0Scope {0}");
public ControllerDefinition Definition => _definition;
@ -343,11 +343,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
default:
return 0;
case 0:
var x = (int)controller.AxisValue("0Scope X");
return (short)x;
if (controller.IsPressed("0Offscreen")) return -1;
return (short)controller.AxisValue("0Scope X");
case 1:
var y = (int)controller.AxisValue("0Scope Y");
return (short)y;
if (controller.IsPressed("0Offscreen")) return -1;
return (short)controller.AxisValue("0Scope Y");
case 2:
return (short)(controller.IsPressed("0Trigger") ? 1 : 0);
case 3:
@ -365,7 +365,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public LibsnesApi.SNES_INPUT_PORT PortType => LibsnesApi.SNES_INPUT_PORT.Justifier;
private static readonly ControllerDefinition _definition
= new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Start", "1Trigger", "1Start" } }
= new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Start", "0Offscreen", "1Trigger", "1Start", "1Offscreen" } }
.AddLightGun("0Justifier {0}")
.AddLightGun("1Justifier {0}");
@ -378,11 +378,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
default:
return 0;
case 0:
var x = (int)controller.AxisValue(index + "Justifier X");
return (short)x;
if (controller.IsPressed(index + "Offscreen")) return -1;
return (short)controller.AxisValue(index + "Justifier X");
case 1:
var y = (int)controller.AxisValue(index + "Justifier Y");
return (short)y;
if (controller.IsPressed(index + "Offscreen")) return -1;
return (short)controller.AxisValue(index + "Justifier Y");
case 2:
return (short)(controller.IsPressed(index + "Trigger") ? 1 : 0);
case 3:

View File

@ -198,7 +198,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
public void ApplyState(IController controller, short[] input, int offset)
{
foreach (var s in Definition.Axes.Keys)
input[offset++] = (short)(controller.AxisValue(s));
input[offset++] = (short)controller.AxisValue(s);
foreach (var s in Definition.BoolButtons)
input[offset++] = (short)(controller.IsPressed(s) ? 1 : 0);
}
@ -208,7 +208,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
{
private static readonly ControllerDefinition _definition
= new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Mouse Left", "0Mouse Right" } }
.AddXYPair("0Mouse {0}", AxisPairOrientation.RightAndUp, (-127).RangeTo(127), 0); //TODO verify direction against hardware
.AddXYPair("0Mouse {0}", AxisPairOrientation.RightAndDown, (-127).RangeTo(127), 0); //TODO verify direction against hardware
public override ControllerDefinition Definition => _definition;
}
@ -216,7 +216,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
private class SuperScope : Analog
{
private static readonly ControllerDefinition _definition
= new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Cursor", "0Turbo", "0Pause" } }
= new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Cursor", "0Turbo", "0Pause", "0Offscreen" } }
.AddLightGun("0Scope {0}");
public override ControllerDefinition Definition => _definition;
@ -225,7 +225,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
private class Justifier : Analog
{
private static readonly ControllerDefinition _definition
= new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Start" } }
= new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Start", "0Offscreen" } }
.AddLightGun("0Justifier {0}");
public override ControllerDefinition Definition => _definition;