P8000/WEGA/contrib/cpm/cpm3/gensktab.c

42 lines
735 B
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* gensktab.c 1.4 83/05/13 */
#include <stdio.h>
#include "cpmio.h"
int skew;
int *skewtab;
/*
* Generate a skew factor table in skewtab accordine to the
* global parameters given by skew and sectrk.
* This routine must be called before any disk (or virtual disk)
* accesses are attempted.
*/
gen_sktab()
{
int *i, *j;
char *malloc();
if (( skewtab = (int *) malloc(sectrk*4)) == NULL) {
fprintf(stderr,
"can't allocate memory for skew sector table\n");
exit(1);
}
*skewtab = 1;
for (i=skewtab+1; i<skewtab+ sectrk; i++) {
*i = *(i-1) + skew;
if (*i > sectrk) {
*i -= sectrk;
L1:
for (j=skewtab; j<i; j++) {
if (*j == *i)  break;
}
if (j < i ) {
++*i;
goto L1;
}
}
}
}