Move `&&`/`||` to start of next line in Emulation.Cores project

This commit is contained in:
James Groom 2024-03-27 02:10:39 +00:00 committed by GitHub
parent e5582cd016
commit 5685befe14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
33 changed files with 212 additions and 275 deletions

View File

@ -396,8 +396,8 @@ namespace BizHawk.Emulation.Cores.Components.M68000
{
if ((registers & 0x8000) != 0) // current bit
{
if ((registers & 0x10000) != 0 && // last bit
(registers & 0x4000) != 0) // next bit
if ((registers & 0x10000) is not 0 // last bit
&& (registers & 0x4000) is not 0) // next bit
{
if (!snip)
{
@ -419,8 +419,8 @@ namespace BizHawk.Emulation.Cores.Components.M68000
{
if ((registers & 0x8000) != 0) // current bit
{
if ((registers & 0x10000) != 0 && // last bit
(registers & 0x4000) != 0) // next bit
if ((registers & 0x10000) is not 0 // last bit
&& (registers & 0x4000) is not 0) // next bit
{
if (!snip)
{
@ -451,8 +451,8 @@ namespace BizHawk.Emulation.Cores.Components.M68000
{
if ((registers & 0x10000) != 0)
{
if ((registers & 0x8000) != 0 && // last bit
(registers & 0x20000) != 0) // next bit
if ((registers & 0x8000) is not 0 // last bit
&& (registers & 0x20000) is not 0) // next bit
{
if (!snip)
{
@ -474,8 +474,8 @@ namespace BizHawk.Emulation.Cores.Components.M68000
{
if ((registers & 0x10000) != 0)
{
if ((registers & 0x8000) != 0 && // last bit
(registers & 0x20000) != 0) // next bit
if ((registers & 0x8000) is not 0 // last bit
&& (registers & 0x20000) is not 0) // next bit
{
if (!snip)
{

View File

@ -44,10 +44,7 @@ namespace BizHawk.Emulation.Cores.Components.CP1610
bool op1_neg = ((op1 & 0x8000) != 0);
bool op2_neg = ((op2 & 0x8000) != 0);
bool result_neg = ((result & 0x8000) != 0);
FlagO = (
(op1_neg && op2_neg && !result_neg) ||
(!op1_neg && !op2_neg && result_neg)
);
FlagO = (op1_neg && op2_neg && !result_neg) || (!op1_neg && !op2_neg && result_neg);
}
private void Calc_FlagO_Sub(int op1, int op2, int result)
@ -55,10 +52,7 @@ namespace BizHawk.Emulation.Cores.Components.CP1610
bool op1_neg = ((op1 & 0x8000) != 0);
bool op2_neg = ((op2 & 0x8000) != 0);
bool result_neg = ((result & 0x8000) != 0);
FlagO = (
(op1_neg && !op2_neg && !result_neg) ||
(!op1_neg && op2_neg && result_neg)
);
FlagO = (op1_neg && !op2_neg && !result_neg) || (!op1_neg && op2_neg && result_neg);
}
private void Calc_FlagS(int result)

View File

@ -176,10 +176,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
_waitEdge = 0;
_position = 0;
if (
_dataBlocks.Count > 0 && // data blocks are present &&
_currentDataBlockIndex >= 0 // the current data block index is 1 or greater
)
if (_dataBlocks.Count > 0 && _currentDataBlockIndex >= 0) //TODO removed a comment that said "index is 1 or greater", but code is clearly "0 or greater"--which is correct? --yoshi
{
while (_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count)
{
@ -225,10 +222,8 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
// sign that the tape is no longer playing
_tapeIsPlaying = false;
if (
_currentDataBlockIndex >= 0 && // we are at datablock 1 or above
_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count - 1 // the block is still playing back
)
if (_currentDataBlockIndex >= 0 && // we are at datablock 1 or above //TODO 1-indexed then? --yoshi
_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count - 1) // the block is still playing back
{
// move to the next block
_currentDataBlockIndex++;
@ -242,10 +237,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
_waitEdge = 0;
_position = 0;
if (
_currentDataBlockIndex < 0 && // block index is -1
_dataBlocks.Count > 0 // number of blocks is greater than 0
)
if (_currentDataBlockIndex < 0 && _dataBlocks.Count > 0) //TODO deleted a comment that said "block index is -1", but code is clearly "is negative"--are lower values not reachable? --yoshi
{
// move the index on to 0
_currentDataBlockIndex = 0;

View File

@ -779,8 +779,8 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
ActiveCommandParams.EOT = ActiveCommandParams.Sector;
}
if (!CMD_FLAG_SK && !Status2.Bit(SR2_CM) &&
ActiveDrive.Disk.Protection == ProtectionType.PaulOwens)
if (!CMD_FLAG_SK && !Status2.Bit(SR2_CM)
&& ActiveDrive.Disk.Protection is ProtectionType.PaulOwens)
{
ActiveCommandParams.EOT = ActiveCommandParams.Sector;
SetBit(SR2_CM, ref Status2);
@ -1032,10 +1032,10 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
sec.SectorReadCompleted();
// end of sector - compare IDs
if (sec.TrackNumber != ActiveCommandParams.Cylinder ||
sec.SideNumber != ActiveCommandParams.Head ||
sec.SectorID != ActiveCommandParams.Sector ||
sec.SectorSize != ActiveCommandParams.SectorSize)
if (sec.TrackNumber != ActiveCommandParams.Cylinder
|| sec.SideNumber != ActiveCommandParams.Head
|| sec.SectorID != ActiveCommandParams.Sector
|| sec.SectorSize != ActiveCommandParams.SectorSize)
{
SetBit(SR1_ND, ref Status1);
}
@ -2112,8 +2112,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
// for now I will assume that the first call is aimed at DriveA, the second at DriveB (which we are NOT implementing)
// check active drive first
if (ActiveDrive.SeekStatus == SEEK_RECALIBRATE ||
ActiveDrive.SeekStatus == SEEK_SEEK)
if (ActiveDrive.SeekStatus is SEEK_RECALIBRATE or SEEK_SEEK)
{
// interrupt has been raised for this drive
// acknowledge
@ -2664,25 +2663,25 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
}
// check for error bits
if (GetBit(SR1_DE, Status1) ||
GetBit(SR1_MA, Status1) ||
GetBit(SR1_ND, Status1) ||
GetBit(SR1_NW, Status1) ||
GetBit(SR1_OR, Status1) ||
GetBit(SR2_BC, Status2) ||
GetBit(SR2_CM, Status2) ||
GetBit(SR2_DD, Status2) ||
GetBit(SR2_MD, Status2) ||
GetBit(SR2_SN, Status2) ||
GetBit(SR2_WC, Status2))
if (GetBit(SR1_DE, Status1)
|| GetBit(SR1_MA, Status1)
|| GetBit(SR1_ND, Status1)
|| GetBit(SR1_NW, Status1)
|| GetBit(SR1_OR, Status1)
|| GetBit(SR2_BC, Status2)
|| GetBit(SR2_CM, Status2)
|| GetBit(SR2_DD, Status2)
|| GetBit(SR2_MD, Status2)
|| GetBit(SR2_SN, Status2)
|| GetBit(SR2_WC, Status2))
{
// error bits set - unset end of track
UnSetBit(SR1_EN, ref Status1);
}
// check for data errors
if (GetBit(SR1_DE, Status1) ||
GetBit(SR2_DD, Status2))
if (GetBit(SR1_DE, Status1)
|| GetBit(SR2_DD, Status2))
{
// unset control mark
UnSetBit(SR2_CM, ref Status2);

View File

@ -84,14 +84,15 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
// or the index hole being passed twice
while (iHole <= 2)
{
var next = trk.Sectors[index];
// does the requested sector match the current sector
if (trk.Sectors[index].SectorIDInfo.C == ActiveCommandParams.Cylinder &&
trk.Sectors[index].SectorIDInfo.H == ActiveCommandParams.Head &&
trk.Sectors[index].SectorIDInfo.R == ActiveCommandParams.Sector &&
trk.Sectors[index].SectorIDInfo.N == ActiveCommandParams.SectorSize)
if (next.SectorIDInfo.C == ActiveCommandParams.Cylinder
&& next.SectorIDInfo.H == ActiveCommandParams.Head
&& next.SectorIDInfo.R == ActiveCommandParams.Sector
&& next.SectorIDInfo.N == ActiveCommandParams.SectorSize)
{
// sector has been found
sector = trk.Sectors[index];
sector = next;
UnSetBit(SR2_BC, ref Status2);
UnSetBit(SR2_WC, ref Status2);
@ -99,12 +100,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
}
// check for bad cylinder
if (trk.Sectors[index].SectorIDInfo.C == 255)
if (next.SectorIDInfo.C is 255)
{
SetBit(SR2_BC, ref Status2);
}
// check for no cylinder
else if (trk.Sectors[index].SectorIDInfo.C != ActiveCommandParams.Cylinder)
else if (next.SectorIDInfo.C != ActiveCommandParams.Cylinder)
{
SetBit(SR2_WC, ref Status2);
}

View File

@ -189,31 +189,35 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
return false;
var zeroSecs = DiskTracks[0].Sectors;
if (zeroSecs[0].SectorID != 65 ||
zeroSecs[1].SectorID != 66 ||
zeroSecs[2].SectorID != 67 ||
zeroSecs[3].SectorID != 68 ||
zeroSecs[4].SectorID != 69 ||
zeroSecs[5].SectorID != 70 ||
zeroSecs[6].SectorID != 71 ||
zeroSecs[7].SectorID != 72 ||
zeroSecs[8].SectorID != 73)
if (zeroSecs[0].SectorID is not 65
|| zeroSecs[1].SectorID is not 66
|| zeroSecs[2].SectorID is not 67
|| zeroSecs[3].SectorID is not 68
|| zeroSecs[4].SectorID is not 69
|| zeroSecs[5].SectorID is not 70
|| zeroSecs[6].SectorID is not 71
|| zeroSecs[7].SectorID is not 72
|| zeroSecs[8].SectorID is not 73)
{
return false;
}
var oneSecs = DiskTracks[1].Sectors;
if (oneSecs.Length != 8)
return false;
if (oneSecs[0].SectorID != 17 ||
oneSecs[1].SectorID != 18 ||
oneSecs[2].SectorID != 19 ||
oneSecs[3].SectorID != 20 ||
oneSecs[4].SectorID != 21 ||
oneSecs[5].SectorID != 22 ||
oneSecs[6].SectorID != 23 ||
oneSecs[7].SectorID != 24)
if (oneSecs[0].SectorID is not 17
|| oneSecs[1].SectorID is not 18
|| oneSecs[2].SectorID is not 19
|| oneSecs[3].SectorID is not 20
|| oneSecs[4].SectorID is not 21
|| oneSecs[5].SectorID is not 22
|| oneSecs[6].SectorID is not 23
|| oneSecs[7].SectorID is not 24)
{
return false;
}
return true;
}
@ -240,17 +244,11 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
return false;
// check for correct sector 0 lengths
if (DiskTracks[0].Sectors[0].SectorSize != 2 ||
DiskTracks[0].Sectors[0].SectorData.Length < 0x200)
return false;
if (DiskTracks[0].Sectors[0] is not { SectorSize: 2, SectorData.Length: >= 0x200 }) return false;
// sector[1] (SectorID 2) contains the weak sectors
Sector sec = DiskTracks[0].Sectors[1];
// check for correct sector 1 lengths
if (sec.SectorSize != 2 ||
sec.SectorData.Length < 0x200)
return false;
if (DiskTracks[0].Sectors[1] is not { SectorSize: 2, SectorData.Length: >= 0x200 } sec) return false;
// secID 2 needs a CRC error
//if (!(sec.Status1.Bit(5) || sec.Status2.Bit(5)))

View File

@ -352,8 +352,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
with output pins on the peripheral ports.
*/
if ((_pcrCa1IntControl == PCR_INT_CONTROL_POSITIVE_EDGE && Ca1 && !_ca1L) ||
(_pcrCa1IntControl == PCR_INT_CONTROL_NEGATIVE_EDGE && !Ca1 && _ca1L))
if ((_pcrCa1IntControl is PCR_INT_CONTROL_POSITIVE_EDGE && Ca1 && !_ca1L)
|| (_pcrCa1IntControl is PCR_INT_CONTROL_NEGATIVE_EDGE && !Ca1 && _ca1L))
{
if (_acrPaLatchEnable && (_ifr & 0x02) == 0)
_paLatch = _port.ReadExternalPra();
@ -367,8 +367,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
output. As with the PA port, the processor always reads the input latches.
*/
if ((_pcrCb1IntControl == PCR_INT_CONTROL_POSITIVE_EDGE && Cb1 && !_cb1L) ||
(_pcrCb1IntControl == PCR_INT_CONTROL_NEGATIVE_EDGE && !Cb1 && _cb1L))
if ((_pcrCb1IntControl is PCR_INT_CONTROL_POSITIVE_EDGE && Cb1 && !_cb1L)
|| (_pcrCb1IntControl is PCR_INT_CONTROL_NEGATIVE_EDGE && !Cb1 && _cb1L))
{
if (_acrPbLatchEnable && (_ifr & 0x10) == 0)
_pbLatch = _port.ReadPrb(_prb, _ddrb);

View File

@ -348,9 +348,9 @@
_parseCycleBaSprite0 = _parseBa & BaTypeMaskSprite0;
_parseCycleBaSprite1 = (_parseBa & BaTypeMaskSprite1) >> 4;
_parseCycleBaSprite2 = (_parseBa & BaTypeMaskSprite2) >> 8;
_ba = !((_parseCycleBaSprite0 < 8 && _sprites[_parseCycleBaSprite0].Dma) ||
(_parseCycleBaSprite1 < 8 && _sprites[_parseCycleBaSprite1].Dma) ||
(_parseCycleBaSprite2 < 8 && _sprites[_parseCycleBaSprite2].Dma));
_ba = !((_parseCycleBaSprite0 < 8 && _sprites[_parseCycleBaSprite0].Dma)
|| (_parseCycleBaSprite1 < 8 && _sprites[_parseCycleBaSprite1].Dma)
|| (_parseCycleBaSprite2 < 8 && _sprites[_parseCycleBaSprite2].Dma));
break;
}

View File

@ -139,10 +139,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
_waitEdge = 0;
_position = 0;
if (
_dataBlocks.Count > 0 && // data blocks are present &&
_currentDataBlockIndex >= 0 // the current data block index is 1 or greater
)
if (_dataBlocks.Count > 0 && _currentDataBlockIndex >= 0) //TODO removed a comment that said "index is 1 or greater", but code is clearly "0 or greater"--which is correct? --yoshi
{
while (_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count)
{
@ -188,10 +185,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// sign that the tape is no longer playing
_tapeIsPlaying = false;
if (
_currentDataBlockIndex >= 0 && // we are at datablock 1 or above
_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count - 1 // the block is still playing back
)
if (_currentDataBlockIndex >= 0 // we are at datablock 1 or above //TODO 1-indexed then? --yoshi
&& _position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count - 1) // the block is still playing back
{
// move to the next block
_currentDataBlockIndex++;
@ -205,10 +200,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
_waitEdge = 0;
_position = 0;
if (
_currentDataBlockIndex < 0 && // block index is -1
_dataBlocks.Count > 0 // number of blocks is greater than 0
)
if (_currentDataBlockIndex < 0 && _dataBlocks.Count > 0)
{
// move the index on to 0
_currentDataBlockIndex = 0;
@ -641,8 +633,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
}
var pc = (ushort)0x05DF;
if (_cpu.Regs[_cpu.E] + (_cpu.Regs[_cpu.D] << 8) == toRead &&
toRead + 1 < tData.Length)
if (_cpu.Regs[_cpu.E] + (_cpu.Regs[_cpu.D] << 8) == toRead
&& toRead + 1 < tData.Length)
{
var v = tData[toRead + 1];
_cpu.Regs[_cpu.L] = v;
@ -709,10 +701,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
_cpu.Regs[_cpu.L]
};
if (delta > 0 &&
delta < 96 &&
_cpu.RegPC == _monitorLastPC &&
_monitorLastRegs != null)
if (delta is > 0 and < 96 && _cpu.RegPC == _monitorLastPC && _monitorLastRegs is not null)
{
int dCnt = 0;
int dVal = 0;
@ -726,8 +715,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
}
}
if (dCnt == 1 &&
(dVal == 1 || dVal == -1))
if (dCnt is 1 && dVal is 1 or -1)
{
_monitorCount++;
@ -782,9 +770,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
{
if (_tapeIsPlaying && _autoPlay)
{
if (DataBlocks.Count > 1 ||
(_dataBlocks[_currentDataBlockIndex].BlockDescription != BlockType.CSW_Recording &&
_dataBlocks[_currentDataBlockIndex].BlockDescription != BlockType.WAV_Recording))
if (DataBlocks.Count > 1
|| _dataBlocks[_currentDataBlockIndex].BlockDescription is not (BlockType.CSW_Recording or BlockType.WAV_Recording))
{
// we should only stop the tape when there are multiple blocks
// if we just have one big block (maybe a CSW or WAV) then auto stopping will cock things up
@ -793,8 +780,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
if (_monitorTimeOut < 0)
{
if (_dataBlocks[_currentDataBlockIndex].BlockDescription != BlockType.PAUSE_BLOCK &&
_dataBlocks[_currentDataBlockIndex].BlockDescription != BlockType.PAUS)
if (_dataBlocks[_currentDataBlockIndex].BlockDescription is not (BlockType.PAUSE_BLOCK or BlockType.PAUS))
{
AutoStopTape();
}
@ -828,9 +814,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
return;
// don't autostop if there is only 1 block
if (DataBlocks.Count == 1 || _dataBlocks[_currentDataBlockIndex].BlockDescription == BlockType.CSW_Recording ||
_dataBlocks[_currentDataBlockIndex].BlockDescription == BlockType.WAV_Recording
)
if (DataBlocks.Count == 1
|| _dataBlocks[_currentDataBlockIndex].BlockDescription is BlockType.CSW_Recording or BlockType.WAV_Recording)
{
return;
}

View File

@ -790,8 +790,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
ActiveCommandParams.EOT = ActiveCommandParams.Sector;
}
if (!CMD_FLAG_SK && !Status2.Bit(SR2_CM) &&
ActiveDrive.Disk.Protection == ProtectionType.PaulOwens)
if (!CMD_FLAG_SK && !Status2.Bit(SR2_CM)
&& ActiveDrive.Disk.Protection is ProtectionType.PaulOwens)
{
ActiveCommandParams.EOT = ActiveCommandParams.Sector;
SetBit(SR2_CM, ref Status2);
@ -1054,10 +1054,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
sec.SectorReadCompleted();
// end of sector - compare IDs
if (sec.TrackNumber != ActiveCommandParams.Cylinder ||
sec.SideNumber != ActiveCommandParams.Head ||
sec.SectorID != ActiveCommandParams.Sector ||
sec.SectorSize != ActiveCommandParams.SectorSize)
if (sec.TrackNumber != ActiveCommandParams.Cylinder
|| sec.SideNumber != ActiveCommandParams.Head
|| sec.SectorID != ActiveCommandParams.Sector
|| sec.SectorSize != ActiveCommandParams.SectorSize)
{
SetBit(SR1_ND, ref Status1);
}
@ -2134,8 +2134,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// for now I will assume that the first call is aimed at DriveA, the second at DriveB (which we are NOT implementing)
// check active drive first
if (ActiveDrive.SeekStatus == SEEK_RECALIBRATE ||
ActiveDrive.SeekStatus == SEEK_SEEK)
if (ActiveDrive.SeekStatus is SEEK_RECALIBRATE or SEEK_SEEK)
{
// interrupt has been raised for this drive
// acknowledge
@ -2692,25 +2691,25 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
}
// check for error bits
if (GetBit(SR1_DE, Status1) ||
GetBit(SR1_MA, Status1) ||
GetBit(SR1_ND, Status1) ||
GetBit(SR1_NW, Status1) ||
GetBit(SR1_OR, Status1) ||
GetBit(SR2_BC, Status2) ||
GetBit(SR2_CM, Status2) ||
GetBit(SR2_DD, Status2) ||
GetBit(SR2_MD, Status2) ||
GetBit(SR2_SN, Status2) ||
GetBit(SR2_WC, Status2))
if (GetBit(SR1_DE, Status1)
|| GetBit(SR1_MA, Status1)
|| GetBit(SR1_ND, Status1)
|| GetBit(SR1_NW, Status1)
|| GetBit(SR1_OR, Status1)
|| GetBit(SR2_BC, Status2)
|| GetBit(SR2_CM, Status2)
|| GetBit(SR2_DD, Status2)
|| GetBit(SR2_MD, Status2)
|| GetBit(SR2_SN, Status2)
|| GetBit(SR2_WC, Status2))
{
// error bits set - unset end of track
UnSetBit(SR1_EN, ref Status1);
}
// check for data errors
if (GetBit(SR1_DE, Status1) ||
GetBit(SR2_DD, Status2))
if (GetBit(SR1_DE, Status1)
|| GetBit(SR2_DD, Status2))
{
// unset control mark
UnSetBit(SR2_CM, ref Status2);

View File

@ -84,14 +84,15 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// or the index hole being passed twice
while (iHole <= 2)
{
var next = trk.Sectors[index];
// does the requested sector match the current sector
if (trk.Sectors[index].SectorIDInfo.C == ActiveCommandParams.Cylinder &&
trk.Sectors[index].SectorIDInfo.H == ActiveCommandParams.Head &&
trk.Sectors[index].SectorIDInfo.R == ActiveCommandParams.Sector &&
trk.Sectors[index].SectorIDInfo.N == ActiveCommandParams.SectorSize)
if (next.SectorIDInfo.C == ActiveCommandParams.Cylinder
&& next.SectorIDInfo.H == ActiveCommandParams.Head
&& next.SectorIDInfo.R == ActiveCommandParams.Sector
&& next.SectorIDInfo.N == ActiveCommandParams.SectorSize)
{
// sector has been found
sector = trk.Sectors[index];
sector = next;
UnSetBit(SR2_BC, ref Status2);
UnSetBit(SR2_WC, ref Status2);
@ -99,12 +100,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
}
// check for bad cylinder
if (trk.Sectors[index].SectorIDInfo.C == 255)
if (next.SectorIDInfo.C is 255)
{
SetBit(SR2_BC, ref Status2);
}
// check for no cylinder
else if (trk.Sectors[index].SectorIDInfo.C != ActiveCommandParams.Cylinder)
else if (next.SectorIDInfo.C != ActiveCommandParams.Cylinder)
{
SetBit(SR2_WC, ref Status2);
}

View File

@ -309,12 +309,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
int scrPix = pix - _ula.FirstPaperTState;
int scrLin = line - _ula.FirstPaperLine;
if ((line >= (_ula.FirstPaperLine - _ula.BorderTopHeight)) && (line < (_ula.FirstPaperLine + 192 + _ula.BorderBottomHeight)) &&
(pix >= (_ula.FirstPaperTState - _ula.BorderLeftTime)) && (pix < (_ula.FirstPaperTState + 128 + _ula.BorderRightTime)))
if (_ula.FirstPaperLine - _ula.BorderTopHeight <= line && line < _ula.FirstPaperLine + 192 + _ula.BorderBottomHeight
&& _ula.FirstPaperTState - _ula.BorderLeftTime <= pix && pix < _ula.FirstPaperTState + 128 + _ula.BorderRightTime)
{
// visibleArea (vertical)
if ((line >= _ula.FirstPaperLine) && (line < (_ula.FirstPaperLine + 192)) &&
(pix >= _ula.FirstPaperTState) && (pix < (_ula.FirstPaperTState + 128)))
if (_ula.FirstPaperLine <= line && line < _ula.FirstPaperLine + 192
&& _ula.FirstPaperTState <= pix && pix < _ula.FirstPaperTState + 128)
{
// pixel area
switch (scrPix & 7)
@ -370,15 +370,15 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
break;
}
}
else if ((line >= _ula.FirstPaperLine) && (line < (_ula.FirstPaperLine + 192)) &&
(pix == (_ula.FirstPaperTState - 2))) // border & fetch B1
else if (_ula.FirstPaperLine <= line && line < _ula.FirstPaperLine + 192
&& pix == _ula.FirstPaperTState - 2) // border & fetch B1
{
Renderer[item].RAction = RenderAction.BorderAndFetchByte1; // border & fetch B1
// +2 = prefetch!
Renderer[item].ByteAddress = CalculateByteAddress(scrPix + 2, scrLin);
}
else if ((line >= _ula.FirstPaperLine) && (line < (_ula.FirstPaperLine + 192)) &&
(pix == (_ula.FirstPaperTState - 1))) // border & fetch A1
else if (_ula.FirstPaperLine <= line && line < _ula.FirstPaperLine + 192
&& pix == _ula.FirstPaperTState - 1) // border & fetch A1
{
Renderer[item].RAction = RenderAction.BorderAndFetchAttribute1; // border & fetch A1
// +1 = prefetch!

View File

@ -189,31 +189,35 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
return false;
var zeroSecs = DiskTracks[0].Sectors;
if (zeroSecs[0].SectorID != 65 ||
zeroSecs[1].SectorID != 66 ||
zeroSecs[2].SectorID != 67 ||
zeroSecs[3].SectorID != 68 ||
zeroSecs[4].SectorID != 69 ||
zeroSecs[5].SectorID != 70 ||
zeroSecs[6].SectorID != 71 ||
zeroSecs[7].SectorID != 72 ||
zeroSecs[8].SectorID != 73)
if (zeroSecs[0].SectorID is not 65
|| zeroSecs[1].SectorID is not 66
|| zeroSecs[2].SectorID is not 67
|| zeroSecs[3].SectorID is not 68
|| zeroSecs[4].SectorID is not 69
|| zeroSecs[5].SectorID is not 70
|| zeroSecs[6].SectorID is not 71
|| zeroSecs[7].SectorID is not 72
|| zeroSecs[8].SectorID is not 73)
{
return false;
}
var oneSecs = DiskTracks[1].Sectors;
if (oneSecs.Length != 8)
return false;
if (oneSecs[0].SectorID != 17 ||
oneSecs[1].SectorID != 18 ||
oneSecs[2].SectorID != 19 ||
oneSecs[3].SectorID != 20 ||
oneSecs[4].SectorID != 21 ||
oneSecs[5].SectorID != 22 ||
oneSecs[6].SectorID != 23 ||
oneSecs[7].SectorID != 24)
if (oneSecs[0].SectorID is not 17
|| oneSecs[1].SectorID is not 18
|| oneSecs[2].SectorID is not 19
|| oneSecs[3].SectorID is not 20
|| oneSecs[4].SectorID is not 21
|| oneSecs[5].SectorID is not 22
|| oneSecs[6].SectorID is not 23
|| oneSecs[7].SectorID is not 24)
{
return false;
}
return true;
}
@ -240,17 +244,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
return false;
// check for correct sector 0 lengths
if (DiskTracks[0].Sectors[0].SectorSize != 2 ||
DiskTracks[0].Sectors[0].SectorData.Length < 0x200)
return false;
if (DiskTracks[0].Sectors[0] is not { SectorSize: 2, SectorData.Length: >= 0x200 }) return false;
// sector[1] (SectorID 2) contains the weak sectors
Sector sec = DiskTracks[0].Sectors[1];
// check for correct sector 1 lengths
if (sec.SectorSize != 2 ||
sec.SectorData.Length < 0x200)
return false;
if (DiskTracks[0].Sectors[1] is not { SectorSize: 2, SectorData.Length: >= 0x200 } sec) return false;
// secID 2 needs a CRC error
//if (!(sec.Status1.Bit(5) || sec.Status2.Bit(5)))

View File

@ -24,8 +24,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public int ReadNext()
{
// check - sample should be in PCM format
if (m_header.fmtCode != WAVE_FORMAT_PCM &&
m_header.fmtCode != WAVE_FORMAT_IEEE_FLOAT)
if (m_header.fmtCode is not (WAVE_FORMAT_PCM or WAVE_FORMAT_IEEE_FLOAT))
{
throw new FormatException($"Not supported audio format: fmtCode={m_header.fmtCode}, bitDepth={m_header.bitDepth}");
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using BizHawk.Common.BufferExtensions;
@ -20,10 +21,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
return "2K";
}
if (rom.Length == 2048 || // If 2k or the same 2k twice...Why would a rom be that way? Overdump?
(rom.Length == 4096
&& rom.Take(2048).SequenceEqual(rom.Skip(2048).Take(2048))))
if (rom.Length is 2048
|| (rom.Length is 4096
&& rom.AsSpan(start: 0, length: 2048).SequenceEqual(rom.AsSpan(start: 2048, length: 2048))))
{
// If 2k or the same 2k twice...Why would a rom be that way? Overdump?
return IsProablyCV(rom) ? "CV" : "2K";
}
@ -283,9 +285,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
}
// Program starts at $1Fxx with NOP $6Exx or NOP $6Fxx?
if (((rom[0xFFFD] & 0x1F) == 0x1F) &&
(rom[rom[0xFFFD] * 256 + rom[0xFFFC]] == 0x0C) &&
((rom[rom[0xFFFD] * 256 + rom[0xFFFC] + 2] & 0xFE) == 0x6E))
if ((rom[0xFFFD] & 0x1F) is 0x1F
&& rom[rom[0xFFFD] * 256 + rom[0xFFFC]] is 0x0C
&& (rom[rom[0xFFFD] * 256 + rom[0xFFFC] + 2] & 0xFE) is 0x6E)
{
return true;
}

View File

@ -259,8 +259,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_writePending = false;
BankConfiguration(_dataHoldRegister);
}
else if (_writeEnabled && _writePending &&
Core.DistinctAccessCount == _distinctAccesses + 5)
else if (_writeEnabled && _writePending && Core.DistinctAccessCount == _distinctAccesses + 5)
{
if ((addr & 0x800) == 0)
{
@ -309,8 +308,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
}
// Handle poke if writing enabled
else if (_writeEnabled && _writePending &&
(Core.DistinctAccessCount == (_distinctAccesses + 5)))
else if (_writeEnabled && _writePending && Core.DistinctAccessCount == _distinctAccesses + 5)
{
if ((addr & 0x0800) == 0)
{

View File

@ -267,10 +267,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
public void new_draw_line()
{
if (((ramp_sig && !zero_sig) && ((x_vel != x_vel_old) || (y_vel != y_vel_old))) ||
(blank_sig != blank_old) ||
(bright_int_1 != bright_int_1_old) ||
(zero_sig != zero_old))
if ((ramp_sig && !zero_sig && (x_vel != x_vel_old || y_vel != y_vel_old))
|| blank_sig != blank_old
|| bright_int_1 != bright_int_1_old
|| zero_sig != zero_old)
{
draw_lines[line_pointer * 4 + 2] = x_pos;
draw_lines[line_pointer * 4 + 3] = y_pos;

View File

@ -969,9 +969,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{
for (int i = 0; i < SL_sprites_index; i++)
{
if ((pixel_counter >= (SL_sprites[i * 4 + 1] - 8)) &&
(pixel_counter < (SL_sprites[i * 4 + 1])) &&
!evaled_sprites.Bit(i))
if (!evaled_sprites.Bit(i) && pixel_counter - SL_sprites[4 * i + 1] is >= -8 and < 0)
{
going_to_fetch = true;
fetch_sprite = true;
@ -1484,9 +1482,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// at this time it is unknown what each cycle does, but we only need to accurately keep track of cycles
for (int i = 0; i < SL_sprites_index; i++)
{
if ((pixel_counter >= (SL_sprites[i * 4 + 1] - 8)) &&
(pixel_counter < (SL_sprites[i * 4 + 1])) &&
!evaled_sprites.Bit(i))
if (!evaled_sprites.Bit(i) && pixel_counter - SL_sprites[4 * i + 1] is >= -8 and < 0)
{
sprite_fetch_counter += 6;
evaled_sprites |= (1 << i);
@ -1755,8 +1751,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{
ushort temp = DMA_OAM_access ? Core.OAM[OAM_scan_index * 4] : (ushort)0xFF;
// (sprite Y - 16) equals LY, we have a sprite
if ((temp - 16) <= LY &&
((temp - 16) + 8 + (LCDC.Bit(2) ? 8 : 0)) > LY)
if (LCDC.Bit(2) ? LY - temp is >= -16 and < 0 : LY - temp is >= -16 and < -8)
{
// always pick the first 10 in range sprites
if (SL_sprites_index < 10)

View File

@ -976,9 +976,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{
for (int i = 0; i < SL_sprites_index; i++)
{
if ((pixel_counter >= (SL_sprites[i * 4 + 1] - 8)) &&
(pixel_counter < (SL_sprites[i * 4 + 1])) &&
!evaled_sprites.Bit(i))
if (!evaled_sprites.Bit(i) && pixel_counter - SL_sprites[4 * i + 1] is >= -8 and < 0)
{
going_to_fetch = true;
fetch_sprite = true;
@ -1453,9 +1451,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// at this time it is unknown what each cycle does, but we only need to accurately keep track of cycles
for (int i = 0; i < SL_sprites_index; i++)
{
if ((pixel_counter >= (SL_sprites[i * 4 + 1] - 8)) &&
(pixel_counter < (SL_sprites[i * 4 + 1])) &&
!evaled_sprites.Bit(i))
if (!evaled_sprites.Bit(i) && pixel_counter - SL_sprites[4 * i + 1] is >= -8 and < 0)
{
sprite_fetch_counter += 6;
evaled_sprites |= (1 << i);
@ -1699,8 +1695,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{
ushort temp = DMA_OAM_access ? Core.OAM[OAM_scan_index * 4] : (ushort)0xFF;
// (sprite Y - 16) equals LY, we have a sprite
if ((temp - 16) <= LY &&
((temp - 16) + 8 + (LCDC.Bit(2) ? 8 : 0)) > LY)
if (LCDC.Bit(2) ? LY - temp is >= -16 and < 0 : LY - temp is >= -16 and < -8)
{
// always pick the first 10 in range sprites
if (SL_sprites_index < 10)

View File

@ -258,11 +258,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
input_register |= 0xF;
}
// check for interrupts
if (((contr_prev & 8) > 0) && ((input_register & 8) == 0) ||
((contr_prev & 4) > 0) && ((input_register & 4) == 0) ||
((contr_prev & 2) > 0) && ((input_register & 2) == 0) ||
((contr_prev & 1) > 0) && ((input_register & 1) == 0))
// check for interrupts
if (((contr_prev & 0b1000) is not 0 && (input_register & 0b1000) is 0)
|| ((contr_prev & 0b100) is not 0 && (input_register & 0b100) is 0)
|| ((contr_prev & 0b10) is not 0 && (input_register & 0b10) is 0)
|| ((contr_prev & 0b1) is not 0 && (input_register & 0b1) is 0))
{
if (REG_FFFF.Bit(4)) { cpu.FlagI = true; }
REG_FF0F |= 0x10;

View File

@ -558,9 +558,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// Also, on DMG only, this process only runs if sprites are on in the LCDC (on GBC it always runs)
for (int i = 0; i < SL_sprites_index; i++)
{
if ((pixel_counter >= (SL_sprites[i * 4 + 1] - 8)) &&
(pixel_counter < (SL_sprites[i * 4 + 1])) &&
!evaled_sprites.Bit(i))
if (!evaled_sprites.Bit(i) && pixel_counter - SL_sprites[4 * i + 1] is >= -8 and < 0)
{
going_to_fetch = true;
fetch_sprite = true;
@ -981,9 +979,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// at this time it is unknown what each cycle does, but we only need to accurately keep track of cycles
for (int i = 0; i < SL_sprites_index; i++)
{
if ((pixel_counter >= (SL_sprites[i * 4 + 1] - 8)) &&
(pixel_counter < (SL_sprites[i * 4 + 1])) &&
!evaled_sprites.Bit(i))
if (!evaled_sprites.Bit(i) && pixel_counter - SL_sprites[4 * i + 1] is >= -8 and < 0)
{
sprite_fetch_counter += 6;
evaled_sprites |= (1 << i);
@ -1221,8 +1217,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{
ushort temp = DMA_OAM_access ? Core.OAM[OAM_scan_index * 4] : (ushort)0xFF;
// (sprite Y - 16) equals LY, we have a sprite
if ((temp - 16) <= LY &&
((temp - 16) + 8 + (LCDC.Bit(2) ? 8 : 0)) > LY)
if (LCDC.Bit(2) ? LY - temp is >= -16 and < 0 : LY - temp is >= -16 and < -8)
{
// always pick the first 10 in range sprites
if (SL_sprites_index < 10)

View File

@ -281,10 +281,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// check for interrupts
// if an interrupt is triggered, it is delayed by 4 cycles
if (((contr_prev & 8) > 0) && ((input_register & 8) == 0) ||
((contr_prev & 4) > 0) && ((input_register & 4) == 0) ||
((contr_prev & 2) > 0) && ((input_register & 2) == 0) ||
((contr_prev & 1) > 0) && ((input_register & 1) == 0))
if (((contr_prev & 0b1000) is not 0 && (input_register & 0b1000) is 0)
|| ((contr_prev & 0b100) is not 0 && (input_register & 0b100) is 0)
|| ((contr_prev & 0b10) is not 0 && (input_register & 0b10) is 0)
|| ((contr_prev & 0b1) is not 0 && (input_register & 0b1) is 0))
{
controller_delay_cd = 4; delays_to_process = true;
}

View File

@ -5,6 +5,8 @@ using System.Runtime.InteropServices;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.N64.NativeApi;
using static BizHawk.Emulation.Cores.Nintendo.N64.N64SyncSettings.N64ControllerSettings;
namespace BizHawk.Emulation.Cores.Nintendo.N64
{
public partial class N64
@ -76,26 +78,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
MakeMemoryDomain("SRAM", mupen64plusApi.N64_MEMORY.SRAM, MemoryDomain.Endian.Big, true);
MakeMemoryDomain("FlashRAM", mupen64plusApi.N64_MEMORY.FLASHRAM, MemoryDomain.Endian.Big, true);
if (_syncSettings.Controllers[0].IsConnected &&
_syncSettings.Controllers[0].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD)
if (_syncSettings.Controllers[0] is { IsConnected: true, PakType: N64ControllerPakType.MEMORY_CARD })
{
MakeMemoryDomain("Mempak 1", mupen64plusApi.N64_MEMORY.MEMPAK1, MemoryDomain.Endian.Big, true);
}
if (_syncSettings.Controllers[1].IsConnected &&
_syncSettings.Controllers[1].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD)
if (_syncSettings.Controllers[1] is { IsConnected: true, PakType: N64ControllerPakType.MEMORY_CARD })
{
MakeMemoryDomain("Mempak 2", mupen64plusApi.N64_MEMORY.MEMPAK2, MemoryDomain.Endian.Big, true);
}
if (_syncSettings.Controllers[2].IsConnected &&
_syncSettings.Controllers[2].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD)
if (_syncSettings.Controllers[2] is { IsConnected: true, PakType: N64ControllerPakType.MEMORY_CARD })
{
MakeMemoryDomain("Mempak 3", mupen64plusApi.N64_MEMORY.MEMPAK3, MemoryDomain.Endian.Big, true);
}
if (_syncSettings.Controllers[3].IsConnected &&
_syncSettings.Controllers[3].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD)
if (_syncSettings.Controllers[3] is { IsConnected: true, PakType: N64ControllerPakType.MEMORY_CARD })
{
MakeMemoryDomain("Mempak 4", mupen64plusApi.N64_MEMORY.MEMPAK4, MemoryDomain.Endian.Big, true);
}

View File

@ -172,8 +172,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
break;
case LibsnesApi.SNES_MAPPER.SUPERFXROM:
if ((bank >= 0x40 && bank <= 0x5f) || (bank >= 0xc0 && bank <= 0xdf) ||
(low >= 0x8000 && ((bank >= 0x00 && bank <= 0x3f) || (bank >= 0x80 && bank <= 0xbf))))
if (bank is (>= 0x40 and <= 0x5F) or (>= 0xC0 and <= 0xDF)
|| (low >= 0x8000 && bank is (>= 0x00 and <= 0x3F) or (>= 0x80 and <= 0xBF)))
{
return Api.QUERY_peek(LibsnesApi.SNES_MEMORY.SYSBUS, (uint)addr);
}
@ -194,17 +194,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
break;
case LibsnesApi.SNES_MAPPER.BSCHIROM:
if ((bank >= 0x40 && bank <= 0x5f) || (bank >= 0xc0 && bank <= 0xdf) ||
(low >= 0x8000 && ((bank >= 0x00 && bank <= 0x1f) || (bank >= 0x80 && bank <= 0x9f))))
if (bank is (>= 0x40 and <= 0x5F) or (>= 0xC0 and <= 0xDF)
|| (low >= 0x8000 && bank is (>= 0x00 and <= 0x1F) or (>= 0x80 and <= 0x9F)))
{
return Api.QUERY_peek(LibsnesApi.SNES_MEMORY.SYSBUS, (uint)addr);
}
break;
case LibsnesApi.SNES_MAPPER.BSXROM:
if ((bank >= 0x40 && bank <= 0x7f) || bank >= 0xc0 ||
(low >= 0x8000 && ((bank >= 0x00 && bank <= 0x3f) || (bank >= 0x80 && bank <= 0xbf))) ||
(low >= 0x6000 && low <= 0x7fff && (bank >= 0x20 && bank <= 0x3f)))
if (bank is (>= 0x40 and <= 0x7F) or >= 0xC0
|| (low >= 0x8000 && bank is (>= 0x00 and <= 0x3F) or (>= 0x80 and <= 0xBF))
|| (low >= 0x6000 and <= 0x7FFF && bank is >= 0x20 and <= 0x3F))
{
return Api.QUERY_peek(LibsnesApi.SNES_MEMORY.SYSBUS, (uint)addr);
}

View File

@ -26,8 +26,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
if (addr < 0x1FE800) { Cpu.PendingCycles--; return VCE.ReadVCE(addr); }
if (addr < 0x1FEC00) return IOBuffer;
if (addr < 0x1FF000) { IOBuffer = (byte)(Cpu.ReadTimerValue() | (IOBuffer & 0x80)); return IOBuffer; }
if (addr >= 0x1FF000 &&
addr < 0x1FF400) { IOBuffer = ReadInput(); return IOBuffer; }
if (addr is >= 0x1FF000 and < 0x1FF400) return IOBuffer = ReadInput();
if ((addr & ~1) == 0x1FF400) return IOBuffer;
if (addr == 0x1FF402) { IOBuffer = Cpu.IRQControlByte; return IOBuffer; }
if (addr == 0x1FF403) { IOBuffer = (byte)(Cpu.ReadIrqStatus() | (IOBuffer & 0xF8)); return IOBuffer; }
@ -49,8 +48,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
else if (addr < 0x1FEC00) { IOBuffer = value; PSG.WritePSG((byte)addr, value, Cpu.TotalExecutedCycles); }
else if (addr == 0x1FEC00) { IOBuffer = value; Cpu.WriteTimer(value); }
else if (addr == 0x1FEC01) { IOBuffer = value; Cpu.WriteTimerEnable(value); }
else if (addr >= 0x1FF000 &&
addr < 0x1FF400) { IOBuffer = value; WriteInput(value); }
else if (addr is >= 0x1FF000 and < 0x1FF400) WriteInput(IOBuffer = value);
else if (addr == 0x1FF402) { IOBuffer = value; Cpu.WriteIrqControl(value); }
else if (addr == 0x1FF403) { IOBuffer = value; Cpu.WriteIrqStatus(); }
else Log.Error("MEM", "unhandled hardware write [{0:X6}] : {1:X2}", addr, value);

View File

@ -28,8 +28,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
if (addr < 0x1FE800) { Cpu.PendingCycles--; return VCE.ReadVCE(addr); }
if (addr < 0x1FEC00) return IOBuffer;
if (addr < 0x1FF000) { IOBuffer = (byte)(Cpu.ReadTimerValue() | (IOBuffer & 0x80)); return IOBuffer; }
if (addr >= 0x1FF000 &&
addr < 0x1FF400) { IOBuffer = ReadInput(); return IOBuffer; }
if (addr is >= 0x1FF000 and < 0x1FF400) return IOBuffer = ReadInput();
if ((addr & ~1) == 0x1FF400) return IOBuffer;
if (addr == 0x1FF402) { IOBuffer = Cpu.IRQControlByte; return IOBuffer; }
if (addr == 0x1FF403) { IOBuffer = (byte)(Cpu.ReadIrqStatus() | (IOBuffer & 0xF8)); return IOBuffer; }
@ -64,8 +63,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
else if (addr < 0x1FEC00) { IOBuffer = value; PSG.WritePSG((byte)addr, value, Cpu.TotalExecutedCycles); }
else if (addr == 0x1FEC00) { IOBuffer = value; Cpu.WriteTimer(value); }
else if (addr == 0x1FEC01) { IOBuffer = value; Cpu.WriteTimerEnable(value); }
else if (addr >= 0x1FF000 &&
addr < 0x1FF400) { IOBuffer = value; WriteInput(value); }
else if (addr is >= 0x1FF000 and < 0x1FF400) WriteInput(IOBuffer = value);
else if (addr == 0x1FF402) { IOBuffer = value; Cpu.WriteIrqControl(value); }
else if (addr == 0x1FF403) { IOBuffer = value; Cpu.WriteIrqStatus(); }
else Log.Error("MEM", "unhandled hardware write [{0:X6}] : {1:X2}", addr, value);

View File

@ -29,8 +29,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
if (addr < 0x1FE800) { Cpu.PendingCycles--; return VCE.ReadVCE(addr); }
if (addr < 0x1FEC00) return IOBuffer;
if (addr < 0x1FF000) { IOBuffer = (byte)(Cpu.ReadTimerValue() | (IOBuffer & 0x80)); return IOBuffer; }
if (addr >= 0x1FF000 &&
addr < 0x1FF400) { IOBuffer = ReadInput(); return IOBuffer; }
if (addr is >= 0x1FF000 and < 0x1FF400) return IOBuffer = ReadInput();
if ((addr & ~1) == 0x1FF400) return IOBuffer;
if (addr == 0x1FF402) { IOBuffer = Cpu.IRQControlByte; return IOBuffer; }
if (addr == 0x1FF403) { IOBuffer = (byte)(Cpu.ReadIrqStatus() | (IOBuffer & 0xF8)); return IOBuffer; }
@ -58,8 +57,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
else if (addr < 0x1FEC00) { IOBuffer = value; PSG.WritePSG((byte)addr, value, Cpu.TotalExecutedCycles); }
else if (addr == 0x1FEC00) { IOBuffer = value; Cpu.WriteTimer(value); }
else if (addr == 0x1FEC01) { IOBuffer = value; Cpu.WriteTimerEnable(value); }
else if (addr >= 0x1FF000 &&
addr < 0x1FF400) { IOBuffer = value; WriteInput(value); }
else if (addr is >= 0x1FF000 and < 0x1FF400) WriteInput(IOBuffer = value);
else if (addr == 0x1FF402) { IOBuffer = value; Cpu.WriteIrqControl(value); }
else if (addr == 0x1FF403) { IOBuffer = value; Cpu.WriteIrqStatus(); }
else Log.Error("MEM", "unhandled hardware write [{0:X6}] : {1:X2}", addr, value);

View File

@ -24,8 +24,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
if (addr < 0x1FE800) { Cpu.PendingCycles--; return VCE.ReadVCE(addr); }
if (addr < 0x1FEC00) return IOBuffer;
if (addr < 0x1FF000) { IOBuffer = (byte)(Cpu.ReadTimerValue() | (IOBuffer & 0x80)); return IOBuffer; }
if (addr >= 0x1FF000 &&
addr < 0x1FF400) { IOBuffer = ReadInput(); return IOBuffer; }
if (addr is >= 0x1FF000 and < 0x1FF400) return IOBuffer = ReadInput();
if ((addr & ~1) == 0x1FF400) return IOBuffer;
if (addr == 0x1FF402) { IOBuffer = Cpu.IRQControlByte; return IOBuffer; }
if (addr == 0x1FF403) { IOBuffer = (byte)(Cpu.ReadIrqStatus() | (IOBuffer & 0xF8)); return IOBuffer; }
@ -69,8 +68,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
else if (addr < 0x1FEC00) { IOBuffer = value; PSG.WritePSG((byte)addr, value, Cpu.TotalExecutedCycles); }
else if (addr == 0x1FEC00) { IOBuffer = value; Cpu.WriteTimer(value); }
else if (addr == 0x1FEC01) { IOBuffer = value; Cpu.WriteTimerEnable(value); }
else if (addr >= 0x1FF000 &&
addr < 0x1FF400) { IOBuffer = value; WriteInput(value); }
else if (addr is >= 0x1FF000 and < 0x1FF400) WriteInput(IOBuffer = value);
else if (addr == 0x1FF402) { IOBuffer = value; Cpu.WriteIrqControl(value); }
else if (addr == 0x1FF403) { IOBuffer = value; Cpu.WriteIrqStatus(); }
else if (addr >= 0x1FF800) { WriteCD(addr, value); }

View File

@ -20,8 +20,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
if (addr < 0x1FE800) { Cpu.PendingCycles--; return VCE.ReadVCE(addr); }
if (addr < 0x1FEC00) return IOBuffer;
if (addr < 0x1FF000) { IOBuffer = (byte)(Cpu.ReadTimerValue() | (IOBuffer & 0x80)); return IOBuffer; }
if (addr >= 0x1FF000 &&
addr < 0x1FF400) { IOBuffer = ReadInput(); return IOBuffer; }
if (addr is >= 0x1FF000 and < 0x1FF400) return IOBuffer = ReadInput();
if ((addr & ~1) == 0x1FF400) return IOBuffer;
if (addr == 0x1FF402) { IOBuffer = Cpu.IRQControlByte; return IOBuffer; }
if (addr == 0x1FF403) { IOBuffer = (byte)(Cpu.ReadIrqStatus() | (IOBuffer & 0xF8)); return IOBuffer; }
@ -54,8 +53,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
else if (addr < 0x1FEC00) { IOBuffer = value; PSG.WritePSG((byte)addr, value, Cpu.TotalExecutedCycles); }
else if (addr == 0x1FEC00) { IOBuffer = value; Cpu.WriteTimer(value); }
else if (addr == 0x1FEC01) { IOBuffer = value; Cpu.WriteTimerEnable(value); }
else if (addr >= 0x1FF000 &&
addr < 0x1FF400) { IOBuffer = value; WriteInput(value); }
else if (addr is >= 0x1FF000 and < 0x1FF400) WriteInput(IOBuffer = value);
else if (addr == 0x1FF402) { IOBuffer = value; Cpu.WriteIrqControl(value); }
else if (addr == 0x1FF403) { IOBuffer = value; Cpu.WriteIrqStatus(); }
else if (addr >= 0x1FF800) { WriteCD(addr, value); }

View File

@ -107,10 +107,11 @@ namespace BizHawk.Emulation.Cores.PCEngine
public void RenderScanLine()
{
if (((ActiveLine + ViewStartLine) >= pce.Settings.BottomLine) ||
((ActiveLine + ViewStartLine) < pce.Settings.TopLine))
if (pce.Settings.BottomLine <= ActiveLine + ViewStartLine
|| ActiveLine + ViewStartLine < pce.Settings.TopLine)
{
return;
}
RenderBackgroundScanline(pce.Settings.ShowBG1);
RenderSpritesScanline(pce.Settings.ShowOBJ1);
}

View File

@ -245,8 +245,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
private void RenderScanLine()
{
if (((VDC1.ActiveLine + VDC1.ViewStartLine) >= PCE.Settings.BottomLine) ||
((VDC1.ActiveLine + VDC1.ViewStartLine) < PCE.Settings.TopLine))
if (PCE.Settings.BottomLine <= VDC1.ActiveLine + VDC1.ViewStartLine
|| VDC1.ActiveLine + VDC1.ViewStartLine < PCE.Settings.TopLine)
{
return;
}

View File

@ -181,8 +181,8 @@
_lagged = false;
byte value = 0xC0;
if ((_controller.IsPressed("Pause") && !IsGameGear) ||
(_controller.IsPressed("P1 Start") && IsGameGear_C))
if ((!IsGameGear && _controller.IsPressed("Pause"))
|| (IsGameGear_C && _controller.IsPressed("P1 Start")))
{
value ^= 0x80;
}

View File

@ -28,9 +28,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
{
if (r.Key.StartsWithOrdinal("M68K")) // drop Z80 regs until it has its own debugger/tracer
{
if (r.Key != "M68K SP" && r.Key != "M68K ISP" && // copies of a7
r.Key != "M68K PC" && // already present in every line start
r.Key != "M68K IR") // copy of last opcode, already shown in raw bytes
if (r.Key is not ("M68K SP" or "M68K ISP" // copies of a7
or "M68K PC" // already present in every line start
or "M68K IR")) // copy of last opcode, already shown in raw bytes
{
sb.Append($"{r.Key.Replace("M68K", "").Trim()}:{r.Value.Value.ToHexString(r.Value.BitSize / 4)} ");
}