Implemented a load more Z80 OpCodes
This commit is contained in:
@@ -322,6 +322,9 @@ namespace Core.Cpu
|
||||
case 0x04: // INC B
|
||||
BC.High = Inc8(BC.High);
|
||||
return 4;
|
||||
case 0x0E: // LD C, n
|
||||
BC.Low = FetchByte();
|
||||
return 7; // Takes 7 T-States
|
||||
case 0x10: // DJNZ d
|
||||
sbyte djnzOffset = (sbyte)FetchByte();
|
||||
|
||||
@@ -606,7 +609,7 @@ namespace Core.Cpu
|
||||
targetAddress = (ushort)(IY.Word + offset75);
|
||||
// Write the low byte of HL to memory
|
||||
_memory.Write(targetAddress, HL.Low);
|
||||
return 19;
|
||||
return 19;
|
||||
case 0xCB: // The FD CB nested prefix
|
||||
{
|
||||
sbyte offsetCB = (sbyte)FetchByte(); // This is the '01'
|
||||
@@ -615,6 +618,35 @@ namespace Core.Cpu
|
||||
|
||||
switch (bitOpcode)
|
||||
{
|
||||
case 0x4E: // BIT 1, (IY+d)
|
||||
{
|
||||
byte memValBit = _memory.Read(targetAddress);
|
||||
|
||||
// Check if bit 1 is 0
|
||||
bool bitIsZero = (memValBit & 0x02) == 0;
|
||||
|
||||
// Preserve the Carry flag (Bit 0), clear everything else
|
||||
AF.Low &= 0x01;
|
||||
|
||||
// Set Half-Carry (Bit 4) - Standard Z80 behavior for BIT
|
||||
AF.Low |= 0x10;
|
||||
|
||||
if (bitIsZero)
|
||||
{
|
||||
AF.Low |= 0x40; // Set Zero Flag (Bit 6)
|
||||
AF.Low |= 0x04; // Set P/V Flag (Bit 2)
|
||||
}
|
||||
|
||||
return 20; // Takes 20 T-States
|
||||
}
|
||||
case 0x8E: // RES 1, (IY+d)
|
||||
byte memValRes = _memory.Read(targetAddress);
|
||||
|
||||
// 0xFD is Binary 1111 1101.
|
||||
// ANDing with this preserves all bits except Bit 1, which becomes 0.
|
||||
memValRes &= 0xFD;
|
||||
_memory.Write(targetAddress, memValRes);
|
||||
return 23;
|
||||
case 0xCE: // SET 1, (IY+d)
|
||||
memVal = _memory.Read(targetAddress);
|
||||
memVal |= 0x02; // 0x02 is Binary 0000 0010 (Bit 1)
|
||||
|
||||
Reference in New Issue
Block a user