From b3e617f1e5698362ce8a04687ededd19c418c993 Mon Sep 17 00:00:00 2001 From: Andrea Date: Fri, 17 Jun 2022 22:27:52 +0200 Subject: [PATCH] Uthernet II: the real hardware only decodes A0 and A1, so we introduce a 0x03 mask. (PR #1115) Fixes #1113 --- source/Uthernet2.cpp | 2 +- source/W5100.h | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/Uthernet2.cpp b/source/Uthernet2.cpp index 7399beb8..dba2c61b 100644 --- a/source/Uthernet2.cpp +++ b/source/Uthernet2.cpp @@ -1407,7 +1407,7 @@ BYTE Uthernet2::IO_C0(WORD programcounter, WORD address, BYTE write, BYTE value, const uint16_t oldAddress = myDataAddress; #endif - const uint8_t loc = address & 0x0F; + const uint8_t loc = address & U2_C0X_MASK; if (write) { diff --git a/source/W5100.h b/source/W5100.h index 169fec93..7d8cec8d 100644 --- a/source/W5100.h +++ b/source/W5100.h @@ -2,10 +2,13 @@ // Uthernet II registers -#define U2_C0X_MODE_REGISTER 0x04 -#define U2_C0X_ADDRESS_HIGH 0x05 -#define U2_C0X_ADDRESS_LOW 0x06 -#define U2_C0X_DATA_PORT 0x07 +// only A0 and A1 are decoded +#define U2_C0X_MASK 0x03 + +#define U2_C0X_MODE_REGISTER (0x04 & U2_C0X_MASK) +#define U2_C0X_ADDRESS_HIGH (0x05 & U2_C0X_MASK) +#define U2_C0X_ADDRESS_LOW (0x06 & U2_C0X_MASK) +#define U2_C0X_DATA_PORT (0x07 & U2_C0X_MASK) // W5100 registers and values