diff options
author | RSDuck <rsduck@users.noreply.github.com> | 2021-01-09 22:06:15 +0100 |
---|---|---|
committer | RSDuck <rsduck@users.noreply.github.com> | 2021-01-09 22:06:15 +0100 |
commit | 6b306e18a563b0118012a0e601f7be1446bf4e83 (patch) | |
tree | 7941c2c36867de39a280e4cf9104e4905d38d455 | |
parent | c4753723722790715aa799160041041cb37b6992 (diff) |
handle edge cases properly
-rw-r--r-- | src/Wifi.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/Wifi.cpp b/src/Wifi.cpp index e00f72b..6792bc8 100644 --- a/src/Wifi.cpp +++ b/src/Wifi.cpp @@ -793,13 +793,12 @@ bool ProcessTX(TXSlot* slot, int num) inline void IncrementRXAddr(u16& addr, u16 inc = 2) { - addr += inc; - addr &= 0x1FFE; - if (addr >= (IOPORT(W_RXBufEnd) & 0x1FFE)) + for (u32 i = 0; i < inc; i += 2) { - addr -= (IOPORT(W_RXBufEnd) & 0x1FFE); - addr += (IOPORT(W_RXBufBegin) & 0x1FFE); + addr += 2; addr &= 0x1FFE; + if (addr == (IOPORT(W_RXBufEnd) & 0x1FFE)) + addr = (IOPORT(W_RXBufBegin) & 0x1FFE); } } |