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

📄 show.c

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

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

            SetLcdBitsPerPixel(LcdBitsPerPixel);

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

            seDisplayLcdBlank(FALSE);

            NumberOfSurfaces = 1;
            DisplaySurfaceCombination = SURFACE_LCD0;
            SurfaceDisplayMode[0] = LCD;
            break;
   
         /*
         ** Surface 0: CRT
         ** Surface 1: none
         */
         case 1:
            if (!(HalInfo.dwFlags & fVALID_CRT))
               ExitBadConfiguration(CRT);

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

            SetCrtBitsPerPixel(CrtTvBitsPerPixel);

            seLcdDisplayEnable(FALSE);
            seCrtDisplayEnable(TRUE);

            seDisplayCrtBlank(FALSE);

            NumberOfSurfaces = 1;
            DisplaySurfaceCombination = SURFACE_CRTTV0;
            SurfaceDisplayMode[0] = CRT;
            break;
   
         /*
         ** Surface 0: TV
         ** Surface 1: none
         */
         case 2:
            if (!(HalInfo.dwFlags & fVALID_TV))
               ExitBadConfiguration(TV);

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

            SetTvBitsPerPixel(CrtTvBitsPerPixel);

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

            NumberOfSurfaces = 1;
            DisplaySurfaceCombination = SURFACE_CRTTV0;
            SurfaceDisplayMode[0] = TV;
            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();

            SetLcdCrtBitsPerPixel(LcdBitsPerPixel);

            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);
               }

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

            NumberOfSurfaces = 1;
            DisplaySurfaceCombination = SURFACE_LCDCRTTV0;
            SurfaceDisplayMode[0] = LCD;
            SurfaceDisplayMode[1] = CRT;
            CommonMemoryBlockForAllDisplays = TRUE;
            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();

            SetLcdTvBitsPerPixel(LcdBitsPerPixel);

            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);
               }

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

            NumberOfSurfaces = 1;
            DisplaySurfaceCombination = SURFACE_LCDCRTTV0;
            SurfaceDisplayMode[0] = LCD;
            SurfaceDisplayMode[1] = TV;
            CommonMemoryBlockForAllDisplays = TRUE;
            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);

            SetLcdBitsPerPixel(LcdBitsPerPixel);
            SetCrtBitsPerPixel(CrtTvBitsPerPixel);

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

            NumberOfSurfaces = 2;
            DisplaySurfaceCombination = SURFACE_LCD0_CRTTV1;
            SurfaceDisplayMode[0] = LCD;
            SurfaceDisplayMode[1] = CRT;
            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);

            SetLcdBitsPerPixel(LcdBitsPerPixel);
            SetTvBitsPerPixel(CrtTvBitsPerPixel);

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

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

         default:
            printf("%s", szBad_iDisplay);
            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;

         if (LcdBitsPerPixel != CrtTvBitsPerPixel)
            {
            printf("ERROR: In the given display surface configuration,\n"
                   "       the user must select the same BPP for both\n"
                   "       LCD and CRT/TV.\n");
            return 1;
            }

         break;
      }

   
   regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);

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

   SetActiveSurfaceNumber(0);

   if (ShowAllBppModes)
      {
      for (k = 0; k < BppSize; ++k)
         {
         /*
         ** Don't show a BPP which is greater than what was set
         ** by the configuration program.
         */
         for (surface = 0; surface < NumberOfSurfaces; ++surface)
            {
            if (!gnAutoRun && (surface == (NumberOfSurfaces - 1)))
               pStr = szPressKey;
            else
               pStr = NULL;

            switch (GetSurfaceDisplayMode(surface))
               {
               case LCD:
               case LCD | CRT:
               case LCD | TV:
               case LCD | CRT | TV:
                  if (bpp[k] > LcdBitsPerPixel)
                     continue;
                  break;

               case CRT:
               case TV:
               case CRT | TV:
                  if (bpp[k] > CrtTvBitsPerPixel)
                     continue;
                  break;
               }

            if (ShowOneMode(surface, bpp[k], pStr) == ERR_FAILED)
               break;

            if ((NumberOfSurfaces == 1) ||
               (((NumberOfSurfaces > 1) && (surface > 0))))
               {
               if (!gnAutoRun)
                  {
                  ch = getch( );
                  if ((0x03 == ch) || (0x1B == ch))
                     return 0;
                  }
#if defined(INTEL_W32) || defined(INTEL_DOS)
               else
                  {
                  seDelay(5);    
                  }
#endif
               }
            }
         }
      }
   else
      {
      for (surface = 0; surface < NumberOfSurfaces; ++surface)
         {
         if (ShowOneMode( surface, nBitsPerPixel[surface], NULL ) == ERR_FAILED)
            break;
         }
      }

   return 0;
   }

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

void DisplayCopyright( void )
{
   const char *szHalVer;
   const char *szHalStatus;
   const char *szHalStatusRev;

   seGetHalVersion( &szHalVer, &szHalStatus, &szHalStatusRev );

   printf( "13506SHOW.EXE - Color depth testing Utility - 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("Register Start Addr:       ");
   if (HalInfo.dwRegisterAddress == 0)
      printf("Configured by system\n");
   else
      printf("%08lX\n", HalInfo.dwRegisterAddress);

   printf("Display Memory Start Addr: ");
   if (HalInfo.dwDisplayMemoryAddress == 0)
      printf("Configured by system\n");
   else
      printf("%08lX\n", HalInfo.dwDisplayMemoryAddress);
}

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

void DisplayUsage( void )
   {
   printf("\nUsage:   SHOW [bl=n] [bc=n] [ds=n | ds=?] [/a] [/g] [/noinit]\n" );
   printf(  "         [/r90 | /r180 | /r270] [/read] [/s] [/write] [/?]\n" );
   printf(  "    bl=n      bits-per-pixel (LCD) where n = ( 4, 8, 15, 16 )\n" );
   printf(  "    bc=n      bits-per-pixel (CRT/TV) where n = ( 4, 8, 15, 16 )\n" );
   printf(  "    ds=n      select predefined display surfaces\n" );
   printf(  "    ds=?      show available display surfaces\n" );
   printf(  "   /a         automatically cycle through all video modes\n" );
   printf(  "   /g         show grid\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(  "   /read      continually read one dword from screen\n" );
   printf(  "   /s         show vertical stripes\n" );
   printf(  "   /write     continually write to one word of offscreen memory\n" );
   printf(  "   /?         display help message\n" );
   }

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

int ShowOneMode( int surface, int BitsPerPixel, char *str )
   {
   unsigned width;
   unsigned height;
   DWORD lSize;
   DWORD addr = 0;
   DWORD dwVal = 0;
   unsigned LcdWidth, LcdHeight;
   unsigned CrtTvWidth, CrtTvHeight;

#ifndef INTEL_DOS
   volatile DWORD *dwPtr = 0;
   volatile DWORD *dwStartPtr = 0;
   unsigned count = 0;
#endif


   SetActiveSurfaceNumber(surface);

   lSize = seGetAvailableMemorySize();

   if (lSize > 0)
      --lSize;

   /*
   ** Cannot show 4 bpp if in rotate90 mode.
   */
   if ((Orientation[surface] & ROTATE90) && (BitsPerPixel < 8))
      {
      if (SelectedLcdBppMode)
         printf("ERROR: Do not select %d BPP LCD in SwivelView 90 or SwivelView 270 degrees.\n", BitsPerPixel);
      else
         printf("WARNING: Cannot use %d BPP LCD in SwivelView 90 or SwivelView 270 degrees.\n", BitsPerPixel);

      return ERR_FAILED;
      }

   if (gnInitRegisters)
      {
#ifdef INTEL_DOS
      if (SetBitsPerPixel(surface, BitsPerPixel) == -1)
#else
      if (SetBitsPerPixel(surface, BitsPerPixel) == 0)
#endif
         {
         DisplayErrorNotEnoughMemory(BitsPerPixel);
         return ERR_FAILED;
         }
      }

   if (CalcDisplaySurfaceCombination() == SURFACE_LCDCRTTV0)
      {
      seGetLcdResolution(&LcdWidth, &LcdHeight);
      seGetCrtResolution(&CrtTvWidth, &CrtTvHeight);

      if ((CrtTvWidth >= LcdWidth) && (CrtTvHeight >= LcdHeight))
         surface = 1;
      else
         surface = 0;
      }

   SetActiveSurfaceNumber(surface);

   // get out of ROTATE 90 mode
   seWriteRegByte(REG_DISPLAY_MODE, seReadRegByte(REG_DISPLAY_MODE) & ~0x40);
   seGetResolution(&width, &height);

   /*
   ** Update rotate90 mode
   */
   if (Orientation[surface] & ROTATE90)
      seWriteRegByte(REG_DISPLAY_MODE, seReadRegByte(REG_DISPLAY_MODE) | 0x40);

   switch (VirtInit(surface, width, height))
      {
      case ERR_NOT_ENOUGH_MEMORY:
         DisplayResolution();
         printf("ERROR: Not enough memory for virtual display.\n");
         return ERR_FAILED;
         break;

      case ERR_OK:
         break;

      default:
         DisplayResolution();
         printf("ERROR: Could not initialize virtual display.\n");
         return ERR_FAILED;
      }


   /*
   ** It was decided that the 13506 HAL would not refuse an attempt to set
   ** a color depth greater than can be supported by display memory. So...
   ** we have to check for ourselves whether we can fit into memory.
   */
   if (seGetResolution(&width, &height) == ERR_OK)
      {
      if ((((DWORD) width * height * 2 * BitsPerPixel) / 16)  > lSize)
         return ERR_FAILED;
      }


   if (gnUpdateDisplayMemory)
      UpdateScreen( BitsPerPixel );

   seDisplayBlank(FALSE);

   if (str != NULL)

⌨️ 快捷键说明

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