Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "sys.h"
00025 #include <iostream>
00026 #include <iomanip>
00027 #include <cstdlib>
00028 #include <stdint.h>
00029
00030 typedef uint64_t mask_t;
00031
00032 void output(int from, int to, mask_t mask)
00033 {
00034 static int count = 0;
00035 if (count == 0)
00036 std::cout << " ";
00037 std::cout << " {CW_MASK_T_CONST(0x" << std::hex << std::setfill('0') << std::setw(16) << mask << std::dec << ")},";
00038 if (++count == 4)
00039 {
00040 std::cout << '\n';
00041 count = 0;
00042 }
00043 }
00044
00045 int main()
00046 {
00047 for (int from = 0; from < 64; ++from)
00048 {
00049 int from_col = from & 7;
00050 int from_row = from >> 3;
00051 for (int to = 0; to < 64; ++to)
00052 {
00053 if (from == to)
00054 {
00055 output(from, to, CW_MASK_T_CONST(0));
00056 continue;
00057 }
00058 int to_col = to & 7;
00059 int to_row = to >> 3;
00060 int col_diff = abs(from_col - to_col);
00061 int row_diff = abs(from_row - to_row);
00062 if (col_diff != 0 && row_diff != 0 && col_diff != row_diff)
00063 {
00064 output(from, to, CW_MASK_T_CONST(0));
00065 continue;
00066 }
00067 int dcol = (to_col - from_col);
00068 if (dcol)
00069 dcol /= col_diff;
00070 int drow = (to_row - from_row);
00071 if (drow)
00072 drow /= row_diff;
00073 mask_t mask = 0;
00074 int c = from_col;
00075 int r = from_row;
00076 do
00077 {
00078 mask |= CW_MASK_T_CONST(1) << ((r << 3) | c);
00079 c += dcol;
00080 r += drow;
00081 }
00082 while (c != to_col || r != to_row);
00083 output(from, to, mask);
00084 }
00085 }
00086 }