
/*
	GIER simulator - RC2000 test tape

	(C) Copyright 2001-2012 by Mogens Kjaer


   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include "GIER.h"

extern unsigned char set_parity(unsigned char);

static void punch(unsigned char c)
{
  printf("%c", c);
}

int main(int argc, char **argv)
{
  int nmissing,nduplicates,interval,i,j;
  if(argc<3)
  {
    fprintf(stderr, "Usage: rc2000test nmissing nduplicates\n");
    exit(-1);
  }

  nmissing = atoi(argv[1]);
  nduplicates = atoi(argv[2]);
  interval = 127/(nmissing+nduplicates+1);

  for(i=0; i<=127; i++)
  {
    if((i%interval)==0 && nmissing>0 && i>0)
    {
      nmissing--;
    }
    else
    {
      punch(set_parity(i));
      if((i%interval)==0 && nduplicates>0 && i>0)
      {
	punch(set_parity(i));
	nduplicates--;
      }
    }
    for(j=0;j<i;j++) punch(0);
  }

}
