#define EXTERN  extern
#include        "define.h"

pulsepair()   
   {
   register int          gatecount;
   register float       *p,*g,*iqptr,Iold,Qold,I,Q,ioffset,qoffset;
   
   g = LAGBUF;
   p = ABPRAM;
  
   iqptr = IQPTR;

   /* do pulse pair on an entire hit */
   for(gatecount=0; gatecount<*Gates; gatecount++)
      {
      /* read in an I */
      Iold = *g;
      *g++ = I = *iqptr++;
       
      /* read in a Q */
      Qold = *g;
      *g++ = Q = *iqptr++;

      /* do a single pulse pair (write over last accumulation) */
      *p++ +=  Iold * I    + Qold * Q;        /* do a */
      *p++ +=  Iold * Q    - Qold * I;        /* do b */
      *p++ +=  I    * I    + Q    * Q;        /* do p */
      }

   if(++hitcount >= *Hits)
      {
      hitcount = 0;             /* reset dwell counter */
   
      /* put data in DPR */
      g = bufpointer[1 - (*Flag & 1)];
      p = ABPRAM;
      for(gatecount=0; gatecount<*Gates*3; gatecount++)
         {
         *g++ = *p;
         *p++ = 0.0;
         }
   
      (*Flag)++;                /* swap buffer indicator */
      
      if(*Flag & 1) LEDSET(LED5);  else     LEDCLR(LED5);

      *PCINT = ASSERT;     /* generate a little low going pulse */
      *PCINT = DEASSERT;
      }
   }   
