From 21d30412327d8dfe81a5c05caeb4f1db0ac6fe2d Mon Sep 17 00:00:00 2001 From: Ignacio Sanchez Gines <863613+drhelius@users.noreply.github.com> Date: Sat, 3 Aug 2024 23:36:55 +0200 Subject: [PATCH] Structure for tests --- platforms/shared/desktop/gui_debug_huc6280.cpp | 2 +- src/huc6280.h | 8 ++++++++ src/huc6280_inline.h | 18 +++++++++--------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/platforms/shared/desktop/gui_debug_huc6280.cpp b/platforms/shared/desktop/gui_debug_huc6280.cpp index 84fbceb..8fe846e 100644 --- a/platforms/shared/desktop/gui_debug_huc6280.cpp +++ b/platforms/shared/desktop/gui_debug_huc6280.cpp @@ -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(); diff --git a/src/huc6280.h b/src/huc6280.h index 1bb6c31..9ed6ea1 100644 --- a/src/huc6280.h +++ b/src/huc6280.h @@ -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; diff --git a/src/huc6280_inline.h b/src/huc6280_inline.h index 31e72c8..7c0e463 100644 --- a/src/huc6280_inline.h +++ b/src/huc6280_inline.h @@ -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) @@ -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(value >> 8)); + m_memory->Write(STACK_ADDR | m_S.GetValue(), static_cast(value >> 8)); m_S.Decrement(); - m_memory->Write(0x2100 | m_S.GetValue(), static_cast(value & 0x00FF)); + m_memory->Write(STACK_ADDR | m_S.GetValue(), static_cast(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() @@ -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()