Use ranges
This commit is contained in:
parent
0f1fa1531f
commit
dd4f9aaf64
|
@ -1,4 +1,6 @@
|
|||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
|
@ -51,7 +53,7 @@ namespace BizHawk.Client.Common
|
|||
return false;
|
||||
}
|
||||
|
||||
if (slot < 0 || slot > 10)
|
||||
if (!0.RangeTo(10).Contains(slot))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -70,33 +72,10 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void ToggleRedo(int slot)
|
||||
{
|
||||
if (slot < 0 || slot > 9)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Global.MovieSession.Movie is TasMovie tasMovie)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_redo[slot] ^= true;
|
||||
if (0.RangeTo(9).Contains(slot) && !(Global.MovieSession.Movie is TasMovie)) _redo[slot] ^= true;
|
||||
}
|
||||
|
||||
public bool IsRedo(int slot)
|
||||
{
|
||||
if (slot < 0 || slot > 9)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Global.MovieSession.Movie is TasMovie tasMovie)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _redo[slot];
|
||||
}
|
||||
public bool IsRedo(int slot) => 0.RangeTo(9).Contains(slot) && !(Global.MovieSession.Movie is TasMovie) && _redo[slot];
|
||||
|
||||
public void SwapBackupSavestate(string path)
|
||||
{
|
||||
|
|
|
@ -3,6 +3,8 @@ using System.Globalization;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public class SubtitleList : List<Subtitle>
|
||||
|
@ -16,10 +18,7 @@ namespace BizHawk.Client.Common
|
|||
AddColorTag = false;
|
||||
}
|
||||
|
||||
public IEnumerable<Subtitle> GetSubtitles(int frame)
|
||||
{
|
||||
return this.Where(t => frame >= t.Frame && frame <= t.Frame + t.Duration);
|
||||
}
|
||||
public IEnumerable<Subtitle> GetSubtitles(int frame) => this.Where(t => t.Frame.RangeTo(t.Frame + t.Duration).Contains(frame));
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public partial class Bk2Movie
|
||||
|
@ -162,7 +164,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
var stateFramei = stateFrame ?? 0;
|
||||
|
||||
if (stateFramei > 0 && stateFramei < Log.Count)
|
||||
if (stateFramei.StrictlyBoundedBy(0.RangeTo(Log.Count)))
|
||||
{
|
||||
if (!Global.Config.VBAStyleMovieLoadState)
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.Globalization;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||
|
||||
|
@ -346,7 +347,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
var stateFrameValue = stateFrame ?? 0;
|
||||
|
||||
if (stateFrameValue > 0 && stateFrameValue < Log.Count)
|
||||
if (stateFrameValue.StrictlyBoundedBy(0.RangeTo(Log.Count)))
|
||||
{
|
||||
if (!Global.Config.VBAStyleMovieLoadState)
|
||||
{
|
||||
|
@ -379,15 +380,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
#region Branches
|
||||
|
||||
public TasBranch GetBranch(int index)
|
||||
{
|
||||
if (index >= Branches.Count || index < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return Branches[index];
|
||||
}
|
||||
public TasBranch GetBranch(int index) => 0.RangeToExclusive(Branches.Count).Contains(index) ? Branches[index] : null;
|
||||
|
||||
public TasBranch GetBranch(Guid id)
|
||||
{
|
||||
|
|
|
@ -159,7 +159,7 @@ namespace BizHawk.Client.Common
|
|||
break;
|
||||
}
|
||||
|
||||
if (_mHead.Value.EndExclusive > _mTail.Value.Index && _mHead.Value.Index <= _mTail.Value.Index && _mHead != _mTail)
|
||||
if (_mHead.Value.Index.RangeToExclusive(_mHead.Value.EndExclusive).Contains(_mTail.Value.Index) && _mHead != _mTail)
|
||||
{
|
||||
var nextTail = _mTail.Next;
|
||||
Size -= _mTail.Value.Length;
|
||||
|
|
|
@ -11,6 +11,7 @@ using ICSharpCode.SharpZipLib.Zip.Compression;
|
|||
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
@ -548,7 +549,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
// the sampleRate limits are arbitrary, just to catch things which are probably silly-wrong
|
||||
// if a larger range of sampling rates is needed, it should be supported
|
||||
if (sampleRate < 8000 || sampleRate > 96000 || channels < 1 || channels > 2 || bits != 16)
|
||||
if (!8000.RangeTo(96000).Contains(sampleRate) || !1.RangeTo(2).Contains(channels) || bits != 16)
|
||||
{
|
||||
throw new ArgumentException("Audio parameters out of range!");
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Drawing;
|
|||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using BizHawk.Client.EmuHawk.WinFormExtensions;
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
@ -519,19 +520,18 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void DoSelectionBG(List<RollColumn> visibleColumns, Rectangle rect)
|
||||
{
|
||||
Color rowColor = Color.White;
|
||||
int firstVisibleRow = FirstVisibleRow;
|
||||
int lastVisibleRow = LastVisibleRow;
|
||||
var visibleRows = FirstVisibleRow.RangeTo(LastVisibleRow);
|
||||
int lastRow = -1;
|
||||
foreach (Cell cell in _selectedItems)
|
||||
{
|
||||
if (!cell.RowIndex.HasValue || cell.RowIndex > lastVisibleRow || cell.RowIndex < firstVisibleRow || !VisibleColumns.Contains(cell.Column))
|
||||
if (!cell.RowIndex.HasValue || !visibleRows.Contains(cell.RowIndex.Value) || !VisibleColumns.Contains(cell.Column))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Cell relativeCell = new Cell
|
||||
{
|
||||
RowIndex = cell.RowIndex - firstVisibleRow,
|
||||
RowIndex = cell.RowIndex - visibleRows.Start,
|
||||
Column = cell.Column,
|
||||
};
|
||||
relativeCell.RowIndex -= CountLagFramesAbsolute(relativeCell.RowIndex.Value);
|
||||
|
|
|
@ -7,6 +7,7 @@ using System.Windows.Forms;
|
|||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Client.EmuHawk.CustomControls;
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
@ -783,6 +784,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
// Small jump, more accurate
|
||||
var range = 0.RangeTo(_lagFrames[VisibleRows - halfRow]);
|
||||
int lastVisible = LastFullyVisibleRow;
|
||||
do
|
||||
{
|
||||
|
@ -798,22 +800,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
SetLagFramesArray();
|
||||
lastVisible = LastFullyVisibleRow;
|
||||
}
|
||||
while ((lastVisible - value < 0 || lastVisible - value > _lagFrames[VisibleRows - halfRow]) && FirstVisibleRow != 0);
|
||||
while (!range.Contains(lastVisible - value) && FirstVisibleRow != 0);
|
||||
}
|
||||
|
||||
PointMouseToNewCell();
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsVisible(int index)
|
||||
{
|
||||
return index >= FirstVisibleRow && index <= LastFullyVisibleRow;
|
||||
}
|
||||
private bool IsVisible(int index) => FirstVisibleRow.RangeTo(LastFullyVisibleRow).Contains(index);
|
||||
|
||||
public bool IsPartiallyVisible(int index)
|
||||
{
|
||||
return index >= FirstVisibleRow && index <= LastVisibleRow;
|
||||
}
|
||||
public bool IsPartiallyVisible(int index) => FirstVisibleRow.RangeTo(LastVisibleRow).Contains(index);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of rows currently visible including partially visible rows.
|
||||
|
@ -889,6 +885,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
// Small jump, more accurate
|
||||
var range = 0.RangeTo(_lagFrames[VisibleRows]);
|
||||
int lastVisible = FirstVisibleRow + CountLagFramesDisplay(VisibleRows / 2);
|
||||
do
|
||||
{
|
||||
|
@ -904,7 +901,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
SetLagFramesArray();
|
||||
lastVisible = FirstVisibleRow + CountLagFramesDisplay(VisibleRows / 2);
|
||||
}
|
||||
while ((lastVisible - index < 0 || lastVisible - index > _lagFrames[VisibleRows]) && FirstVisibleRow != 0);
|
||||
while (!range.Contains(lastVisible - index) && FirstVisibleRow != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1819,26 +1816,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private bool WasHoveringOnColumnCell => _lastCell?.Column != null && !_lastCell.RowIndex.HasValue;
|
||||
|
||||
private bool IsPointingOnCellEdge(int? x)
|
||||
{
|
||||
if (x.HasValue)
|
||||
{
|
||||
if (HorizontalOrientation)
|
||||
{
|
||||
return false; // TODO: support column resize in horizontal orientation
|
||||
}
|
||||
|
||||
foreach (RollColumn column in _columns.VisibleColumns)
|
||||
{
|
||||
if (column.Left - _hBar.Value + (column.Width - column.Width / 6) <= x.Value && column.Right - _hBar.Value >= x.Value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
private bool IsPointingOnCellEdge(int? x) => x.HasValue
|
||||
&& !HorizontalOrientation //TODO support column resize in horizontal orientation
|
||||
&& _columns.VisibleColumns.Any(column => (column.Left - _hBar.Value + (column.Width - column.Width / 6)).RangeTo(column.Right - _hBar.Value).Contains(x.Value));
|
||||
|
||||
/// <summary>
|
||||
/// Finds the specific cell that contains the (x, y) coordinate.
|
||||
|
@ -1895,26 +1875,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (_horizontalOrientation)
|
||||
{
|
||||
foreach (var item in _columns.VisibleColumns.Select((n, i) => new { Column = n, Index = i }))
|
||||
{
|
||||
if (GetHColTop(item.Index) - _vBar.Value <= pixel && GetHColBottom(item.Index) - _vBar.Value >= pixel)
|
||||
{
|
||||
return item.Column;
|
||||
}
|
||||
}
|
||||
return _columns.VisibleColumns.Select((n, i) => new { Column = n, Index = i })
|
||||
.FirstOrDefault(anonObj => (GetHColTop(anonObj.Index) - _vBar.Value).RangeTo(GetHColBottom(anonObj.Index) - _vBar.Value).Contains(pixel))
|
||||
?.Column;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (RollColumn column in _columns.VisibleColumns)
|
||||
{
|
||||
if (column.Left - _hBar.Value <= pixel && column.Right - _hBar.Value >= pixel)
|
||||
{
|
||||
return column;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return _columns.VisibleColumns.FirstOrDefault(column => (column.Left - _hBar.Value).RangeTo(column.Right - _hBar.Value).Contains(pixel));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1957,7 +1922,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return 0;
|
||||
}
|
||||
|
||||
return index >= 0 && index < _horizontalColumnTops.Length
|
||||
return 0.RangeToExclusive(_horizontalColumnTops.Length).Contains(index)
|
||||
? _horizontalColumnTops[index]
|
||||
: _horizontalColumnTops.Last() + CellHeight;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
// http://www.codeproject.com/Articles/154680/A-customizable-NET-WinForms-Message-Box
|
||||
namespace BizHawk.Client.EmuHawk.CustomControls
|
||||
{
|
||||
|
@ -69,7 +71,7 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
|||
|
||||
int count = names.Length;
|
||||
|
||||
if (count < 1 || count > 3)
|
||||
if (!1.RangeTo(3).Contains(count))
|
||||
{
|
||||
throw new ArgumentException("Invalid number of buttons. Must be between 1 and 3.");
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
using SlimDX;
|
||||
using SlimDX.DirectInput;
|
||||
|
||||
|
@ -230,14 +233,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
for (int i = 0; i < _state.GetPointOfViewControllers().Length; i++)
|
||||
{
|
||||
int j = i;
|
||||
AddItem($"POV{i + 1}U",
|
||||
() => { int t = _state.GetPointOfViewControllers()[j]; return (t >= 0 && t <= 4500) || (t >= 31500 && t < 36000); });
|
||||
AddItem($"POV{i + 1}D",
|
||||
() => { int t = _state.GetPointOfViewControllers()[j]; return t >= 13500 && t <= 22500; });
|
||||
AddItem($"POV{i + 1}L",
|
||||
() => { int t = _state.GetPointOfViewControllers()[j]; return t >= 22500 && t <= 31500; });
|
||||
AddItem($"POV{i + 1}R",
|
||||
() => { int t = _state.GetPointOfViewControllers()[j]; return t >= 4500 && t <= 13500; });
|
||||
AddItem($"POV{i + 1}U", () => {
|
||||
var t = _state.GetPointOfViewControllers()[j];
|
||||
return 0.RangeTo(4500).Contains(t) || 31500.RangeToExclusive(36000).Contains(t);
|
||||
});
|
||||
AddItem($"POV{i + 1}D", () => 13500.RangeTo(22500).Contains(_state.GetPointOfViewControllers()[j]));
|
||||
AddItem($"POV{i + 1}L", () => 22500.RangeTo(31500).Contains(_state.GetPointOfViewControllers()[j]));
|
||||
AddItem($"POV{i + 1}R", () => 4500.RangeTo(13500).Contains(_state.GetPointOfViewControllers()[j]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1311,12 +1311,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SNES_ToggleBg(int layer)
|
||||
{
|
||||
if (!(Emulator is LibsnesCore) && !(Emulator is Snes9x))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (layer < 1 || layer > 4)
|
||||
if (!(Emulator is LibsnesCore || Emulator is Snes9x) || !1.RangeTo(4).Contains(layer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1370,12 +1365,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SNES_ToggleObj(int layer)
|
||||
{
|
||||
if (!(Emulator is LibsnesCore) && !(Emulator is Snes9x))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (layer < 1 || layer > 4)
|
||||
if (!(Emulator is LibsnesCore || Emulator is Snes9x) || !1.RangeTo(4).Contains(layer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -229,11 +229,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
|
||||
// reset way-out-of-range values
|
||||
if (diff > 1)
|
||||
diff = 1;
|
||||
if (error > 1 || error < -1)
|
||||
error = 0;
|
||||
if (diffUnthrottled > 1)
|
||||
if (diff > 1.0f)
|
||||
diff = 1.0f;
|
||||
if (!(-1.0f).RangeTo(1.0f).Contains(error))
|
||||
error = 0.0f;
|
||||
if (diffUnthrottled > 1.0f)
|
||||
diffUnthrottled = desiredspf;
|
||||
|
||||
float derivative = (error - lastError) / diff;
|
||||
|
|
|
@ -602,7 +602,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
BigEndian = _domain.EndianType == MemoryDomain.Endian.Big;
|
||||
_maxRow = _domain.Size / 2;
|
||||
SetUpScrollBar();
|
||||
if (0 >= HexScrollBar.Minimum && 0 <= HexScrollBar.Maximum)
|
||||
if (HexScrollBar.Minimum.RangeTo(HexScrollBar.Maximum).Contains(0))
|
||||
{
|
||||
HexScrollBar.Value = 0;
|
||||
}
|
||||
|
@ -702,11 +702,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
private bool IsVisible(long address)
|
||||
{
|
||||
var i = address >> 4;
|
||||
return i >= HexScrollBar.Value && i < _rowsVisible + HexScrollBar.Value;
|
||||
}
|
||||
private bool IsVisible(long address) => ((long) HexScrollBar.Value).RangeToExclusive(HexScrollBar.Value + _rowsVisible).Contains(address >> 4);
|
||||
|
||||
private void SetHeader()
|
||||
{
|
||||
|
@ -946,8 +942,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private long GetPointedAddress(int x, int y)
|
||||
{
|
||||
long address;
|
||||
|
||||
// Scroll value determines the first row
|
||||
long i = HexScrollBar.Value;
|
||||
var rowOffset = y / _fontHeight;
|
||||
|
@ -963,48 +957,40 @@ namespace BizHawk.Client.EmuHawk
|
|||
column = (x - start) / (_fontWidth * DataSize);
|
||||
}
|
||||
|
||||
if (i >= 0 && i <= _maxRow && column >= 0 && column < (16 / DataSize))
|
||||
{
|
||||
address = (i * 16) + (column * DataSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
address = -1;
|
||||
}
|
||||
|
||||
return address;
|
||||
return 0L.RangeTo(_maxRow).Contains(i) && 0.RangeTo(16 / DataSize).Contains(column)
|
||||
? i * 16 + column * DataSize
|
||||
: -1;
|
||||
}
|
||||
|
||||
private void DoShiftClick()
|
||||
{
|
||||
if (_addressOver >= 0 && _addressOver < _domain.Size)
|
||||
if (!0L.RangeToExclusive(_domain.Size).Contains(_addressOver)) return;
|
||||
|
||||
_secondaryHighlightedAddresses.Clear();
|
||||
if (_addressOver < _highlightedAddress)
|
||||
{
|
||||
_secondaryHighlightedAddresses.Clear();
|
||||
if (_addressOver < _highlightedAddress)
|
||||
for (var x = _addressOver; x < _highlightedAddress; x += DataSize)
|
||||
{
|
||||
for (var x = _addressOver; x < _highlightedAddress; x += DataSize)
|
||||
{
|
||||
_secondaryHighlightedAddresses.Add(x);
|
||||
}
|
||||
_secondaryHighlightedAddresses.Add(x);
|
||||
}
|
||||
else if (_addressOver > _highlightedAddress)
|
||||
}
|
||||
else if (_addressOver > _highlightedAddress)
|
||||
{
|
||||
for (var x = _highlightedAddress.Value + DataSize; x <= _addressOver; x += DataSize)
|
||||
{
|
||||
for (var x = _highlightedAddress.Value + DataSize; x <= _addressOver; x += DataSize)
|
||||
{
|
||||
_secondaryHighlightedAddresses.Add(x);
|
||||
}
|
||||
_secondaryHighlightedAddresses.Add(x);
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsVisible(_addressOver))
|
||||
{
|
||||
var value = (_addressOver / 16) + 1 - ((_addressOver / 16) < HexScrollBar.Value ? 1 : _rowsVisible);
|
||||
if (value < 0)
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
|
||||
if (!IsVisible(_addressOver))
|
||||
{
|
||||
var value = (_addressOver / 16) + 1 - ((_addressOver / 16) < HexScrollBar.Value ? 1 : _rowsVisible);
|
||||
if (value < 0)
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
|
||||
HexScrollBar.Value = (int)value; // This will fail on a sufficiently large domain
|
||||
}
|
||||
HexScrollBar.Value = (int)value; // This will fail on a sufficiently large domain
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1058,7 +1044,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void AddToSecondaryHighlights(long address)
|
||||
{
|
||||
if (address >= 0 && address < _domain.Size && !_secondaryHighlightedAddresses.Contains(address))
|
||||
if (0L.RangeToExclusive(_domain.Size).Contains(address) && !_secondaryHighlightedAddresses.Contains(address))
|
||||
{
|
||||
_secondaryHighlightedAddresses.Add(address);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.Windows.Forms;
|
|||
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
@ -211,13 +212,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (Encoding.Checked && !string.IsNullOrWhiteSpace(ValueBox.Text))
|
||||
{
|
||||
var val = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
|
||||
if (val > 0 && val < 0x100)
|
||||
if (val.StrictlyBoundedBy(0.RangeTo(0x100)) && !string.IsNullOrWhiteSpace(AddressBox.Text))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(AddressBox.Text))
|
||||
{
|
||||
_value = val;
|
||||
EncodeGameGenie();
|
||||
}
|
||||
_value = val;
|
||||
EncodeGameGenie();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -273,13 +271,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (CompareBox.Text.Length > 0)
|
||||
{
|
||||
var c = int.Parse(CompareBox.Text, NumberStyles.HexNumber);
|
||||
if (c > 0 && c < 0x100)
|
||||
if (c.StrictlyBoundedBy(0.RangeTo(0x100)) && ValueBox.Text.Length > 0 && AddressBox.Text.Length > 0)
|
||||
{
|
||||
if (ValueBox.Text.Length > 0 && AddressBox.Text.Length > 0)
|
||||
{
|
||||
_compare = c;
|
||||
EncodeGameGenie();
|
||||
}
|
||||
_compare = c;
|
||||
EncodeGameGenie();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -4,6 +4,8 @@ using System.Xml.Linq;
|
|||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Cores.Nintendo.NES;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
|
@ -65,10 +67,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
float a = freqtbl[i - 1];
|
||||
float b = freqtbl[i];
|
||||
float c = freqtbl[i + 1];
|
||||
float min = (a + b) / 2;
|
||||
float max = (b + c) / 2;
|
||||
if (freq >= min && freq <= max)
|
||||
return i - 1;
|
||||
var range = ((a + b) / 2).RangeTo((b + c) / 2);
|
||||
if (range.Contains(freq)) return i - 1;
|
||||
}
|
||||
return 95; //I guess?
|
||||
}
|
||||
|
|
|
@ -1027,7 +1027,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
int tileStride = pxacross / 8;
|
||||
int tilesTall = pxtall / 8;
|
||||
if (tx < 0 || ty < 0 || tx >= tileStride || ty >= tilesTall)
|
||||
if (!0.RangeToExclusive(tileStride).Contains(tx) || !0.RangeToExclusive(tilesTall).Contains(ty))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1060,7 +1060,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void HandleSpriteMouseOver(int px, int py)
|
||||
{
|
||||
if (px < 0 || py < 0 || px >= 256 || py >= 224) return;
|
||||
if (!0.RangeTo(255).Contains(px) || !0.RangeTo(223).Contains(py)) return;
|
||||
|
||||
int sprite = spriteMap[px,py];
|
||||
if(sprite == 0xFF) return;
|
||||
|
@ -1074,8 +1074,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
int ox = px / si.ObjSizeBounds.Width;
|
||||
int oy = py / si.ObjSizeBounds.Height;
|
||||
|
||||
if (ox < 0 || oy < 0 || ox >= 8 || oy >= 16)
|
||||
return;
|
||||
if (!0.RangeTo(7).Contains(ox) || !0.RangeTo(15).Contains(oy)) return;
|
||||
|
||||
int objNum = oy * 8 + ox;
|
||||
|
||||
|
|
Loading…
Reference in New Issue