5. Print Routines

For debugging purposes mainly.

5.1. Print A Tile

<<funcdefs>>=
void kuf_print_tile(uint8_t tile);
<<funcs>>=
void kuf_print_tile(uint8_t tile)
{
    printf("%s", tile ? "#" : ".");
}

5.2. Print a Quad

<<funcdefs>>=
void kuf_print_quad(uint8_t quad);
<<funcs>>=
void kuf_print_quad(uint8_t quad)
{
    printf("+--+\n");
    printf("|");
    kuf_print_tile(quad & 1);
    kuf_print_tile((quad & 2) >> 1);
    printf("|\n|");
    kuf_print_tile((quad & 4) >> 2);
    kuf_print_tile((quad & 8) >> 3);
    printf("|\n");
    printf("+--+\n");
}

5.3. Print a Side

Meant to be used when printing squares

<<funcdefs>>=
void kuf_print_side(uint8_t side);
<<funcs>>=
void kuf_print_side(uint8_t side)
{
    kuf_print_tile(side & 1);
    kuf_print_tile(side & 2);
}

5.4. Print a Square

<<funcdefs>>=
void kuf_print_square(uint16_t square);
<<funcs>>=
void kuf_print_square(uint16_t square)
{
    printf("+----+\n");
    printf("|");
    kuf_print_side(kuf_quad_side_get(square & 0xf, KUF_NORTH));
    kuf_print_side(kuf_quad_side_get((square >> 4) & 0xf, KUF_NORTH));
    printf("|\n");

    printf("|");
    kuf_print_side(kuf_quad_side_get(square & 0xf, KUF_SOUTH));
    kuf_print_side(kuf_quad_side_get((square >> 4) & 0xf, KUF_SOUTH));
    printf("|\n");

    printf("|");
    kuf_print_side(kuf_quad_side_get((square >> 8) & 0xf, KUF_NORTH));
    kuf_print_side(kuf_quad_side_get((square >> 12) & 0xf, KUF_NORTH));
    printf("|\n");

    printf("|");
    kuf_print_side(kuf_quad_side_get((square >> 8) & 0xf, KUF_SOUTH));
    kuf_print_side(kuf_quad_side_get((square >> 12) & 0xf, KUF_SOUTH));
    printf("|\n");

    printf("+----+\n");
}

5.5. Print a Block

<<funcdefs>>=
void kuf_print_block(uint16_t w, uint16_t x, uint16_t y, uint16_t z);
<<funcs>>=
void kuf_print_block(uint16_t w, uint16_t x, uint16_t y, uint16_t z)
{
    uint8_t s_a[4];
    uint8_t s_b[4];
    printf("+--------+\n");
    /* print w + x squares */

    s_a[0] = kuf_square_quad_get(w, KUF_QUAD_A);
    s_a[1] = kuf_square_quad_get(w, KUF_QUAD_B);
    s_a[2] = kuf_square_quad_get(w, KUF_QUAD_C);
    s_a[3] = kuf_square_quad_get(w, KUF_QUAD_D);

    s_b[0] = kuf_square_quad_get(x, KUF_QUAD_A);
    s_b[1] = kuf_square_quad_get(x, KUF_QUAD_B);
    s_b[2] = kuf_square_quad_get(x, KUF_QUAD_C);
    s_b[3] = kuf_square_quad_get(x, KUF_QUAD_D);


    /* row 1: W(A,N), W(B, N), X(A, N), X(B, N) */
    printf("|");
    kuf_print_side(kuf_quad_side_get(s_a[0], KUF_NORTH));
    kuf_print_side(kuf_quad_side_get(s_a[1], KUF_NORTH));
    kuf_print_side(kuf_quad_side_get(s_b[0], KUF_NORTH));
    kuf_print_side(kuf_quad_side_get(s_b[1], KUF_NORTH));
    printf("|\n");

    /* row 2: W(A,S), W(B, S), X(A, S), X(B, N) */
    printf("|");
    kuf_print_side(kuf_quad_side_get(s_a[0], KUF_SOUTH));
    kuf_print_side(kuf_quad_side_get(s_a[1], KUF_SOUTH));
    kuf_print_side(kuf_quad_side_get(s_b[0], KUF_SOUTH));
    kuf_print_side(kuf_quad_side_get(s_b[1], KUF_SOUTH));
    printf("|\n");

    /* row 3: W(C,N), W(D, N), X(C, N), X(D, N) */
    printf("|");
    kuf_print_side(kuf_quad_side_get(s_a[2], KUF_NORTH));
    kuf_print_side(kuf_quad_side_get(s_a[3], KUF_NORTH));
    kuf_print_side(kuf_quad_side_get(s_b[2], KUF_NORTH));
    kuf_print_side(kuf_quad_side_get(s_b[3], KUF_NORTH));
    printf("|\n");

    /* row 4: W(C,S), W(D, S), X(C, S), X(D, S) */
    printf("|");
    kuf_print_side(kuf_quad_side_get(s_a[2], KUF_SOUTH));
    kuf_print_side(kuf_quad_side_get(s_a[3], KUF_SOUTH));
    kuf_print_side(kuf_quad_side_get(s_b[2], KUF_SOUTH));
    kuf_print_side(kuf_quad_side_get(s_b[3], KUF_SOUTH));
    printf("|\n");

    /* print y + z squares */

    s_a[0] = kuf_square_quad_get(y, KUF_QUAD_A);
    s_a[1] = kuf_square_quad_get(y, KUF_QUAD_B);
    s_a[2] = kuf_square_quad_get(y, KUF_QUAD_C);
    s_a[3] = kuf_square_quad_get(y, KUF_QUAD_D);

    s_b[0] = kuf_square_quad_get(z, KUF_QUAD_A);
    s_b[1] = kuf_square_quad_get(z, KUF_QUAD_B);
    s_b[2] = kuf_square_quad_get(z, KUF_QUAD_C);
    s_b[3] = kuf_square_quad_get(z, KUF_QUAD_D);

    /* row 5: Y(A,N), Y(B, N), Z(A, N), Z(B, N) */
    printf("|");
    kuf_print_side(kuf_quad_side_get(s_a[0], KUF_NORTH));
    kuf_print_side(kuf_quad_side_get(s_a[1], KUF_NORTH));
    kuf_print_side(kuf_quad_side_get(s_b[0], KUF_NORTH));
    kuf_print_side(kuf_quad_side_get(s_b[1], KUF_NORTH));
    printf("|\n");

    /* row 6: Y(A,S), Y(B, S), Z(A, S), Z(B, N) */
    printf("|");
    kuf_print_side(kuf_quad_side_get(s_a[0], KUF_SOUTH));
    kuf_print_side(kuf_quad_side_get(s_a[1], KUF_SOUTH));
    kuf_print_side(kuf_quad_side_get(s_b[0], KUF_SOUTH));
    kuf_print_side(kuf_quad_side_get(s_b[1], KUF_SOUTH));
    printf("|\n");

    /* row 7: Y(C,N), Y(D, N), Z(C, N), Z(D, N) */
    printf("|");
    kuf_print_side(kuf_quad_side_get(s_a[2], KUF_NORTH));
    kuf_print_side(kuf_quad_side_get(s_a[3], KUF_NORTH));
    kuf_print_side(kuf_quad_side_get(s_b[2], KUF_NORTH));
    kuf_print_side(kuf_quad_side_get(s_b[3], KUF_NORTH));
    printf("|\n");

    /* row 8: Y(C,S), Y(D, S), Z(C, S), Z(D, S) */
    printf("|");
    kuf_print_side(kuf_quad_side_get(s_a[2], KUF_SOUTH));
    kuf_print_side(kuf_quad_side_get(s_a[3], KUF_SOUTH));
    kuf_print_side(kuf_quad_side_get(s_b[2], KUF_SOUTH));
    kuf_print_side(kuf_quad_side_get(s_b[3], KUF_SOUTH));
    printf("|\n");

    printf("+--------+\n");
}



prev | home | next