|
@ -43,6 +43,15 @@ bool RawCode::is_horizontal_mirror(const RawCode &raw_code) const { |
|
|
|
|
|
|
|
|
#include <iostream> |
|
|
#include <iostream> |
|
|
|
|
|
|
|
|
|
|
|
/// MASK_MIRROR_A | MASK_MIRROR_B
|
|
|
|
|
|
/// 111 000 000 000 | 000 111 000 000
|
|
|
|
|
|
/// 111 000 000 000 | 000 111 000 000
|
|
|
|
|
|
/// 111 000 000 000 | 000 111 000 000
|
|
|
|
|
|
/// 111 000 000 000 | 000 111 000 000
|
|
|
|
|
|
/// 111 000 000 000 | 000 111 000 000
|
|
|
|
|
|
constexpr uint64_t MASK_MIRROR_A = 0x0'007'007'007'007'007; |
|
|
|
|
|
constexpr uint64_t MASK_MIRROR_B = 0x0'038'038'038'038'038; |
|
|
|
|
|
|
|
|
void horizontal_fill(uint64_t &raw_code) { |
|
|
void horizontal_fill(uint64_t &raw_code) { |
|
|
for (int addr = 0; addr < 60; addr += 3) { // traverse every 3-bits
|
|
|
for (int addr = 0; addr < 60; addr += 3) { // traverse every 3-bits
|
|
|
switch ((raw_code >> addr) & 0b111) { |
|
|
switch ((raw_code >> addr) & 0b111) { |
|
@ -59,17 +68,13 @@ void horizontal_fill(uint64_t &raw_code) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void horizontal_clear(uint64_t &raw_code) { |
|
|
void horizontal_clear(uint64_t &raw_code) { |
|
|
|
|
|
|
|
|
for (int addr = 0; addr < 60; addr += 3) { // traverse every 3-bits
|
|
|
for (int addr = 0; addr < 60; addr += 3) { // traverse every 3-bits
|
|
|
|
|
|
|
|
|
switch ((raw_code >> addr) & 0b111) { |
|
|
switch ((raw_code >> addr) & 0b111) { |
|
|
case B_1x2: |
|
|
case B_1x2: |
|
|
case B_2x2: |
|
|
case B_2x2: |
|
|
raw_code |= (uint64_t)0b111 << (addr + 3); |
|
|
raw_code |= (uint64_t)0b111 << (addr + 3); // reset as original block
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint64_t RawCode::vertical_mirror(uint64_t raw_code) { |
|
|
uint64_t RawCode::vertical_mirror(uint64_t raw_code) { |
|
@ -80,19 +85,10 @@ uint64_t RawCode::vertical_mirror(uint64_t raw_code) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint64_t RawCode::horizontal_mirror(uint64_t raw_code) { |
|
|
uint64_t RawCode::horizontal_mirror(uint64_t raw_code) { |
|
|
|
|
|
|
|
|
// TODO: horizontal mirror convert
|
|
|
|
|
|
|
|
|
|
|
|
// fill -> mirror -> unfill
|
|
|
|
|
|
|
|
|
|
|
|
horizontal_fill(raw_code); |
|
|
horizontal_fill(raw_code); |
|
|
|
|
|
raw_code = ((raw_code >> 9) & MASK_MIRROR_A) | ((raw_code >> 3) & MASK_MIRROR_B) |
|
|
// flip raw code
|
|
|
| ((raw_code & MASK_MIRROR_B) << 3) | ((raw_code & MASK_MIRROR_A) << 9); // flip raw code
|
|
|
|
|
|
|
|
|
horizontal_clear(raw_code); |
|
|
horizontal_clear(raw_code); |
|
|
|
|
|
|
|
|
std::cout << RawCode::unsafe_create(raw_code) << std::endl; |
|
|
|
|
|
|
|
|
|
|
|
return raw_code; |
|
|
return raw_code; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -103,19 +99,8 @@ bool RawCode::vertical_mirror_check(uint64_t raw_code) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool RawCode::horizontal_mirror_check(uint64_t raw_code) { |
|
|
bool RawCode::horizontal_mirror_check(uint64_t raw_code) { |
|
|
/// MASK_A MASK_B
|
|
|
|
|
|
/// 111 000 000 000 | 000 111 000 000
|
|
|
|
|
|
/// 111 000 000 000 | 000 111 000 000
|
|
|
|
|
|
/// 111 000 000 000 | 000 111 000 000
|
|
|
|
|
|
/// 111 000 000 000 | 000 111 000 000
|
|
|
|
|
|
/// 111 000 000 000 | 000 111 000 000
|
|
|
|
|
|
constexpr uint64_t MASK_A = 0x0'007'007'007'007'007; |
|
|
|
|
|
constexpr uint64_t MASK_B = 0x0'038'038'038'038'038; |
|
|
|
|
|
|
|
|
|
|
|
horizontal_fill(raw_code); |
|
|
horizontal_fill(raw_code); |
|
|
return ((raw_code >> 9 ^ raw_code) & MASK_A) && ((raw_code >> 3 ^ raw_code) & MASK_B); |
|
|
return ((raw_code ^ (raw_code >> 9)) & MASK_MIRROR_A) |
|
|
|
|
|
&& ((raw_code ^ (raw_code >> 3)) & MASK_MIRROR_B); |
|
|
} |
|
|
} |
|
|