Skip to content

Commit

Permalink
SEC SED SEI SET SMBi opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Jul 2, 2024
1 parent 6a7bae1 commit e8d2f69
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 43 deletions.
1 change: 1 addition & 0 deletions src/huc6280.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class HuC6280
void OPCodes_ROR_Accumulator();
void OPCodes_ROR_Memory(u16 address);
void OPCodes_SBC(u8 value);
void OPCodes_SMB(int bit, u16 address);
void OPCodes_Store(EightBitRegister* reg, u16 address);
void OPCodes_Transfer(EightBitRegister* reg, EightBitRegister* target);

Expand Down
57 changes: 30 additions & 27 deletions src/huc6280_opcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ void HuC6280::OPCode0x37()

void HuC6280::OPCode0x38()
{
// OK
// SEC
OPCodes_SetFlag(FLAG_CARRY);
}
Expand Down Expand Up @@ -879,6 +880,7 @@ void HuC6280::OPCode0x77()

void HuC6280::OPCode0x78()
{
// OK
// SEI
OPCodes_SetFlag(FLAG_IRQ);
}
Expand Down Expand Up @@ -985,9 +987,9 @@ void HuC6280::OPCode0x86()

void HuC6280::OPCode0x87()
{
// UNOFFICIAL
// SAX $n
UnofficialOPCode();
// OK
// SMB0 ZZ
OPCodes_SMB(0, ZeroPageAddressing());
}

void HuC6280::OPCode0x88()
Expand Down Expand Up @@ -1090,9 +1092,9 @@ void HuC6280::OPCode0x96()

void HuC6280::OPCode0x97()
{
// UNOFFICIAL
// SAX $n,Y
UnofficialOPCode();
// OK
// SMB1 ZZ
OPCodes_SMB(1, ZeroPageAddressing());
}

void HuC6280::OPCode0x98()
Expand Down Expand Up @@ -1198,9 +1200,9 @@ void HuC6280::OPCode0xA6()

void HuC6280::OPCode0xA7()
{
// UNOFFICIAL
// LAX $n
UnofficialOPCode();
// OK
// SMB2 ZZ
OPCodes_SMB(2, ZeroPageAddressing());
}

void HuC6280::OPCode0xA8()
Expand Down Expand Up @@ -1308,9 +1310,9 @@ void HuC6280::OPCode0xB6()

void HuC6280::OPCode0xB7()
{
// UNOFFICIAL
// LAX $n,Y
UnofficialOPCode();
// OK
// SMB3 ZZ
OPCodes_SMB(3, ZeroPageAddressing());
}

void HuC6280::OPCode0xB8()
Expand Down Expand Up @@ -1420,9 +1422,9 @@ void HuC6280::OPCode0xC6()

void HuC6280::OPCode0xC7()
{
// UNOFFICIAL
// DCP $n
UnofficialOPCode();
// OK
// SMB4 ZZ
OPCodes_SMB(4, ZeroPageAddressing());
}

void HuC6280::OPCode0xC8()
Expand Down Expand Up @@ -1532,9 +1534,9 @@ void HuC6280::OPCode0xD6()

void HuC6280::OPCode0xD7()
{
// UNOFFICIAL
// DCP $n,X
UnofficialOPCode();
// OK
// SMB5 ZZ
OPCodes_SMB(5, ZeroPageAddressing());
}

void HuC6280::OPCode0xD8()
Expand Down Expand Up @@ -1643,9 +1645,9 @@ void HuC6280::OPCode0xE6()

void HuC6280::OPCode0xE7()
{
// UNOFFICIAL
// ISC $n
UnofficialOPCode();
// OK
// SMB6 ZZ
OPCodes_SMB(6, ZeroPageAddressing());
}

void HuC6280::OPCode0xE8()
Expand Down Expand Up @@ -1729,9 +1731,9 @@ void HuC6280::OPCode0xF3()

void HuC6280::OPCode0xF4()
{
// UNOFFICIAL
// NOP $n,X
UnofficialOPCode();
// OK
// SET
OPCodes_SetFlag(FLAG_MEMORY);
}

void HuC6280::OPCode0xF5()
Expand All @@ -1749,13 +1751,14 @@ void HuC6280::OPCode0xF6()

void HuC6280::OPCode0xF7()
{
// UNOFFICIAL
// ISC $n,X
UnofficialOPCode();
// OK
// SMB7 ZZ
OPCodes_SMB(7, ZeroPageAddressing());
}

void HuC6280::OPCode0xF8()
{
// OK
// SED
OPCodes_SetFlag(FLAG_DECIMAL);
}
Expand Down
7 changes: 7 additions & 0 deletions src/huc6280_opcodes_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,13 @@ inline void HuC6280::OPCodes_SBC(u8 value)
}
}

inline void HuC6280::OPCodes_SMB(int bit, u16 address)
{
ClearFlag(FLAG_MEMORY);
u8 result = SetBit(m_memory->Read(address), bit);
m_memory->Write(address, result);
}

inline void HuC6280::OPCodes_Store(EightBitRegister* reg, u16 address)
{
ClearFlag(FLAG_MEMORY);
Expand Down
32 changes: 16 additions & 16 deletions src/huc6280_timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ const u8 k_opcode_tstates[256] =
/* 0x50 */ 2, 7, 7, 8, 4, 4, 6, 7, 2, 5, 3, 7, 4, 5, 7, 6,
/* 0x60 */ 7, 7, 2, 8, 3, 4, 6, 7, 4, 2, 2, 2, 7, 5, 7, 6,
/* 0x70 */ 2, 7, 7, 8, 4, 4, 6, 7, 2, 5, 4, 7, 7, 5, 7, 6,
/* 0x80 */ 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 6,
/* 0x90 */ 2, 6, 2, 6, 4, 4, 4, 4, 2, 5, 2, 5, 5, 5, 5, 6,
/* 0xA0 */ 2, 7, 2, 6, 4, 4, 4, 3, 2, 2, 2, 2, 5, 5, 5, 6,
/* 0xB0 */ 2, 7, 7, 5, 4, 4, 4, 4, 2, 5, 2, 4, 5, 5, 5, 6,
/* 0xC0 */ 2, 7, 2, 8, 4, 4, 6, 5, 2, 2, 2, 2, 5, 5, 7, 6,
/* 0xD0 */ 2, 7, 7, 8, 4, 4, 6, 6, 2, 5, 3, 7, 4, 5, 7, 6,
/* 0xE0 */ 2, 6, 2, 8, 4, 3, 6, 5, 2, 2, 2, 2, 5, 4, 7, 6,
/* 0xF0 */ 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 4, 7, 4, 4, 7, 6
/* 0x80 */ 2, 6, 2, 6, 3, 3, 3, 7, 2, 2, 2, 2, 4, 4, 4, 6,
/* 0x90 */ 2, 6, 2, 6, 4, 4, 4, 7, 2, 5, 2, 5, 5, 5, 5, 6,
/* 0xA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