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

📄 play.c

📁 epson 13506 driver code
💻 C
📖 第 1 页 / 共 5 页
字号:
      if (RegStartAddr[count] != (WORD) LastAddr)
         printf("\n");

      printf("\n[%04X] ", addr);

      if (addr < 0x1000)
         {
         for (count2 = 0; count2 < 16; ++count2, ++addr)
            {
            val = seReadRegByte(addr);
            printf("%02X", val);

            if (count2 == 7)
               printf("-");
            else
               printf(" ");
            }
         }
      else
         {
         for (count2 = 0; count2 < 8; ++count2, addr += 2)
            {
            // Read word without swapping bytes if endian of system is big-endian.
            val = ReadRegWord(addr);
            printf("%04X", val);

            if (count2 == 3)
               printf("-");
            else
               printf(" ");
            }
         }

      LastAddr = addr;
      }
}

/*== Command Handlers ===================================================*/

void HandleSetFreq( PCHAR szArg )
{
   int index = 0;
   WORD Freq_Int, Freq_Frac;
   DWORD *ptr;

   char *szSource[3] = { "CLKI", "CLKI2", "BUSCLK" };

   AscToUpper(szArg);

   ptr = NULL;

   /*
   ** Get PCLK source (CLKI, CLKI2, BUSCLK)
   */
   if (FALSE != FindNextArg(&szArg))
      {
      if (!strncmp(szArg, "CLKI2", 5))
         {
         index = 1;
         ptr = &dwClki2Freq;
         }
      else if (!strncmp(szArg, "CLKI", 4))
         {
         index = 0;
         ptr = &dwClkiFreq;
         }
      else if (!strncmp(szArg, "BUSCLK", 6))
         {
         index = 2;
         ptr = &dwBusClkFreq;
         }
      else
         {
         DISPLAY_WHAT;
         return;
         }
      }
   else
      {
      DISPLAY_WHAT;
      return;
      }


   if (ptr == NULL)
      {
      DISPLAY_WHAT;
      return;
      }


   /*
   ** Get frequency
   */
   if (FALSE != FindNextArg(&szArg))
      {
      *ptr = atol(szArg);

      if (*ptr <= 0)
         {
         DISPLAY_WHAT;
         return;
         }
      }


   printf("\n");

   Freq_Int = (WORD) (*ptr / 1000);
   Freq_Frac = (WORD) (*ptr - (Freq_Int * 1000));
   printf("%s Source Freq=%u.%03u MHz", szSource[index], Freq_Int, Freq_Frac);
}

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

/*
** Completes the parsing and executes the (L)UT command.
*/
void HandleLutIO( PCHAR szArg )
{
   int nIdx;
   unsigned DisplayMode;
   BYTE byLut[3];


   AscToUpper(szArg);

   if (!strncmp(szArg, "LCD", 3))
      {
      /*
      ** Get display type
      */
      if (FALSE != FindNextArg(&szArg))
         {
         if (!strncmp(szArg, "ON", 2))
            seLcdDisplayEnable(TRUE);
         else if (!strncmp(szArg, "OFF", 3))
            seLcdDisplayEnable(FALSE);
         else
            {
            DISPLAY_WHAT;
            return;
            }
         }
      else
         {
         DISPLAY_WHAT;
         return;
         }

      return;
      }


   /*
   ** Are we to dump all the LUT registers?
   */
   if ('A' == toupper(*(szArg + 1)))
   {
      DisplayAllLutEntries(szArg);
      return;
   }

   /*
   ** Otherwise ensure the command is all by itself.
   */
   if (!isspace((int) *(szArg + 1)))
   {
      DISPLAY_WHAT;
      return;
   }


   /*
   ** Get display type
   */
   if (FALSE != FindNextArg(&szArg))
      {
      if (!strncmp(szArg, "LCD", 3))
         DisplayMode = LCD;
      else if (!strncmp(szArg, "CRT", 3))
         DisplayMode = CRT;
      else if (!strncmp(szArg, "TV", 2))
         DisplayMode = TV;
      else
         {
         DISPLAY_WHAT;
         return;
         }
      }
   else
      {
      DISPLAY_WHAT;
      return;
      }


   /*
   ** We MUST have an index.
   */
   if (FALSE == FindNextArg( &szArg ))
   {
      DISPLAY_WHAT;
      return;
   }
   nIdx = (WORD)AscToLong( szArg );

   if (nIdx > 0xff)
   {
      DISPLAY_WHAT;
      return;
   }

   /*
   ** If we don't find any other arguments then do a read.
   */
   if (FALSE == FindNextArg( &szArg ))
      {
      /*
      ** If nothing selected, assume LCD LUT.
      */
      if (DisplayMode & CRT)
         {
         seReadCrtLutEntry(nIdx, &byLut[0]);

         printf( "\nCRT L[%02X] > %02X  %02X  %02X",
                 nIdx, byLut[0], byLut[1], byLut[2] );
         }
      else if (DisplayMode & TV)
         {
         seReadTvLutEntry(nIdx, &byLut[0]);

         printf( "\nTV L[%02X] > %02X  %02X  %02X",
                 nIdx, byLut[0], byLut[1], byLut[2] );
         }
      else
         {
         seReadLcdLutEntry(nIdx, &byLut[0]);

         printf( "\n   LCD L[%02X] > %02X  %02X  %02X",
                 nIdx, byLut[0], byLut[1], byLut[2] );
         }

      return;
      }

   /*
   ** We found an argument - therefore - we MUST have 3 arguments.
   */
   byLut[HAL_RED] = (BYTE)AscToLong( szArg );

   if (FALSE == FindNextArg( &szArg ))
   {
      DISPLAY_WHAT;
      return;
   }
   byLut[HAL_GREEN] = (BYTE)AscToLong( szArg );

   if (FALSE == FindNextArg( &szArg ))
   {
      DISPLAY_WHAT;
      return;
   }
   byLut[HAL_BLUE] = (BYTE)AscToLong( szArg );


   if (DisplayMode & CRT)
      seWriteCrtLutEntry(nIdx, &byLut[0]);
   else if (DisplayMode & TV)
      seWriteTvLutEntry(nIdx, &byLut[0]);
   else
      seWriteLcdLutEntry(nIdx, &byLut[0]);
}

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

void HandlePowersave( PCHAR szArg )
{
   AscToUpper(szArg);

   if (FALSE != FindNextArg(&szArg))
      {
      if (!strncmp(szArg, "ON", 2))
         seSetPowerSaveMode(TRUE);
      else if (!strncmp(szArg, "OFF", 3))
         seSetPowerSaveMode(FALSE);
      else
         {
         DISPLAY_WHAT;
         return;
         }
      }
   else
      {
      DISPLAY_WHAT;
      return;
      }
}

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

/*
**
*/
void HandleRegIO( PCHAR szArg )
{
   DWORD dwIdx;
   unsigned val;
   DWORD dwVal;
   char szBinary[50];
   int  RegSize = 1;


   /*
   ** Are we to dump all the registers?
   */
   if ('A' == toupper( *(szArg + 1) ))
   {
      DisplayAllRegisters();
      return;
   }


   if ('D' == toupper ( *(szArg + 1) ))
      RegSize = 4;
   else if ('W' == toupper ( *(szArg + 1) ))
      RegSize = 2;
   else
      RegSize = 1;


   /*
   ** Otherwise ensure the command is all by itself.
   */
   if ((RegSize == 1) && !isspace((int) *(szArg + 1)))
   {
      DISPLAY_WHAT;
      return;
   }

   if (FALSE == FindNextArg( &szArg ))
   {
      DISPLAY_WHAT;
      return;
   }

   dwIdx = AscToLong( szArg );


   if (FALSE == FindNextArg( &szArg ))
      {
      switch (RegSize)
         {
         case 4:
            // Read dword without swapping bytes if endian of system is big-endian.
            dwVal = ReadRegDword(dwIdx);
            IntToBin( dwVal, 32, szBinary );
            printf( "\n      [%lX] > %08lX  %sb %lut",
                    dwIdx, dwVal, szBinary, dwVal );
            break;

         case 2:
            // Read word without swapping bytes if endian of system is big-endian.
            val = ReadRegWord(dwIdx);
            IntToBin( (DWORD) val, 16, szBinary );
            printf( "\n      [%lX] > %04X  %sb %3ut",
                    dwIdx, val, szBinary, val );
            break;

         default:
            val = seReadRegByte(dwIdx);
            IntToBin( (DWORD) val, 8, szBinary );
            printf( "\n      [%lX] > %02X  %sb %3ut",
                    dwIdx, val, szBinary, val );
            break;
         }

      return;
      }
   else
      {
      switch (RegSize)
         {
         case 4:
            dwVal = AscToLong(szArg);
            // Write dword without swapping bytes if endian of system is big-endian.
            WriteRegDword(dwIdx, dwVal);
            printf( "\n      [%lX] < %08lX", dwIdx, dwVal );
            break;

         case 2:
            val = (unsigned) AscToLong(szArg);
            // Write word without swapping bytes if endian of system is big-endian.
            WriteRegWord(dwIdx, val);
            printf( "\n      [%lX] < %04X", dwIdx, val );
            break;

         default:
            val = (unsigned) AscToLong(szArg);
            seWriteRegByte(dwIdx, val);
            printf( "\n      [%lX] < %02X", dwIdx, val );
            break;
         }

      return;
      }
}

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

/*
**
*/
#if defined(INTEL_W32) || defined(INTEL_DOS)
void CalcVndp(unsigned regVndp)
   {
   time_t StartTime, EndTime, CurrentTime;
   int state;
   unsigned RegVndp;
   int VndpCount;
   int FrameRate;
   unsigned regDisplayMode;
   unsigned regPanelType;
   unsigned regLcdMisc;
   char szVndp[10];

   enum
      {
      SEARCH_FOR_HIGH_TO_LOW,
      SEARCH_FOR_LOW_TO_HIGH
      };


   switch (regVndp)
      {
      case REG_LCD_VNDP:
      default:
         strcpy(szVndp, "LCD");
         regVndp = REG_LCD_VNDP;
         break;

      case REG_CRTTV_VNDP:
         strcpy(szVndp, "CRT/TV");
         break;
      }

   printf("\nCounting %s VNDP cycles...\n\n", szVndp);

   state = SEARCH_FOR_LOW_TO_HIGH;
   VndpCount = 0;

   /*
   ** Give Windows time to display message before freezing windows.
   */
   seDelay(1);
   seBeginHighPriority();

   time(&StartTime);

   /*
   ** Wait until this current second is completed
   */
   do
      time(&CurrentTime);
   while (StartTime == CurrentTime);


   StartTime = CurrentTime;

   /*
   ** Wait for a total of 5 seconds
   */
   EndTime = StartTime + 5;

   do
      {
      RegVndp = seReadRegByte(regVndp);

      switch (state)
        {
         case SEARCH_FOR_HIGH_TO_LOW:
            if (!(RegVndp & 0x80))
               state = SEARCH_FOR_LOW_TO_HIGH;
            break;

         case SEARCH_FOR_LOW_TO_HIGH:
            if (RegVndp & 0x80)
               {
               state = SEARCH_FOR_HIGH_TO_LOW;
               ++VndpCount;
               time(&CurrentTime);
               }
            break;
         }
      }
   while (CurrentTime < EndTime);

   seEndHighPriority();

   printf("%s VNDP cycles:   %u\n", szVndp, VndpCount);
   printf("%s Time Interval: %u\n", szVndp, 5);

   regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);
   regPanelType = seReadRegByte(REG_PANEL_TYPE);
   regLcdMisc = seReadRegByte(REG_LCD_MISC);

   /*
   ** If dual panel buffer is used, double the frame rate.
   */
   if (regVndp == REG_LCD_VNDP)
      {
      if ( (regDisplayMode & LCD) &&   /* LCD enabled */
           (regPanelType & 0x02) &&    /* dual panel */
          !(regLcdMisc & 0x01) )       /* dual panel buffer enabled */
         FrameRate = (VndpCount * 2) / 5;
      else
         FrameRate = VndpCount / 5;
      }
   else
      FrameRate = VndpCount / 5;

   printf("%s Frame Rate:    %uHz\n", szVndp, FrameRate);

   return;
}


/*
** HandleVndp()
*/
void HandleVndp( PCHAR szArg )
   {
   unsigned regDisplayMode;

   if (FALSE != FindNextArg( &szArg ))
      {
      DISPLAY_WHAT;
      return;
      }

   regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);

⌨️ 快捷键说明

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