maketbl.c 2.25 KB
#include<stdio.h>

int sectorsize[9]=
{
  232,  216,  208,  192,  176,  160,  144,  128,  112
};

int zonesize0[9]=
{
  134,  146,  137,  137,  137,  137,  137,  102,  0
};

int zonesize1[9]=
{
    0,  146,  146,  137,  137,  137,  137,  137,  102
};

int main()
{
  int	i;
  int	type;
  int	zone;
  int	lba;
  
  printf("/*\n");
  printf(" * Do not edit this file. This file is automatically generated by maketable.c\n");
  printf(" */\n");
  
  printf("#include <stdio.h>\n\n");
  printf("int tab[][4292] = \n");
  printf("{\n");
  
  for(type = 0; type < 6; type++)
  {
    printf("\t{");
  
    lba = 0;
    
    for(zone = 0; zone <= type + 2; zone++)
    {
      printf("\n");
      for(i = 0; i < zonesize0[zone]*2; i++)
      {
	printf("\t%d,", sectorsize[zone]*85);
	lba += sectorsize[zone]*85;
	if( i % 10 == 9)
	  printf("\n");
      }
    }
  
    for(zone = type + 2; zone >= 1; zone--)
    {
      printf("\n");
      for(i = 0; i < zonesize1[zone]*2; i++)
      {
	printf("\t%d,", sectorsize[zone]*85);
	lba += sectorsize[zone]*85;
	if( i % 10 == 9)
	  printf("\n");
      }
    }
    
    for(zone = type + 3; zone <= 7; zone++)
    {
      printf("\n");
      for(i = 0; i < zonesize0[zone]*2; i++)
      {
	printf("\t%d,", sectorsize[zone]*85);
	lba += sectorsize[zone]*85;
	if( i % 10 == 9)
	  printf("\n");
      }
    }
    
    for(zone = 8; zone >= type + 3; zone--)
    {
      printf("\n");
      for(i = 0; i < zonesize1[zone]*2; i++)
      {
	printf("\t%d,", sectorsize[zone]*85);
	lba += sectorsize[zone]*85;
	if( i % 10 == 9)
	  printf("\n");
      }
    }
    fprintf(stderr, "total bytes = %d\n", lba);
    
    printf("},\n");
  }

  /*
   * type 6 is a little bit special
   */
  printf("\t{");
  lba = 0;
  for(zone = 0; zone <= 7; zone++)
  {
    printf("\n");
    for(i = 0; i < zonesize0[zone]*2; i++)
    {
      printf("\t%d,", sectorsize[zone]*85);
      lba += sectorsize[zone]*85;
      if( i % 10 == 9)
	printf("\n");
    }
  }
  
  for(zone = 8; zone >= 1; zone--)
  {
    printf("\n");
    for(i = 0; i < zonesize1[zone]*2; i++)
    {
      printf("\t%d,", sectorsize[zone]*85);
      lba += sectorsize[zone]*85;
      if( i % 10 == 9)
	printf("\n");
    }
  }
  fprintf(stderr, "total bytes = %d\n", lba);
  
  printf("},\n");

  printf("};\n");

  exit(0);

}