~l3kn/quad

22b359ddfc2e60345a989b2a843319758106c62a — Leon Rische 6 months ago 525a8b3
Remove patterns, add quad header
2 files changed, 27 insertions(+), 176 deletions(-)

D patterns.h
A quad.h
D patterns.h => patterns.h +0 -176
@@ 1,176 0,0 @@
#define PATTERN(r0, r1, r2, r3, r4, r5, r6, r7)     \
  r0 + (r1 << 8) + (r2 << 16) + (r3 << 24) +        \
  (r4 << 32) + (r5 << 40) + (r6 << 48) + (r7 << 56)

typedef unsigned long long Pattern;

const Pattern BLACK =
  PATTERN(0b00000000UL,
          0b00000000UL,
          0b00000000UL,
          0b00000000UL,
          0b00000000UL,
          0b00000000UL,
          0b00000000UL,
          0b00000000UL);

const Pattern WHITE =
  PATTERN(0b11111111UL,
          0b11111111UL,
          0b11111111UL,
          0b11111111UL,
          0b11111111UL,
          0b11111111UL,
          0b11111111UL,
          0b11111111UL);

const Pattern GRAY1 =
  PATTERN(0b00010001UL,
          0b00000000UL,
          0b00000000UL,
          0b00000000UL,
          0b00010001UL,
          0b00000000UL,
          0b00000000UL,
          0b00000000UL);

const Pattern GRAY2 =
  PATTERN(0b01010101UL,
          0b00000000UL,
          0b01010101UL,
          0b00000000UL,
          0b01010101UL,
          0b00000000UL,
          0b01010101UL,
          0b00000000UL);

const Pattern HOR1 =
  PATTERN(0b00000001UL,
          0b00000001UL,
          0b00000001UL,
          0b00000001UL,
          0b00000001UL,
          0b00000001UL,
          0b00000001UL,
          0b00000001UL);

const Pattern VER1 =
  PATTERN(0b00000000UL,
          0b00000000UL,
          0b00000000UL,
          0b00000000UL,
          0b00000000UL,
          0b00000000UL,
          0b00000000UL,
          0b11111111UL);

const Pattern HOR2 =
  PATTERN(0b00001111UL,
          0b00001111UL,
          0b00001111UL,
          0b00001111UL,
          0b00001111UL,
          0b00001111UL,
          0b00001111UL,
          0b00001111UL);

const Pattern VER2 =
  PATTERN(0b00000000UL,
          0b00000000UL,
          0b00000000UL,
          0b00000000UL,
          0b11111111UL,
          0b11111111UL,
          0b11111111UL,
          0b11111111UL);

const Pattern DIAG1 =
  PATTERN(0b00000001UL,
          0b00000010UL,
          0b00000100UL,
          0b00001000UL,
          0b00010000UL,
          0b00100000UL,
          0b01000000UL,
          0b10000000UL);

const Pattern ADIAG1 =
  PATTERN(0b10000000UL,
          0b01000000UL,
          0b00100000UL,
          0b00010000UL,
          0b00001000UL,
          0b00000100UL,
          0b00000010UL,
          0b00000001UL);

const Pattern DIAG2 =
  PATTERN(0b00000001UL,
          0b00000001UL,
          0b00000001UL,
          0b00000001UL,
          0b00000001UL,
          0b00000001UL,
          0b00000001UL,
          0b11111111UL);

const Pattern ADIAG2 =
  PATTERN(0b00000000UL,
          0b00000000UL,
          0b00000000UL,
          0b00001000UL,
          0b00010100UL,
          0b00100010UL,
          0b01000001UL,
          0b10000000UL);

const Pattern patterns[40] = {
  0b0000000000000000000000000000000000000000000000000000000000000000UL,
  0b0000000100000000000000000000000000010000000000000000000000000000UL,
  0b0001000100000000010001000000000000010001000000000100010000000000UL,
  0b0001000100010001010001000100010000010001000100010100010001000100UL,
  0b0001000101010101010001000101010100010001010101010100010001010101UL,
  0b0011001101010101110011000101010100110011010101011100110001010101UL,
  0b0111011101010101110111010101010101110111010101011101110101010101UL,
  0b0111011111011101110111010111011101110111110111011101110101110111UL,
  0b1111111111011101111111110111011111111111110111011111111101110111UL,
  0b1111111111011101111111111111111111111111110111011111111111111111UL,
  0b0000000100001000010000000000010010000000000100000000001000100000UL,
  0b1111111111111111111111111111111111111111111111111111111111111111UL,
  0b0001000101000100000100010100010000010001010001000001000101000100UL,
  0b1000100001000100001000100001000110001000010001000010001000010001UL,
  0b0010001100000001001100000001011011000010010000000000110001100100UL,
  0b1000110100001100110000001101100000011011000000110011000010110001UL,
  0b0101010100000000010101010000000001010101000000000101010100000000UL,
  0b0001000101000100101010100100010000010001010001001010101001000100UL,
  0b0001000110101010010001001010101000010001101010100100010010101010UL,
  0b1110111010111011111011101011101111101110101110111110111010111011UL,
  0b0000000100000000000000000000000000000000000000000000000000000000UL,
  0b0101010110101010010101011010101001010101101010100101010110101010UL,
  0b1100000000100001000100100000110000110000010000001000000010000000UL,
  0b0100000100100010100111000010001001000001100000001000000010000000UL,
  0b0001000100101000010001001000001000010001100000100100010000101000UL,
  0b0000000100000001100000100111110000010000000100000010100011000111UL,
  0b0100010000100000001100010010111001000100111010000001100100001000UL,
  0b0111110100000001000100010001000011010111000100000001000100000001UL,
  0b1010010000010011010011001001000100100110001001000011001001001001UL,
  0b0100010100111001100000100111110101010100100100110010100011010111UL,
  0b0000001000000101000000000000000000100000010100000000000000000000UL,
  0b0000000100000010000001000000000001000000001000000001000000000000UL,
  0b0101010100000000000000010000000000010001000000000000000100000000UL,
  0b1111111100000001000000010000000100000001000000010000000100000001UL,
  0b0001000000111000010001001000001100000001100000000100000000100000UL,
  0b1111111100000001000000010000000111111111000100000001000000010000UL,
  0b0001111100101110010001001110001011110001111010000100010010001110UL,
  0b1111110100000000111111011111110100001101000011010000110100001101UL,
  0b1111111111111110011111011011101001000101100000100000000100000000UL,
  0b0101111110101111010111111010111100000101000010100000010100001010UL
};

/* Pattern patterns[] = { */
/*   BLACK, GRAY1, GRAY2, WHITE, */
/*   HOR1, VER1, HOR2, VER2, */
/*   DIAG1, ADIAG1, DIAG2, ADIAG2 */
/* }; */

/* const Pattern patterns[] = HYPERCARD; */

A quad.h => quad.h +27 -0
@@ 0,0 1,27 @@
typedef bool Pattern;
const Pattern BLACK = false;
const Pattern WHITE = true;
Pattern patterns[] = { BLACK, WHITE };

int colors[2] = { COLOR_BLACK, COLOR_WHITE };

void setColor(SDL_Renderer* renderer, int color) {
  int r = color >> 16;
  int g = (color >> 8) & 255;
  int b = color & 255;
  SDL_SetRenderDrawColor(renderer, r, g, b, SDL_ALPHA_OPAQUE);
}

typedef enum {
  RULE, PATTERN,
} nodeType;

typedef struct node {
  nodeType type;
  int index;
} Node;

typedef struct rule {
  Node quads[4];
  Node fallback;
} Rule;