⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 virt.c

📁 epson公司的一个关于s1d13706的低层驱动程序
💻 C
📖 第 1 页 / 共 2 页
字号:
         exit(1);
         break;

      case ERR_NOT_ENOUGH_MEMORY:
         printf("ERROR: %s\n", szErrNotEnoughMem);
         exit(1);
         break;

      default:
         printf("ERROR: Could not initialize virtual display.\n");
         exit(1);
         break;
      }
}

/*-------------------------------------------------------------------------*/

void DisplayPanImage(DWORD width)
   {
   unsigned PhysicalWidth, PhysicalHeight, height;
   unsigned AvailableLines;
   unsigned x1, y1, x2, y2;
   unsigned dx, dy;
   unsigned step, StepCount;
   unsigned section;
   unsigned PixelsPerDword;
   DWORD white;

   seGetMainWinResolution(&PhysicalWidth, &PhysicalHeight);


   height = PhysicalHeight;

   if (ShowSubWindow)
      {
      seUseMainWinImageForSubWin();

      x1 = PhysicalWidth / 4;
      y1 = height / 4;
      x2 = ((3 * PhysicalWidth) / 4) - 1;
      y2 = (3 * height) / 4;

      seSetSubWinCoordinates(x1, y1, x2, y2);
      seSubWinDisplayEnable(TRUE);

      height /= 2;

      seSetSubWinAsActiveSurface();
      }

   InitializeVirtualDisplay(width, height);

   AvailableLines = DISPLAY_BUFFER_SIZE / (width * seGetBitsPerPixel() / 8);

   if (AvailableLines < height)
      height = AvailableLines;


   /*
   ** Get white value
   */
   switch (seGetBitsPerPixel())
      {
      default:  // 4 and 8 bpp
         white = WHITE_4BPP;
         break;

      case 16:
         white = WHITE_16BPP;
         break;
      }


   /*
   ** The top horizontal section consists of one pixel wide vertical lines.
   ** These lines are colored according to the following sequence:
   **
   ** black, brown, red, orange, yellow, green, blue, violet, gray, white
   **
   ** The second from the top horizontal section consists of ten pixel wide
   ** rectangles which follow the same coloring sequence as above.
   **
   ** The third from the top horizontal section consists of 100 pixel wide
   ** rectangles which again follow the same coloring sequence as above.
   */
   dx = 1;
   dy = height / 3;

   step = 0;
   StepCount = 0;

   PixelsPerDword = 32 / seGetBitsPerPixel();

   for (section = 0; section < 3; ++section)
      {
      y1 = dy * section;
      y2 = y1 + dy - 1;

      switch (section)
         {
         case 0:
            dx = PixelsPerDword;    // one pixel wide

            step = dy / 10;

            if (step > 5)
               step = 5;

            if (step < 1)
               step = 1;
            break;

         case 1:
            dx = 10 * PixelsPerDword;   // 10 pixels wide
            break;

         case 2:
            dx = 100 * PixelsPerDword;  // 100 pixels wide

            y2 = height - 1;  // Make sure last line is shown
            break;
         }

      CurrentColor = white;

      for (x1 = 0; x1 < width; x1 += dx)
         {
         x2 = x1 + dx - 1;

         if (x2 >= width)
            x2 = width-1;

         if (dx == 1)
            {
            if (CurrentColor == white)
               StepCount = 0;
            else
               StepCount += step;

            seDrawRect(x1, y1 + StepCount, x2, y2, GetNextColor(), TRUE);
            }
         else
            seDrawRect(x1, y1, x2, y2, GetNextColor(), TRUE);
         }
      }

   if (ShowSubWindow)
      MaxX = width - PhysicalWidth / 2 - 1;
   else
      MaxX = width - PhysicalWidth;

   MaxY = PhysicalHeight;
   }

/*-------------------------------------------------------------------------*/

void DisplayScrollImage(void)
{
   unsigned width = 1024;
   unsigned height;
   unsigned PhysicalWidth, PhysicalHeight;
   unsigned x1, y1, x2, y2;
   unsigned dx, dy;
   unsigned step, StepCount;
   unsigned section;
   DWORD white;

   if (seGetResolution(&PhysicalWidth, &PhysicalHeight) != ERR_OK)
      {
      printf("ERROR: No display enabled.\n");
      exit(1);
      }

   if (ShowSubWindow)
      {
      seUseMainWinImageForSubWin();

      x1 = PhysicalWidth / 4;
      y1 = PhysicalHeight / 4;
      x2 = ((3 * PhysicalWidth) / 4) - 1;
      y2 = (3 * PhysicalHeight) / 4;

      seSetSubWinCoordinates(x1, y1, x2, y2);
      seSubWinDisplayEnable(TRUE);
      seSetSubWinAsActiveSurface();
      }


   /*
   ** Select the largest image height possible.
   */
   height = DISPLAY_BUFFER_SIZE / (width * seGetBitsPerPixel() / 8);

   if (height <= PhysicalHeight)
      {
      printf(">>> WARNING: Not enough memory for virtual display. <<<\n");
      printf(">>>          Valid until line %u.                   <<<\n\n", height-1);
      }

   InitializeVirtualDisplay(width, height);
   printf("Virtual Image Size: %u x %u\n", width, height);


   /*
   ** Get white value
   */
   switch (seGetBitsPerPixel())
      {
      default:  // 4 and 8 bpp
         white = WHITE_4BPP;
         break;

      case 16:
         white = WHITE_16BPP;
         break;
      }


   /*
   ** The leftmost vertical section consists of horizontal lines which are one pixel high.
   ** These lines are colored according to the following sequence:
   **
   ** black, brown, red, orange, yellow, green, blue, violet, gray, white
   **
   ** The second from the left vertical section consists of 10 pixel high rectangles and
   ** follow the same coloring sequence as above.
   */
   dx = PhysicalWidth / 2;
   dy = 1;
   step = 0;
   StepCount = 0;

   for (section = 0; section < 2; ++section)
      {
      switch (section)
         {
         case 0:
            dy = 1;    // one pixel high

            step = dx / 10;

            if (step > 5)
               step = 5;

            if (step < 1)
               step = 1;
            break;

         case 1:
            dy = 10;   // 10 pixels high
            break;
         }

      x1 = dx * section;
      x2 = x1 + dx - 1;

      CurrentColor = white;

      for (y1 = 0; y1 < height; y1 += dy)
         {
         y2 = y1 + dy - 1;

         if (section == 3)
            x2 = width - 1;

         if (y2 >= height)
            y2 = height - 1;

         if (dy == 1)
            {
            if (CurrentColor == white)
               StepCount = 0;
            else
               StepCount += step;

            seDrawRect(x1 + StepCount, y1, x2, y2, GetNextColor(), TRUE);
            }
         else
            seDrawRect(x1, y1, x2, y2, GetNextColor(), TRUE);
         }
      }

   MaxX = PhysicalWidth;

   if (ShowSubWindow)
      {
      MaxX = (PhysicalWidth / 2) - 1;
      MaxY = height - (PhysicalHeight / 2) - 1;
      }
   else
      {
      MaxX = PhysicalWidth;
      MaxY = height - PhysicalHeight;
      }
}

/*-------------------------------------------------------------------------*/

int main( int argc, char *argv[] )
   {
   unsigned width, height;
   DWORD x1, y1, x2, y2;

   int error = 0;

/*-------------------*/

   InitializeGlobalVariables();

/*-------------------*/

   DisplayCopyright();

   if ((error = ParseCommandLine(argc, argv)) != 0)
      return error;

   if ((error = RegisterDevice(&HalInfo)) != 0)
      return error;

   if ((error = InitRegisters()) != 0)
      return error;



   if (CmdLineBitsPerPixel != 0)
      {
      //
      // First check if valid clocks for given mode
      //
      if (!CheckSwivelViewClocks(CmdLineBitsPerPixel, seGetSwivelViewMode()))
         exit(1);

      if (seSetMode(CmdLineBitsPerPixel) != ERR_OK)
         {
         printf("ERROR: 13706VIRT could not change to %d bits-per-pixel.\n",
                CmdLineBitsPerPixel);
         exit(1);
         }
      }


   // Make sure a valid bpp mode is selected
   switch (seGetBitsPerPixel())
      {
      case 4:
      case 8:
      case 16:
         break;

      default:
         printf("WARNING: Invalid bits-per-pixel mode detected.\n");
         printf("         Changing to 4 bits-per-pixel.\n");
         seSetMode(4);
         break;
      }


   // Used for both 4 and 8 bpp modes
   seWriteLut(LUT_4bpp, 16);


   switch (mode)
      {
      case MODE_PAN:
         DisplayPanImage(VirtualWidth);

         if (ShowSubWindow)
            {
            seGetMainWinResolution(&width, &height);
            x1 = width / 4;
            y1 = height / 4;
            x2 = ((3 * width) / 4) - 1;
            y2 = (3 * height) / 4;

            seSetSubWinCoordinates(x1, y1, x2, y2);
            seSubWinDisplayEnable(TRUE);
            }

         printf("Bits-per-pixel: %u\n", seGetBitsPerPixel());
         HandleKeyboard();
         break;

      case MODE_SCROLL:
         DisplayScrollImage();

         if (ShowSubWindow)
            {
            seGetMainWinResolution(&width, &height);
            x1 = width / 4;
            y1 = height / 4;
            x2 = ((3 * width) / 4) - 1;
            y2 = (3 * height) / 4;

            seSetSubWinCoordinates(x1, y1, x2, y2);
            seSubWinDisplayEnable(TRUE);
            }

         printf("Bits-per-pixel: %u\n", seGetBitsPerPixel());
         HandleKeyboard();
         break;

      default:
         DisplayUsage();
         printf("ERROR: No test mode selected.\n");
         exit(1);
         break;
      }

   return 0;
   }

/*-------------------------------------------------------------------------*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -