
#include <stdio.h>

#include "utils.h"

#define BOARD_SIZE 210

void printboard1(void)
{
  int i;

  for (i = 0; i < BOARD_SIZE; i ++)
  {
    printf("%03d ", i);
    
    if ((i + 1) % 15 == 0)
    {
      printf("\n");
    }
  }
}

void printboard2(void)
{
  int i, x, y;

  for (i = 0; i < BOARD_SIZE; i ++)
  {
    sqr2xy(i, &x, &y);
    
    if (x >= 0 && x <= 9 && y >= 0 && y <= 7)
    {
      printf("%03d ", i);
    }
    else
    {
      printf("... ");
    }
    
    if ((i + 1) % 15 == 0)
    {
      printf("\n");
    }
  }
}

void printboard3(void)
{
  int i, x, y;
  
  for (i = 0; i < BOARD_SIZE; i ++)
  {
    sqr2xy(i, &x, &y);
    
    if (x >= 0 && x <= 9 && y >= 0 && y <= 7)
    {
      printf("%c%c ", x + 'A', y + '1');
    }
    else
    {
      printf(".. ");
    }
    
    if ((i + 1) % 15 == 0)
    {
      printf("\n");
    }
  }
}

void printboard4(void)
{
  int x, y;

  for (y = 7; y >= 0; y --)
  {
    for (x = 0; x <= 9; x ++)
    {
      printf("BOARD[%3d], ", xy2sqr(x, y));
    }
    printf("\n");
  }
}

void printboard5(void)
{
  int x, y;

  for (y = 7; y >= 0; y --)
  {
    for (x = 0; x <= 9; x ++)
    {
      printf("const int %c%c = %3d; ", 'A' + x, '1' + y, xy2sqr(x, y));
    }
    printf("\n");
  }
}

void printboard6(void)
{
  int x, y;

  for (y = 9; y >= -5; y --)
  {
    for (x = -2; x <= 11; x ++)
    {
      printf("%03d ",  xy2sqr(x, y));
    }
    printf("\n");
  }
}

void printboard7(void)
{
  int x, y;

  for (y = 9; y >= -5; y --)
  {
    for (x = -2; x <= 11; x ++)
    {
      if (y >= 0 && y <= 7 && x >= 0 && x <= 9)
      {
        printf("%03d ",  xy2sqr(x, y));
      }
      else
      {
        printf("... ");
      }
    }
    printf("\n");
  }
}

void printboard8(void)
{
  int x, y;

  for (y = 9; y >= -5; y --)
  {
    for (x = -2; x <= 11; x ++)
    {
      if (y >= 0 && y <= 7 && x >= 0 && x <= 9)
      {
        printf("%c%c ", 'A' + x, '1' + y);
      }
      else
      {
        printf(".. ");
      }
    }
    printf("\n");
  }
}

int main(void)
{
  printf("\n");
  printboard1();
  
  printf("\n");
  printboard2();
  
  printf("\n");
  printboard3();
  
  printf("\n");
  printboard4();
  
  printf("\n");
  printboard5();
  
  printf("\n");
  printboard6();
  
  printf("\n");
  printboard7();
  
  printf("\n");
  printboard8();
  
  return 0;
}
