   // Gun's XY coordinate will be read within vsync_callback ()

   // Only when vcnt is less than 2 and gun is used
   if ((vcnt < PADS_NUM) & (pad_kind[vcnt][0] == TYPE_GUN))
   {
      padN = vcnt;
      // if the value is taken...
      if (gunstate[padN][1])
      {
         // Based on my experience, I let certain values
         for (i = 3; i < gunstate[padN][1]; i++)
         {
            x0 = ((gunstate[padN][5 + (i + 0) * 4] << 0x08) |
                  (gunstate[padN][4 + (i + 0) * 4]));
            x1 = ((gunstate[padN][5 + (i + 1) * 4] << 0x08) |
                  (gunstate[padN][4 + (i + 1) * 4]));
            x2 = ((gunstate[padN][5 + (i + 2) * 4] << 0x08) |
                  (gunstate[padN][4 + (i + 2) * 4]));
            d_count = (unsigned short)(abs (x0 - x1) + abs (x1 - x2));
            if (d_count < 7)
               break;
         }

         // At this point, if i is less than the value got, use this value.
         // Otherwise 0 will be used
         if (i >= gunstate[padN][1])
            i = 0;
         pre_h_count = ((gunstate[padN][5 + i * 4] << 0x08) |
                        (gunstate[padN][4 + i * 4]));

         // Adjust the values
         gun_tmpX[padN] = pre_h_count / 5;
         gun_tmpY[padN] = gunstate[padN][2 + 0 * 4];
         gun_reload[padN] = OFF;

         // Average the value with the previous one
         gun_tmpX[padN] = (gun_tmpX[padN] + oldX[padN]) / 2;
         gun_tmpY[padN] = (gun_tmpY[padN] + oldY[padN]) / 2;
         oldX[padN] = gun_tmpX[padN];
         oldY[padN] = gun_tmpY[padN];
      }
      else
      {
         // If there's no value, then we need to reload
         gun_reload[padN] = ON;
      }
   }

   // 1st interrupt is for gun 1, 2nd for gun 2.  3rd & more is not used
   switch (vcnt)
   {
      case 0:  SelectGun (CHAN0, ON);
               SelectGun (CHAN1, OFF);
               break;
      case 1:  SelectGun (CHAN0, OFF);
               SelectGun (CHAN1, ON);
               break;
      default: break;
   }
