
A CrossStar file has one of these objects at the start - it is 264 bytes long


typedef struct
{
 char name[24];         A char is one byte
 char  mark[8];
 char copy[64];
 char stuff[152];
 int  draftfill;
 int  saveupper;        An int is 4 bytes
 int  x;                <-------  Dimensions of grid
 int  y;                <-------
} gheader;




int loadgridsub(char * filename)
{

 fp=ropen(filename,"rb");
 if(fp)
 {
  rread(&gh,sizeof(gheader),1,fp);               Load the header

  mark100=(strcmp(gh.mark,"1.01")<0);

  maxx=gh.x;                                     Get dimensions from header
  maxy=gh.y;
  saveupper=gh.saveupper;
  draftfill=gh.draftfill;

  readfhdc(fp);                                  Read any dictionaries (see below)

  for(x=0;x<maxx;x++)                            Read in x columns of text i.e. what
   rread(griddata[x],1,maxy,fp);                 goes in the grid - one byte per square

  for(x=0;x<maxx;x++)                            Read in x columns of state e.g. is
   rread(gridstate[x],1,maxy,fp);                the sqaure filled or what?
                                                 one byte per square

  rclose(fp);
 }
}



Reading dictionaries



int readfhdc(FILE * fp)
{
 char name[12];
 int  dcn;

 nodc=0;

 while(1)
 {
  rread(name,12,1,fp);
  if(rerror(fp)) return(1);
  if(!strlen(name)) break;
  dcn=finddc(name);
  if(dcn>-1) dcadd(dcn);
 }

 dccleanup();

 return(0);
}


Each dictionary name is 12 bytes long. Names are C style zero terminated.
A name with a length of zero terminates the list of names.
(a zero length name has a zero value byte in the first position)


These are the values of the state for a square



#define CHARST  0                       Text
#define HILITE  1                       Hilighted
#define BLOCK   2                       Blank

#define BLOCKX  0x4                     Bar on X side
#define BLOCKY  0x8                     Bar on Y side



