Skip to content

Commit

Permalink
EOR opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Jul 1, 2024
1 parent aced044 commit 6b5ad44
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
30 changes: 19 additions & 11 deletions src/huc6280_opcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,8 @@ void HuC6280::OPCode0x40()

void HuC6280::OPCode0x41()
{
// EOR $(nn,X)
// OK
// EOR (ZZ,X)
OPCodes_EOR(m_memory->Read(IndexedIndirectAddressing()));
}

Expand All @@ -491,7 +492,8 @@ void HuC6280::OPCode0x44()

void HuC6280::OPCode0x45()
{
// EOR $n
// OK
// EOR ZZ
OPCodes_EOR(m_memory->Read(ZeroPageAddressing()));
}

Expand All @@ -516,7 +518,8 @@ void HuC6280::OPCode0x48()

void HuC6280::OPCode0x49()
{
// EOR #$n
// OK
// EOR #nn
OPCodes_EOR(ImmediateAddressing());
}

Expand All @@ -542,7 +545,8 @@ void HuC6280::OPCode0x4C()

void HuC6280::OPCode0x4D()
{
// EOR $nn
// OK
// EOR hhll
OPCodes_EOR(m_memory->Read(AbsoluteAddressing()));
}

Expand All @@ -568,15 +572,16 @@ void HuC6280::OPCode0x50()

void HuC6280::OPCode0x51()
{
// EOR ($n),Y
// OK
// EOR (ZZ),Y
OPCodes_EOR(m_memory->Read(IndirectIndexedAddressing()));
}

void HuC6280::OPCode0x52()
{
// UNOFFICIAL
// KILL
UnofficialOPCode();
// OK
// EOR (ZZ)
OPCodes_EOR(m_memory->Read(ZeroPageIndirectAddressing()));
}

void HuC6280::OPCode0x53()
Expand All @@ -595,7 +600,8 @@ void HuC6280::OPCode0x54()

void HuC6280::OPCode0x55()
{
// EOR $n,X
// OK
// EOR ZZ,X
OPCodes_EOR(m_memory->Read(ZeroPageAddressing(&m_X)));
}

Expand All @@ -621,7 +627,8 @@ void HuC6280::OPCode0x58()

void HuC6280::OPCode0x59()
{
// EOR $nn,Y
// OK
// EOR hhll,Y
OPCodes_EOR(m_memory->Read(AbsoluteAddressing(&m_Y)));
}

Expand All @@ -648,7 +655,8 @@ void HuC6280::OPCode0x5C()

void HuC6280::OPCode0x5D()
{
// EOR $nn,X
// OK
// EOR hhll,X
OPCodes_EOR(m_memory->Read(AbsoluteAddressing(&m_X)));
}

Expand Down
17 changes: 15 additions & 2 deletions src/huc6280_opcodes_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,21 @@ inline void HuC6280::OPCodes_DEC_Reg(EightBitRegister* reg)

inline void HuC6280::OPCodes_EOR(u8 value)
{
u8 result = m_A.GetValue() ^ value;
m_A.SetValue(result);
u8 result;
if (IsSetFlag(FLAG_MEMORY))
{
u16 address = ZeroPageX();
u8 a = m_memory->Read(address);
result = a ^ value;
m_memory->Write(address, result);
m_t_states += 3;
ClearFlag(FLAG_MEMORY);
}
else
{
result = m_A.GetValue() ^ value;
m_A.SetValue(result);
}
SetZeroFlagFromResult(result);
SetNegativeFlagFromResult(result);
}
Expand Down

0 comments on commit 6b5ad44

Please sign in to comment.