#include <stdio.h>
#include "old.h"

save()
{
	int i;
	FILE *fp;

	if((fp=fopen("chess.out", "wu")) == NULL) {
		printf("cannot create file\n");
		return;
	}
	fput(clktim, 4, fp);
	fput(&bookp, 2, fp);
	fput(&moveno, 2, fp);
	fput(&game, 2, fp);
	i = amp-ambuf;
	fput(&i, 2, fp);
	fput(&mantom, 2, fp);
	fput(&value, 2, fp);
	fput(&ivalue, 2, fp);
	fput(&depth, 2, fp);
	fput(&flag, 2, fp);
	fput(&eppos, 2, fp);
	fput(&bkpos, 2, fp);
	fput(&wkpos, 2, fp);
	fput(board, 128, fp);
	fput(ambuf, i*2, fp);
	fclose(fp);
}

restore()
{
	int i;
	FILE *fp;

	if((fp=fopen("chess.out", "ru")) == NULL) {
		printf("cannot open file\n");
		return;
	}
	fget(clktim, 4, fp);
	fget(&bookp, 2, fp);
	fget(&moveno, 2, fp);
	fget(&game, 2, fp);
	fget(&i, 2, fp);
	amp = ambuf+i;
	fget(&mantom, 2, fp);
	fget(&value, 2, fp);
	fget(&ivalue, 2, fp);
	fget(&depth, 2, fp);
	fget(&flag, 2, fp);
	fget(&eppos, 2, fp);
	fget(&bkpos, 2, fp);
	fget(&wkpos, 2, fp);
	fget(board, 128, fp);
	fget(ambuf, i*2, fp);
	fclose(fp);
}
