Skip to content

Commit

Permalink
TAI TDD TIA TII TIN opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Jul 2, 2024
1 parent 0173f6b commit fea262b
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 25 deletions.
5 changes: 5 additions & 0 deletions src/huc6280.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ class HuC6280
void OPCodes_TRB(u16 address);
void OPCodes_TSB(u16 address);
void OPCodes_TST(u8 value, u16 address);
void OPCodes_TAI();
void OPCodes_TDD();
void OPCodes_TIA();
void OPCodes_TII();
void OPCodes_TIN();

void InitOPCodeFunctors();

Expand Down
30 changes: 15 additions & 15 deletions src/huc6280_opcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,9 +849,9 @@ void HuC6280::OPCode0x72()

void HuC6280::OPCode0x73()
{
// UNOFFICIAL
// RRA ($n),Y
UnofficialOPCode();
// OK
// TII
OPCodes_TII();
}

void HuC6280::OPCode0x74()
Expand Down Expand Up @@ -1421,9 +1421,9 @@ void HuC6280::OPCode0xC2()

void HuC6280::OPCode0xC3()
{
// UNOFFICIAL
// DCP $(nn,X)
UnofficialOPCode();
// OK
// TDD
OPCodes_TDD();
}

void HuC6280::OPCode0xC4()
Expand Down Expand Up @@ -1533,9 +1533,9 @@ void HuC6280::OPCode0xD2()

void HuC6280::OPCode0xD3()
{
// UNOFFICIAL
// DCP ($n),Y
UnofficialOPCode();
// OK
// TIN
OPCodes_TIN();
}

void HuC6280::OPCode0xD4()
Expand Down Expand Up @@ -1645,9 +1645,9 @@ void HuC6280::OPCode0xE2()

void HuC6280::OPCode0xE3()
{
// UNOFFICIAL
// ISC $(nn,X)
UnofficialOPCode();
// OK
// TIA
OPCodes_TIA();
}

void HuC6280::OPCode0xE4()
Expand Down Expand Up @@ -1751,9 +1751,9 @@ void HuC6280::OPCode0xF2()

void HuC6280::OPCode0xF3()
{
// UNOFFICIAL
// ISC ($n),Y
UnofficialOPCode();
// OK
// TAI
OPCodes_TAI();
}

void HuC6280::OPCode0xF4()
Expand Down
75 changes: 75 additions & 0 deletions src/huc6280_opcodes_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,4 +554,79 @@ inline void HuC6280::OPCodes_TST(u8 value, u16 address)
SetOverflowFlagFromResult(result);
}

inline void HuC6280::OPCodes_TAI()
{
// TODO
u16 source = Fetch16();
u16 dest = Fetch16();
u16 length = Fetch16();

for (u16 i = 0; i < length; i++)
{
u8 value = m_memory->Read(source + i);
m_memory->Write(dest + i, value);
m_t_states += 6;
}
}

inline void HuC6280::OPCodes_TDD()
{
// TODO
u16 source = Fetch16();
u16 dest = Fetch16();
u16 length = Fetch16();

for (u16 i = 0; i < length; i++)
{
u8 value = m_memory->Read(source + i);
m_memory->Write(dest + i, value);
m_t_states += 6;
}
}

inline void HuC6280::OPCodes_TIA()
{
// TODO
u16 source = Fetch16();
u16 dest = Fetch16();
u16 length = Fetch16();

for (u16 i = 0; i < length; i++)
{
u8 value = m_memory->Read(source + i);
m_memory->Write(dest + i, value);
m_t_states += 6;
}
}

inline void HuC6280::OPCodes_TII()
{
// TODO
u16 source = Fetch16();
u16 dest = Fetch16();
u16 length = Fetch16();

for (u16 i = 0; i < length; i++)
{
u8 value = m_memory->Read(source + i);
m_memory->Write(dest + i, value);
m_t_states += 6;
}
}

inline void HuC6280::OPCodes_TIN()
{
// TODO
u16 source = Fetch16();
u16 dest = Fetch16();
u16 length = Fetch16();

for (u16 i = 0; i < length; i++)
{
u8 value = m_memory->Read(source + i);
m_memory->Write(dest + i, value);
m_t_states += 6;
}
}

#endif /* HUC6280_OPCODES_INLINE_H */
20 changes: 10 additions & 10 deletions src/huc6280_timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ const u8 k_opcode_tstates[256] =
/* 0x40 */ 7, 7, 3, 4, 8, 4, 6, 7, 3, 2, 2, 2, 4, 5, 7, 6,
/* 0x50 */ 2, 7, 7, 5, 4, 4, 6, 7, 2, 5, 3, 7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