Skip to content

Commit

Permalink
Structure for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Aug 3, 2024
1 parent 346b2b2 commit 21d3041
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion platforms/shared/desktop/gui_debug_huc6280.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void gui_debug_window_huc6280(void)

ImGui::TableNextColumn();
ImGui::TextColored(yellow, " SP"); ImGui::SameLine();
ImGui::Text("= $%04X", 0x2100 | proc_state->S->GetValue());
ImGui::Text("= $%04X", STACK_ADDR | proc_state->S->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED " " BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(0x21), BYTE_TO_BINARY(proc_state->S->GetValue()));

ImGui::TableNextColumn();
Expand Down
8 changes: 8 additions & 0 deletions src/huc6280.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
#define FLAG_OVERFLOW 0x40
#define FLAG_NEGATIVE 0x80

#if defined(GEARGRAFX_TESTING)
#define ZERO_PAGE_ADDR 0x0000
#define STACK_ADDR 0x0100
#else
#define ZERO_PAGE_ADDR 0x2000
#define STACK_ADDR 0x2100
#endif

class Memory;
class HuC6270;

Expand Down
18 changes: 9 additions & 9 deletions src/huc6280_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ inline bool HuC6280::PageCrossed(u16 old_address, u16 new_address)

inline u16 HuC6280::ZeroPageX()
{
return 0x2000 | m_X.GetValue();
return ZERO_PAGE_ADDR | m_X.GetValue();
}

inline void HuC6280::SetOrClearZNFlags(u8 result)
Expand Down Expand Up @@ -210,31 +210,31 @@ inline bool HuC6280::IsSetFlag(u8 flag)

inline void HuC6280::StackPush16(u16 value)
{
m_memory->Write(0x2100 | m_S.GetValue(), static_cast<u8>(value >> 8));
m_memory->Write(STACK_ADDR | m_S.GetValue(), static_cast<u8>(value >> 8));
m_S.Decrement();
m_memory->Write(0x2100 | m_S.GetValue(), static_cast<u8>(value & 0x00FF));
m_memory->Write(STACK_ADDR | m_S.GetValue(), static_cast<u8>(value & 0x00FF));
m_S.Decrement();
}

inline void HuC6280::StackPush8(u8 value)
{
m_memory->Write(0x2100 | m_S.GetValue(), value);
m_memory->Write(STACK_ADDR | m_S.GetValue(), value);
m_S.Decrement();
}

inline u16 HuC6280::StackPop16()
{
m_S.Increment();
u8 l = m_memory->Read(0x2100 | m_S.GetValue());
u8 l = m_memory->Read(STACK_ADDR | m_S.GetValue());
m_S.Increment();
u8 h = m_memory->Read(0x2100 | m_S.GetValue());
u8 h = m_memory->Read(STACK_ADDR | m_S.GetValue());
return Address16(h , l);
}

inline u8 HuC6280::StackPop8()
{
m_S.Increment();
return m_memory->Read(0x2100 | m_S.GetValue());
return m_memory->Read(STACK_ADDR | m_S.GetValue());
}

inline u8 HuC6280::ImmediateAddressing()
Expand All @@ -244,12 +244,12 @@ inline u8 HuC6280::ImmediateAddressing()

inline u16 HuC6280::ZeroPageAddressing()
{
return 0x2000 | Fetch8();
return ZERO_PAGE_ADDR | Fetch8();
}

inline u16 HuC6280::ZeroPageAddressing(EightBitRegister* reg)
{
return 0x2000 | ((Fetch8() + reg->GetValue()) & 0xFF);
return ZERO_PAGE_ADDR | ((Fetch8() + reg->GetValue()) & 0xFF);
}

inline u16 HuC6280::ZeroPageRelativeAddressing()
Expand Down

0 comments on commit 21d3041

Please sign in to comment.