From 097951edb41f0c75feec9ea12a071d920b7bc9ac Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Tue, 10 Jan 2023 23:08:58 +0800 Subject: [PATCH] feat: `NOT_COLUMN_` macro in core --- src/core_demo.cc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/core_demo.cc b/src/core_demo.cc index 4236f12..1887f99 100644 --- a/src/core_demo.cc +++ b/src/core_demo.cc @@ -18,6 +18,13 @@ cache_t cache[16]; #define TOP_LIMIT(ADDR) (addr >= ADDR * 3) #define BOTTOM_LIMIT(ADDR) (addr <= ADDR * 3) +#define NOT_COLUMN_0 ((addr & 3) != 0) +#define NOT_COLUMN_2 ((addr & 3) != 2) +#define NOT_COLUMN_3 ((addr & 3) != 1) + +//#define AT_COLUMN_0 ((addr & 3) == 0) +//#define AT_COLUMN_3 ((addr & 3) == 1) + #define release_1x1(_filter) { \ cache_t next_case = { \ .code = code & ~(F_1x1 << addr) | (C_1x1 << next_addr), \ @@ -93,10 +100,10 @@ void move_1x1(uint64_t code, int addr) { if (ALLOW_DOWN && BOTTOM_LIMIT(15) && !(code >> MOVE_DOWN & F_1x1)) { release_1x1(DOWN) // 1x1 block move down } - if (ALLOW_LEFT && (addr & 3) != 0 && !(code >> MOVE_LEFT & F_1x1)) { + if (ALLOW_LEFT && NOT_COLUMN_0 && !(code >> MOVE_LEFT & F_1x1)) { release_1x1(LEFT) // 1x1 block move left } - if (ALLOW_RIGHT && (addr & 3) != 1 && !(code >> MOVE_RIGHT & F_1x1)) { + if (ALLOW_RIGHT && NOT_COLUMN_3 && !(code >> MOVE_RIGHT & F_1x1)) { release_1x1(RIGHT) // 1x1 block move right } } @@ -121,10 +128,10 @@ void move_1x2(uint64_t code, int addr) { if (ALLOW_DOWN && BOTTOM_LIMIT(14) && !(code >> MOVE_DOWN & F_1x2)) { release_1x2(DOWN) // 1x2 block move down } - if (ALLOW_LEFT && (addr & 3) != 0 && !(code >> MOVE_LEFT & F_1x1)) { + if (ALLOW_LEFT && NOT_COLUMN_0 && !(code >> MOVE_LEFT & F_1x1)) { release_1x2(LEFT) // 1x2 block move left } - if (ALLOW_RIGHT && (addr & 3) != 2 && !(code >> MOVE_RIGHT & F_1x1_R)) { + if (ALLOW_RIGHT && NOT_COLUMN_2 && !(code >> MOVE_RIGHT & F_1x1_R)) { release_1x2(RIGHT) // 1x2 block move right } } @@ -149,10 +156,10 @@ void move_2x1(uint64_t code, int addr) { if (ALLOW_DOWN && BOTTOM_LIMIT(11) && !(code >> MOVE_DOWN & F_1x1_D)) { release_2x1(DOWN) // 2x1 block move down } - if (ALLOW_LEFT && (addr & 0x3) != 0 && !(code >> MOVE_LEFT & F_2x1)) { + if (ALLOW_LEFT && NOT_COLUMN_0 && !(code >> MOVE_LEFT & F_2x1)) { release_2x1(LEFT) // 2x1 block move left } - if (ALLOW_RIGHT && (addr & 0x3) != 1 && !(code >> MOVE_RIGHT & F_2x1)) { + if (ALLOW_RIGHT && NOT_COLUMN_3 && !(code >> MOVE_RIGHT & F_2x1)) { release_2x1(RIGHT) // 2x1 block move right } } @@ -177,10 +184,10 @@ void move_2x2(uint64_t code, int addr) { if (ALLOW_DOWN && BOTTOM_LIMIT(10) && !(code >> MOVE_DOWN & F_1x2_D)) { release_2x2(DOWN) // 2x2 block move down } - if (ALLOW_LEFT && (addr & 3) != 0 && !(code >> MOVE_LEFT & F_2x1)) { + if (ALLOW_LEFT && NOT_COLUMN_0 && !(code >> MOVE_LEFT & F_2x1)) { release_2x2(LEFT) // 2x2 block move left } - if (ALLOW_RIGHT && (addr & 3) != 2 && !(code >> MOVE_RIGHT & F_2x1_R)) { + if (ALLOW_RIGHT && NOT_COLUMN_2 && !(code >> MOVE_RIGHT & F_2x1_R)) { release_2x2(RIGHT) // 2x2 block move right } }