Skip to content

Commit

Permalink
BBRi and BBSi opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Jul 1, 2024
1 parent c9b8d03 commit 7324b9e
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 75 deletions.
2 changes: 1 addition & 1 deletion src/huc6280.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ unsigned int HuC6280::Tick()

m_t_states += k_opcode_tstates[opcode];
m_t_states += m_page_crossed ? k_opcode_tstates_cross_paged[opcode] : 0;
m_t_states += m_branch_taken ? 1 : 0;
m_t_states += m_branch_taken ? 2 : 0;

return m_t_states;
}
Expand Down
96 changes: 48 additions & 48 deletions src/huc6280_opcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ void HuC6280::OPCode0x0E()

void HuC6280::OPCode0x0F()
{
// UNOFFICIAL
// SLO $nn
UnofficialOPCode();
// OK
// BBR0 ZZ,hhll
OPcodes_Branch(!IsSetBit(0, m_memory->Read(ZeroPageAddressing())));
}

void HuC6280::OPCode0x10()
Expand Down Expand Up @@ -228,9 +228,9 @@ void HuC6280::OPCode0x1E()

void HuC6280::OPCode0x1F()
{
// UNOFFICIAL
// SLO $nn,X
UnofficialOPCode();
// OK
// BBR1 ZZ,hhll
OPcodes_Branch(!IsSetBit(1, m_memory->Read(ZeroPageAddressing())));
}

void HuC6280::OPCode0x20()
Expand Down Expand Up @@ -336,9 +336,9 @@ void HuC6280::OPCode0x2E()

void HuC6280::OPCode0x2F()
{
// UNOFFICIAL
// RLA $nn
UnofficialOPCode();
// OK
// BBR2 ZZ,hhll
OPcodes_Branch(!IsSetBit(2, m_memory->Read(ZeroPageAddressing())));
}

void HuC6280::OPCode0x30()
Expand Down Expand Up @@ -444,9 +444,9 @@ void HuC6280::OPCode0x3E()

void HuC6280::OPCode0x3F()
{
// UNOFFICIAL
// RLA $nn,X
UnofficialOPCode();
// OK
// BBR3 ZZ,hhll
OPcodes_Branch(!IsSetBit(3, m_memory->Read(ZeroPageAddressing())));
}

void HuC6280::OPCode0x40()
Expand Down Expand Up @@ -548,9 +548,9 @@ void HuC6280::OPCode0x4E()

void HuC6280::OPCode0x4F()
{
// UNOFFICIAL
// SRE $nn
UnofficialOPCode();
// OK
// BBR4 ZZ,hhll
OPcodes_Branch(!IsSetBit(4, m_memory->Read(ZeroPageAddressing())));
}

void HuC6280::OPCode0x50()
Expand Down Expand Up @@ -652,9 +652,9 @@ void HuC6280::OPCode0x5E()

void HuC6280::OPCode0x5F()
{
// UNOFFICIAL
// SRE $nn,X
UnofficialOPCode();
// OK
// BBR5 ZZ,hhll
OPcodes_Branch(!IsSetBit(5, m_memory->Read(ZeroPageAddressing())));
}

void HuC6280::OPCode0x60()
Expand Down Expand Up @@ -764,9 +764,9 @@ void HuC6280::OPCode0x6E()

void HuC6280::OPCode0x6F()
{
// UNOFFICIAL
// RRA $nn
UnofficialOPCode();
// OK
// BBR6 ZZ,hhll
OPcodes_Branch(!IsSetBit(6, m_memory->Read(ZeroPageAddressing())));
}

void HuC6280::OPCode0x70()
Expand Down Expand Up @@ -872,9 +872,9 @@ void HuC6280::OPCode0x7E()

void HuC6280::OPCode0x7F()
{
// UNOFFICIAL
// RRA $nn,X
UnofficialOPCode();
// OK
// BBR7 ZZ,hhll
OPcodes_Branch(!IsSetBit(7, m_memory->Read(ZeroPageAddressing())));
}

void HuC6280::OPCode0x80()
Expand Down Expand Up @@ -975,9 +975,9 @@ void HuC6280::OPCode0x8E()

void HuC6280::OPCode0x8F()
{
// UNOFFICIAL
// SAX $nn
UnofficialOPCode();
// OK
// BBS0 ZZ,hhll
OPcodes_Branch(IsSetBit(0, m_memory->Read(ZeroPageAddressing())));
}

void HuC6280::OPCode0x90()
Expand Down Expand Up @@ -1078,9 +1078,9 @@ void HuC6280::OPCode0x9E()

void HuC6280::OPCode0x9F()
{
// UNOFFICIAL
// AHX $nn,Y
UnofficialOPCode();
// OK
// BBS1 ZZ,hhll
OPcodes_Branch(IsSetBit(1, m_memory->Read(ZeroPageAddressing())));
}

void HuC6280::OPCode0xA0()
Expand Down Expand Up @@ -1178,9 +1178,9 @@ void HuC6280::OPCode0xAE()

void HuC6280::OPCode0xAF()
{
// UNOFFICIAL
// LAX $nn
UnofficialOPCode();
// OK
// BBS2 ZZ,hhll
OPcodes_Branch(IsSetBit(2, m_memory->Read(ZeroPageAddressing())));
}

void HuC6280::OPCode0xB0()
Expand Down Expand Up @@ -1279,9 +1279,9 @@ void HuC6280::OPCode0xBE()

void HuC6280::OPCode0xBF()
{
// UNOFFICIAL
// LAX $nn,Y
UnofficialOPCode();
// OK
// BBS3 ZZ,hhll
OPcodes_Branch(IsSetBit(3, m_memory->Read(ZeroPageAddressing())));
}

void HuC6280::OPCode0xC0()
Expand Down Expand Up @@ -1380,9 +1380,9 @@ void HuC6280::OPCode0xCE()

void HuC6280::OPCode0xCF()
{
// UNOFFICIAL
// DCP $nn
UnofficialOPCode();
// OK
// BBS4 ZZ,hhll
OPcodes_Branch(IsSetBit(4, m_memory->Read(ZeroPageAddressing())));
}

void HuC6280::OPCode0xD0()
Expand Down Expand Up @@ -1484,9 +1484,9 @@ void HuC6280::OPCode0xDE()

void HuC6280::OPCode0xDF()
{
// UNOFFICIAL
// DCP $nn,X
UnofficialOPCode();
// OK
// BBS5 ZZ,hhll
OPcodes_Branch(IsSetBit(5, m_memory->Read(ZeroPageAddressing())));
}

void HuC6280::OPCode0xE0()
Expand Down Expand Up @@ -1584,9 +1584,9 @@ void HuC6280::OPCode0xEE()

void HuC6280::OPCode0xEF()
{
// UNOFFICIAL
// ISC $nn
UnofficialOPCode();
// OK
// BBS6 ZZ,hhll
OPcodes_Branch(IsSetBit(6, m_memory->Read(ZeroPageAddressing())));
}

void HuC6280::OPCode0xF0()
Expand Down Expand Up @@ -1688,7 +1688,7 @@ void HuC6280::OPCode0xFE()

void HuC6280::OPCode0xFF()
{
// UNOFFICIAL
// ISC $nn,X
UnofficialOPCode();
// OK
// BBS7 ZZ,hhll
OPcodes_Branch(IsSetBit(7, m_memory->Read(ZeroPageAddressing())));
}
24 changes: 24 additions & 0 deletions src/huc6280_registers.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class EightBitRegister
u8 GetValue() const;
void SetValue(u8 value);
void Increment();
void Increment(u8 value);
void Decrement();
void Decrement(u8 value);

private:
u8 m_value;
Expand All @@ -50,11 +52,21 @@ inline void EightBitRegister::Increment()
m_value++;
}

inline void EightBitRegister::Increment(u8 value)
{
m_value += value;
}

inline void EightBitRegister::Decrement()
{
m_value--;
}

inline void EightBitRegister::Decrement(u8 value)
{
m_value -= value;
}

//////////////////////////////////////////////////////////////////////////

class SixteenBitRegister
Expand All @@ -68,7 +80,9 @@ class SixteenBitRegister
void SetHigh(u8 high);
void SetValue(u16 value);
void Increment();
void Increment(u16 value);
void Decrement();
void Decrement(u16 value);

private:
u16 m_value;
Expand Down Expand Up @@ -109,9 +123,19 @@ inline void SixteenBitRegister::Increment()
m_value++;
}

inline void SixteenBitRegister::Increment(u16 value)
{
m_value += value;
}

inline void SixteenBitRegister::Decrement()
{
m_value--;
}

inline void SixteenBitRegister::Decrement(u16 value)
{
m_value -= value;
}

#endif /* HUC6280_REGISTERS_H */
52 changes: 26 additions & 26 deletions src/huc6280_timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ const u8 k_opcode_tstates[256] =
{
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
/* 0x00 */ 7, 6, 2, 8, 3, 3, 6, 5, 3, 2, 2, 2, 4, 4, 7, 6,
/* 0x10 */ 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7,
/* 0x10 */ 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 6,
/* 0x20 */ 6, 7, 2, 8, 3, 4, 5, 5, 4, 2, 2, 2, 4, 5, 6, 6,
/* 0x30 */ 2, 7, 7, 8, 4, 4, 6, 6, 2, 5, 2, 7, 4, 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