## 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 & 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 */

/* row 1: W(A,N), W(B, N), X(A, N), X(B, N) */
printf("|");
printf("|\n");

/* row 2: W(A,S), W(B, S), X(A, S), X(B, N) */
printf("|");
printf("|\n");

/* row 3: W(C,N), W(D, N), X(C, N), X(D, N) */
printf("|");
printf("|\n");

/* row 4: W(C,S), W(D, S), X(C, S), X(D, S) */
printf("|");
printf("|\n");

/* print y + z squares */

/* row 5: Y(A,N), Y(B, N), Z(A, N), Z(B, N) */
printf("|");
printf("|\n");

/* row 6: Y(A,S), Y(B, S), Z(A, S), Z(B, N) */
printf("|");
printf("|\n");

/* row 7: Y(C,N), Y(D, N), Z(C, N), Z(D, N) */
printf("|");
printf("|\n");

/* row 8: Y(C,S), Y(D, S), Z(C, S), Z(D, S) */
printf("|");