/* O7plus71.c			 - Dated : 29 Feb '95 */
/* OBS 7 plus 7 ver 1            		      */					
/* *************************************************  */
/*              CY 7C276   POWER     OBSERVATION      */
/* *************************************************  */
						      
#include "gac.h"
#define asize 0x3fff  /*  14 bits */

main()
{	unsigned char data[asize],d1,d2, c0,c1 ;
	int i ;
	FILE *out,*outt;

   clrscr() ;	
   out = fopen("7plus7.bin","wb"); /* Obs 7 plus 7 ver 1 */
   outt = fopen("7plus7.txt","wt"); /* Text 7 plus 7 ver 1 */

   for(i=0;i<=asize;i++)
   {	d1 = i & 0x7f ;
	d2 = (i >> 7) &0x7f ;

	data[i] = d1 + d2 ; 
	printf("%2x +%2x = %2x\n",d2,d1,data[i] );  
	fwrite(&data[i],1,1,out);
	data[i] =0;                /* write PROM MSByte  */
	fwrite(&data[i],1,1,out);  /* as Zero            */
	fprintf(outt ,"%d\n",data[i]);

   }

/* Next two fwrite are used to write the CONTROL WORDS at 4000 Hex location  */
/* Control Word : x CS2 CS1 CS0   X X X X X   X X X X   1 X X OE   */ 
/* Control word 0x0080 programmes CS2,CS1,CS0, OE as active LOW    */
   c0 = 0x08 ; c1 = 0x00 ;
   fwrite(&c0,1,1,out);  /* write LS 8 control bits   */				
   fwrite(&c1,1,1,out);  /* write MS 8 control  bits  */		

   fclose(out) ;
   fclose(outt) ;

}
	 
	
