From 0a566eb58fb626e2413a31aceefaf6e8cb51a169 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 6 Aug 2017 06:59:01 +0200 Subject: [PATCH] Fix masking of the right-hand side. The `SCANBIT` macro was not using `row` and `col` properly: if either was anything else than a number (such as `col - 8`), the macro did not expand them correctly, preserving operator precedence. As such, the right-hand side SCANBITs were broken when used with masking, because the masking code uses `SCANBIT(row, col - 8)`, and the `(7 - col)` part would expand to `(7 - col - 8)` which is very different than `(7 - (col - 8))`. This patch addresses the issue. Signed-off-by: Gergely Nagy --- src/Kaleidoscope-Hardware-Model01.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kaleidoscope-Hardware-Model01.h b/src/Kaleidoscope-Hardware-Model01.h index 2e58fd23..e2fe552d 100644 --- a/src/Kaleidoscope-Hardware-Model01.h +++ b/src/Kaleidoscope-Hardware-Model01.h @@ -58,7 +58,7 @@ class Model01 { static uint32_t rightHandMask; }; -#define SCANBIT(row,col) ((uint32_t)1 << (row * 8 + (7 - col))) +#define SCANBIT(row,col) ((uint32_t)1 << ((row) * 8 + (7 - (col)))) #define R0C0 SCANBIT(0, 0) #define R0C1 SCANBIT(0, 1)