RMW simplification

This commit is contained in:
Adrian Conlon 2024-03-07 08:31:28 +00:00
parent 9a0cf0cca8
commit b582412231
1 changed files with 9 additions and 8 deletions

View File

@ -176,20 +176,21 @@ namespace EightBit {
#define FIXUP_RMW(ADDRESSING, OPERATION) \
{ \
fixup(ADDRESSING()); \
const auto result = OPERATION(memoryRead()); \
memoryModifyWrite(result); \
_RMW(OPERATION); \
}
#define RMW(ADDRESSING, OPERATION) \
{ \
const auto result = OPERATION(memoryRead(ADDRESSING())); \
memoryModifyWrite(result); \
BUS().ADDRESS() = ADDRESSING(); \
_RMW(OPERATION); \
}
void memoryModifyWrite(const uint8_t data) noexcept {
// The read will have already taken place...
memoryWrite();
memoryWrite(data);
#define _RMW(OPERATION) \
{ \
const auto data = memoryRead(); \
const auto result = OPERATION(data); \
memoryWrite(); \
memoryWrite(result); \
}
void maybe_fixup(register16_t address, uint8_t unfixed_page, bool always_fixup = false) noexcept {