Skip to content

Commit

Permalink
via: replace asserts with unhandled logging
Browse files Browse the repository at this point in the history
Allows roms like veccy_pong_v092 to work, despite using unimplemented
via flags.
  • Loading branch information
amaiorano committed Dec 22, 2023
1 parent b68337f commit 430c217
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions libs/emulator/src/Via.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,16 @@ void Via::Write(uint16_t address, uint8_t value) {
//@TODO: validate if this is the correct behaviour

// Assert if trying to clear an interrupt we don't handle yet
#define ASSERT_UNHANDLED(flag) \
ASSERT_MSG(!TestBits(value, flag), "Write to clear interrupt not supported yet: %s", #flag)
ASSERT_UNHANDLED(InterruptFlag::CA2);
ASSERT_UNHANDLED(InterruptFlag::CB1);
ASSERT_UNHANDLED(InterruptFlag::CB2);
#undef ASSERT_UNHANDLED
#define LOG_UNHANDLED(flag) \
if (TestBits(value, flag)) \
do { \
ErrorHandler::Unsupported("Write to clear interrupt not supported yet: %s\n", #flag); \
} while (false)

LOG_UNHANDLED(InterruptFlag::CA2);
LOG_UNHANDLED(InterruptFlag::CB1);
LOG_UNHANDLED(InterruptFlag::CB2);
#undef LOG_UNHANDLED

if (TestBits(value, InterruptFlag::CA1))
m_ca1InterruptFlag = false;
Expand All @@ -484,13 +488,16 @@ void Via::Write(uint16_t address, uint8_t value) {
SetBits(m_interruptEnable, (value & 0x7F), TestBits(value, BITS(7)));

// Assert if trying to enable interrupt we don't handle yet
#define ASSERT_UNHANDLED(flag) \
ASSERT_MSG(!TestBits(m_interruptEnable, flag), \
"Write to enable interrupt not supported yet: %s", #flag)
ASSERT_UNHANDLED(InterruptFlag::CA2);
ASSERT_UNHANDLED(InterruptFlag::CB1);
ASSERT_UNHANDLED(InterruptFlag::CB2);
#undef ASSERT_UNHANDLED
#define LOG_UNHANDLED(flag) \
if (TestBits(m_interruptEnable, flag)) \
do { \
ErrorHandler::Unsupported("Write to enable interrupt not supported yet: %s\n", #flag); \
} while (false)

LOG_UNHANDLED(InterruptFlag::CA2);
LOG_UNHANDLED(InterruptFlag::CB1);
LOG_UNHANDLED(InterruptFlag::CB2);
#undef LOG_UNHANDLED

} break;

Expand Down

0 comments on commit 430c217

Please sign in to comment.