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

📄 bmp.c

📁 epson 13506 driver code
💻 C
📖 第 1 页 / 共 4 页
字号:
            break;

         case 4:
         case 6:
            DisplayMode = LCD | TV;

            if (HalInfo.wTVFlickerFilter)
               DisplayMode |= CRT;
            break;

         default:
            DisplayMode = 0;
            break;
         }

      switch (seInitReg(DisplayMode, CLEAR_MEM | DISP_BLANK))
         {
         case ERR_OK:
            break;

         case ERR_CLKI_NOT_IN_TABLE:
            printf("WARNING: CLKI frequency not in HAL table.\n"
                   "         Program assumes that external oscillator is used.\n");
            break;

         case ERR_CLKI2_NOT_IN_TABLE:
            printf("WARNING: CLKI2 frequency not in HAL table.\n"
                   "         Program assumes that external oscillator is used.\n");
            break;

         case ERR_NOT_ENOUGH_MEMORY:
            printf("\nERROR: Not enough display buffer memory.\n");
            return 1;
            break;
         }
      }
   else
      {
      LcdOrientation = LANDSCAPE;

      if (seReadRegByte(REG_DISPLAY_MODE) & 0x40)
         LcdOrientation |= ROTATE90;

      if (seReadRegByte(REG_LCD_DISPLAY_MODE) & 0x10)
         LcdOrientation |= ROTATE180;
      }


   regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);

   if (LcdOrientation & ROTATE90)
      seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode | 0x40);
   else
      seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode & ~0x40);


   regLcdDisplayMode = seReadRegByte(REG_LCD_DISPLAY_MODE);

   if (LcdOrientation & ROTATE180)
      seWriteRegByte(REG_LCD_DISPLAY_MODE, regLcdDisplayMode | 0x10);
   else
      seWriteRegByte(REG_LCD_DISPLAY_MODE, regLcdDisplayMode & ~0x10);


   regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);

   if (iDisplay == -1)
      {
      switch (regDisplayMode & 0x07)
         {
         case LCD:
         default:
            iDisplay = 0;
            break;

         case CRT:
            iDisplay = 1;
            break;

         case TV:
         case (CRT | TV):  // flicker filter on
            iDisplay = 2;
            break;

         case (LCD | CRT):
            iDisplay = 5;  // separate surfaces
            break;

         case (LCD | TV):
         case (LCD | CRT | TV):
            iDisplay = 6;  // separate  surfaces
            break;
         }
      }


   if (iDisplay != -1)
      {
      seWriteRegDword(REG_LCD_START_ADDR0, 0);
      seWriteRegDword(REG_CRTTV_START_ADDR0, 0);

      if (CrtTvBitsPerPixel == 0)
         CrtTvBitsPerPixel = seGetCrtBitsPerPixel();

      if (LcdBitsPerPixel == 0)
         LcdBitsPerPixel = seGetLcdBitsPerPixel();

      switch (iDisplay)
         {
         /*
         ** Surface 0: LCD
         ** Surface 1: none
         */
         case 0:
            if (!(HalInfo.dwFlags & fVALID_LCD))
               ExitBadConfiguration(LCD);

            seLcdDisplayEnable(TRUE);
            seCrtDisplayEnable(FALSE);  // also disables TV

            seDisplayLcdBlank(FALSE);

            NumberOfSurfaces = 1;
            DisplaySurfaceCombination = SURFACE_LCD0;
            SurfaceDisplayMode[0] = LCD;

            CheckBmpCount(1);
            SetBitsPerPixel();
            break;
   
         /*
         ** Surface 0: CRT
         ** Surface 1: none
         */
         case 1:
            if (!(HalInfo.dwFlags & fVALID_CRT))
               ExitBadConfiguration(CRT);

            if (LcdOrientation)
               printf("%s", szCrtTvInLandscapeMode);

            seLcdDisplayEnable(FALSE);
            seCrtDisplayEnable(TRUE);
   
            seDisplayCrtBlank(FALSE);

            NumberOfSurfaces = 1;
            DisplaySurfaceCombination = SURFACE_CRTTV0;
            SurfaceDisplayMode[0] = CRT;

            CheckBmpCount(1);
            SetBitsPerPixel();
            break;
   
         /*
         ** Surface 0: TV
         ** Surface 1: none
         */
         case 2:
            if (!(HalInfo.dwFlags & fVALID_TV))
               ExitBadConfiguration(TV);

            if (LcdOrientation)
               printf("%s", szCrtTvInLandscapeMode);

            seLcdDisplayEnable(FALSE);
            seTvDisplayEnable(TRUE);
   
            seDisplayTvBlank(FALSE);

            NumberOfSurfaces = 1;
            DisplaySurfaceCombination = SURFACE_CRTTV0;
            SurfaceDisplayMode[0] = TV;

            CheckBmpCount(1);
            SetBitsPerPixel();
            break;
   
   
         /*
         ** Surface 0: LCD & CRT
         ** Surface 1: none
         */
         case 3:
            if (!(HalInfo.dwFlags & fVALID_LCD))
               ExitBadConfiguration(LCD);
            else if (!(HalInfo.dwFlags & fVALID_CRT))
               ExitBadConfiguration(CRT);

            seGetLcdResolution(&width1, &height1);
            seGetCrtResolution(&width2, &height2);

            CheckLcdOrientationForLandscape();

            if ((width1 != width2) || (height1 != height2))
               {
               printf("\nWARNING: LCD and CRT resolutions not same but use same display memory block.");
               printf("\n         LCD: (%d, %d)", width1, height1);
               printf("\n         CRT: (%d, %d)\n", width2, height2);
               }

            if (LcdOrientation)
               {
               printf("%s%s", szCrtTvInLandscapeMode, szForcingLandscapeMode);
               LcdOrientation = LANDSCAPE;
               }

            seLcdDisplayEnable(TRUE);
            seCrtDisplayEnable(TRUE);
   
            seDisplayLcdBlank(FALSE);
            seDisplayCrtBlank(FALSE);

            NumberOfSurfaces = 2;
            DisplaySurfaceCombination = SURFACE_LCDCRTTV0;
            SurfaceDisplayMode[0] = LCD;
            SurfaceDisplayMode[1] = CRT;
            CommonMemoryBlockForAllDisplays = TRUE;

            CheckBmpCount(1);
            SetBitsPerPixel();
            break;
   
         /*
         ** Surface 0: LCD & TV
         ** Surface 1: none
         */
         case 4:
            if (!(HalInfo.dwFlags & fVALID_LCD))
               ExitBadConfiguration(LCD);
            else if (!(HalInfo.dwFlags & fVALID_TV))
               ExitBadConfiguration(TV);

            seGetLcdResolution(&width1, &height1);
            seGetTvResolution(&width2, &height2);

            CheckLcdOrientationForLandscape();

            if ((width1 != width2) || (height1 != height2))
               {
               printf("\nWARNING: LCD and TV resolutions not same but use same display memory block.");
               printf("\n         LCD: (%d, %d)", width1, height1);
               printf("\n         TV:  (%d, %d)\n", width2, height2);
               }

            if (LcdOrientation)
               {
               printf("%s%s", szCrtTvInLandscapeMode, szForcingLandscapeMode);
               LcdOrientation = LANDSCAPE;
               }

            seLcdDisplayEnable(TRUE);
            seTvDisplayEnable(TRUE);
   
            seDisplayLcdBlank(FALSE);
            seDisplayTvBlank(FALSE);

            NumberOfSurfaces = 2;
            DisplaySurfaceCombination = SURFACE_LCDCRTTV0;
            SurfaceDisplayMode[0] = LCD;
            SurfaceDisplayMode[1] = TV;
            CommonMemoryBlockForAllDisplays = TRUE;

            CheckBmpCount(1);
            SetBitsPerPixel();
            break;
   
         /*
         ** Surface 0: LCD
         ** Surface 1: CRT
         */
         case 5:
            if (!(HalInfo.dwFlags & fVALID_LCD))
               ExitBadConfiguration(LCD);
            else if (!(HalInfo.dwFlags & fVALID_CRT))
               ExitBadConfiguration(CRT);

            if (LcdOrientation)
               printf("%s", szCrtTvInLandscapeMode);

            seLcdDisplayEnable(TRUE);
            seCrtDisplayEnable(TRUE);

            seDisplayLcdBlank(FALSE);
            seDisplayCrtBlank(FALSE);

            NumberOfSurfaces = 2;
            DisplaySurfaceCombination = SURFACE_LCD0_CRTTV1;
            SurfaceDisplayMode[0] = LCD;
            SurfaceDisplayMode[1] = CRT;

            // Don't call CheckBmpCount() because this routine will accept 1 or 2 BMP images.
            SetBitsPerPixel();
            break;
   
         /*
         ** Surface 0: LCD
         ** Surface 1: TV
         */
         case 6:
            if (!(HalInfo.dwFlags & fVALID_LCD))
               ExitBadConfiguration(LCD);
            else if (!(HalInfo.dwFlags & fVALID_TV))
               ExitBadConfiguration(TV);

            if (LcdOrientation)
               printf("%s", szCrtTvInLandscapeMode);

            seLcdDisplayEnable(TRUE);
            seTvDisplayEnable(TRUE);
   
            seDisplayLcdBlank(FALSE);
            seDisplayTvBlank(FALSE);

            NumberOfSurfaces = 2;
            DisplaySurfaceCombination = SURFACE_LCD0_CRTTV1;
            SurfaceDisplayMode[0] = LCD;
            SurfaceDisplayMode[1] = TV;

            // Don't call CheckBmpCount() because this routine will accept 1 or 2 BMP images.
            SetBitsPerPixel();
            break;

         default:
            printf("\nERROR: Invalid display surface number.\n");
            return 1;
            break;
         }
      }

   printf("\n");

   for (i = 0; i < MAX_DISP_SURFACE; ++i)
      {
      if (SurfaceDisplayMode[i] == 0)
         SurfaceDisplayMode[i] = GetSurfaceDisplayMode(i);
      }

   ShowActiveDisplaySurface();

   // Display LCD Orientation if LCD enabled
   if (seReadRegByte(REG_DISPLAY_MODE) & 0x01)
      DisplayLcdOrientation();

   LcdBitsPerPixel = seGetLcdBitsPerPixel();
   CrtTvBitsPerPixel = seGetCrtBitsPerPixel();

   if (DisplaySurfaceCombination == SURFACE_NONE)
      DisplaySurfaceCombination = CalcDisplaySurfaceCombination();

   switch (DisplaySurfaceCombination)
      {
      case SURFACE_LCD0_CRTTV1:
         Orientation[0] = LcdOrientation;

         nBitsPerPixel[0] = LcdBitsPerPixel;
         nBitsPerPixel[1] = CrtTvBitsPerPixel;
         break;

      case SURFACE_LCD0:
         Orientation[0] = LcdOrientation;

         nBitsPerPixel[0] = LcdBitsPerPixel;
         break;

      case SURFACE_CRTTV0:
         nBitsPerPixel[0] = CrtTvBitsPerPixel;
         break;

      case SURFACE_LCDCRTTV0:
         Orientation[0] = LcdOrientation;

         nBitsPerPixel[0] = LcdBitsPerPixel;
         nBitsPerPixel[1] = CrtTvBitsPerPixel;
         break;
      }
   

   regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);

   if (LcdOrientation & ROTATE90)
      {
      regDisplayMode |= 0x40;
      seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
      }
   else
      {
      regDisplayMode &= ~0x40;
      seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
      }


   val = 0;

   if (BmpCount == 1)
      filename[1] = filename[0];

   if (NumberOfSurfaces < BmpCount)
      NumberOfSurfaces = BmpCount;

   for (surface = 0; surface < NumberOfSurfaces; ++surface)
      {
      SetActiveSurfaceNumber(surface);

      val = Show13506(filename[surface]);

      if (val > 0)
         return val;
      }

   return val;
}

/*-------------------------------------------------PrintUsage()------*/
void PrintUsage(void)
{
   const char *szHalVer;
   const char *szHalStatus;
   const char *szHalStatusRev;
   
   seGetHalVersion(&szHalVer, &szHalStatus, &szHalStatusRev);
   
   printf("\n13506BMP.EXE Version %s  [HAL %s%s%s]\n", szVersion, szHalVer, szHalStatus, szHalStatusRev);
   printf("Copyright (c) 1997, 2001 Epson Research and Development, Inc.\n");
   printf("All Rights Reserved.\n\n");
   
   /*
   // printf("\n**********  BETA VERSION DO NOT DISTRIBUTE  **********\n\n");
   */
   
   printf("Usage:   13506BMP bmpfile [bmpfile2] [ds=n | ds=?] [/noinit]\n"
          "         [/r90 | /r180 | r270] [/v] [/?]\n");
   printf("   bmpfile1  BMP image used for the first surface (surface 0)\n");
   printf("   bmpfile2  BMP image used for the second surface (surface 1)\n");
   printf("               If bmpfile2 not given, bmpfile1 is used for second surface.\n");
   printf("   ds=n      select predefined display surfaces\n" );
   printf("   ds=?      show available display surfaces\n" );
   printf("   /noinit   skips register initialization\n" );
   printf("   /r90      SwivelView 90 degree rotation  (for LCD)\n");
   printf("   /r180     SwivelView 180 degree rotation (for LCD)\n");
   printf("   /r270     SwivelView 270 degree rotation (for LCD)\n");
   printf("   /v        verbose mode\n");
   printf("   /?        display help message\n");
   printf("Command line arguments in [] are optional.\n\n");
}

/*-------------------------------------------Show13506()------*/

unsigned Show13506(char *fname)
{
   unsigned regDisplayMode;
   unsigned nWidth, nHeight;

   seDisplayBlank(TRUE);

   if (GetSurfaceDisplayMode(ActiveSurfaceNumber) & LCD)
      {
      regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);
   
      if (LcdOrientation & ROTATE90)
         {
         /*
         ** Don't call VirtInit() if rotate90 mode already initialized.
         */
         if (!(regDisplayMode & ROTATE90_MODE_BIT))
            {
            regDisplayMode |= ROTATE90_MODE_BIT;
            seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
            }
         }
      else
         {
         regDisplayMode &= ~ROTATE90_MODE_BIT;
         seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);

⌨️ 快捷键说明

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