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

📄 play.c

📁 epson 13506 driver code
💻 C
📖 第 1 页 / 共 5 页
字号:
   if (regDisplayMode & LCD)      /* LCD enabled */
      CalcVndp(REG_LCD_VNDP);

   if (regDisplayMode & (CRT | TV)) /* CRT/TV enabled */
      CalcVndp(REG_CRTTV_VNDP);

   if (!(regDisplayMode & (LCD | CRT | TV)))
      printf("ERROR: At least one of the displays must be enabled.\n");
}
#endif

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

void HandleClock( PCHAR szArg )
{
   DWORD bits;
   DWORD dwFreq;
   char *szFreq;
   int i;
   int iFreq;
   CLOCKSELECT Clock;
   int regClkChip;
   char strInvalidIFreqValue[] = "ERROR: Invalid iFreq value.\n";


   AscToUpper(szArg);

   if (szArg[1] == 'W')
      {
      HandleClockWord(szArg);
      return;
      }

   if (!strncmp(szArg, "CLKI2", 5))
      {
      Clock = CLKI2;
      regClkChip = CLK_VREG0;
      }
   else if (!strncmp(szArg, "CLKI", 4))
      {
      Clock = CLKI;
      regClkChip = CLK_MREG;
      }
   else
      {
      DISPLAY_WHAT;
      return;
      }

   /*
   ** Get frequency or "?" command
   */
   if (FALSE == FindNextArg( &szArg ))
   {
      DISPLAY_WHAT;
      return;
   }

   AscToUpper(szArg);

   if (szArg[0] == '?')
      {
      printf("\nCLKI [?] iFreq");
      printf("\nCLKI2 [?] iFreq");

      printf("\n"
             "\niFreq: integer selecting a specific frequency"
             "\n");

      printf("\nPreset Frequency Values for iFreq (CLKI/CLKI2):"
             "\n"
             "\n     Frequency   Clock Chip Word"
             "\n--------------------------------");

      gnLineCount = 8;  // for halt command (halt after a given number of lines)

      for (i = 0; i < MAX_FREQ_INDEX; ++i)
         {
         if (TRUE == ThrottleDisplay())
            return;

         _GetClockChipBits(i, CLK_VREG0, &bits, &szFreq);
         printf("\n%02u: %7s MHz     %06lXh", i, szFreq, bits);

         if (i == FREQ_FEATCLK)
            printf("   (FEATCLK)");
         }

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


   iFreq = (int) atoi(szArg);

   if (iFreq < 0)
      {
      printf("%s", strInvalidIFreqValue);
      return;
      }


   /*
   ** Program VREG0 and VREG1 (clock chip registers) for CLKI
   */
   if (_GetClockChipBits(iFreq, regClkChip, &bits, &szFreq) != ERR_OK)
      {
      printf("%s", strInvalidIFreqValue);
      return;
      }

   _ClockChipBits2Freq(bits, &dwFreq);

   /*
   ** Adjust dwFreq for three decimal places
   */
   dwFreq = dwFreq / (CLK_CHIP_FREQ_SCALE / 1000L);

   if (seSetClock(Clock, iFreq) != ERR_OK)
      {
      printf("%s", strInvalidIFreqValue);
      return;
      }

   if (Clock == CLKI)
      dwClkiFreq = dwFreq;
   else if (Clock == CLKI2)
      dwClki2Freq = dwFreq;

   printf("\nCLKI%s=%06lX (%ld.%03ld MHz)\n",
      regClkChip == CLK_MREG ? "" : "2",
      bits,
      dwFreq / 1000L,
      dwFreq - ((dwFreq / 1000L) * 1000L));

   if (iFreq == FREQ_FEATCLK)
      {
      if (Clock == CLKI)
         printf("WARNING: FEATCLK cannot be multiplexed to CLKI.\n"
                "         Clock synthesizer programmed instead.\n");
      else if (Clock == CLKI2)
         printf("FEATCLK has been multiplexed to CLKI2.\n"
                "Clock synthesizer not used for CLKI2.\n");
      }
}

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

void HandleClockWord( PCHAR szArg )
{
   DWORD bits;
   DWORD freq;
   int reg;

   static const char *szReg[8] = { "VREG0", "VREG1", "VREG2", "MREG", "PWRDWN", "N/A", "CTRL", "N/A" };

   /*
   ** We MUST have a 24 bit word
   */
   if (FALSE == FindNextArg( &szArg ))
   {
      DISPLAY_WHAT;
      return;
   }

   bits = AscToLong( szArg );


   _ClockChipBits2Freq(bits, &freq);
   reg = (int) ((bits >> 21) & 0x07);

   printf("\n%s=%06lX (%ld.%05ld MHz)\n",
      szReg[reg],
      bits,
      freq / CLK_CHIP_FREQ_SCALE,
      freq - ((freq / CLK_CHIP_FREQ_SCALE) * CLK_CHIP_FREQ_SCALE));


   if (reg == CLK_VREG2)
      reg = FEATCLK;
   else
      reg = CLK_VREG0;

   _ProgramClockChip(bits, reg);
}

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

void HandleFill( PCHAR szArg )
{
   int MemSize = 1;  /* 1 == bytes, 2 == words, 4 == dwords */
   BOOL bOneArgPat;
   DWORD dwOffset, dwEndOffset;
   DWORD dwPattern;
   int NoArguments;
   char *szTmp;

   bOneArgPat = FALSE;


   szTmp = szArg;
   if (FALSE == FindNextArg( &szTmp ))
      NoArguments = TRUE;
   else
      NoArguments = FALSE;

   /*
   ** Check if there is a WORD or DWORD modifier.
   */
   if (szTmp == &szArg[2])
      MemSize = 1;
   else if (('W' == toupper(szArg[1])) && (NoArguments || (szTmp == &szArg[3])))
      MemSize = 2;
   else if (('D' == toupper(szArg[1])) && (NoArguments || (szTmp == &szArg[3])))
      MemSize = 4;
   else
      {
      DISPLAY_WHAT;
      return;
      }

   /*
   ** We MUST have a starting offset.
   */
   if (FALSE == FindNextArg( &szArg ))
   {
      DISPLAY_WHAT;
      return;
   }
   dwOffset = AscToLong( szArg );

   /*
   ** We MUST have an ending offset.
   **
   *** Should the ability to parse out a (L)ength be made here?
   */
   if (FALSE == FindNextArg( &szArg ))
   {
      DISPLAY_WHAT;
      return;
   }
   dwEndOffset = AscToLong( szArg );

   /*
   ** For now we enforce the user to order the start and end addresses.
   */
   if (dwOffset >= dwEndOffset)
   {
      DISPLAY_WHAT;
      return;
   }

   if (dwEndOffset >= 0x200000)
      dwEndOffset = 0x1FFFFF;

   /*
   ** We MUST have a fill pattern. If word writes were specified AND
   ** the fill pattern is less than 0xFF then the byte is duplicated
   ** into the upper half of the word.
   */
   if (FALSE == FindNextArg( &szArg ))
   {
      DISPLAY_WHAT;
      return;
   }

   /*
   ** Determine if there are any more pattern arguments.
   ** We can optimize our handling of the case where there
   ** is just one argument.
   */
   szTmp = szArg;
   if (FALSE == FindNextArg( &szTmp ))
      bOneArgPat = TRUE;
   szTmp = szArg;
   dwPattern = AscToLong( szTmp );

   switch (MemSize)
   {
      /* DWORD */
      case 4:
         if (bOneArgPat)
         {
            printf( "\n       %06lX -> %06lX  %08lX", dwOffset, dwEndOffset, dwPattern );
            dwPattern = AscToLong( szTmp );
            seWriteDisplayDwords(dwOffset, dwPattern, (dwEndOffset-dwOffset+1)/4);
         }
         else
         {
            printf( "\nDWORD Pattern Fill: %06lX -> %06lX", dwOffset, dwEndOffset);

            while (dwOffset < dwEndOffset)
            {
               dwPattern = AscToLong( szTmp );
               seWriteDisplayDwords(dwOffset, dwPattern, 1);
               dwOffset += 4;
               if (FALSE == FindNextArg( &szTmp ))
                  szTmp = szArg;
            }
         }
         break;
   
      /* WORD */
      case 2:
         if (bOneArgPat)
         {
            printf( "\n       %06lX -> %06lX  %04X", dwOffset, dwEndOffset, (WORD) dwPattern );
            dwPattern = AscToLong( szTmp );
            seWriteDisplayWords(dwOffset, (WORD) dwPattern, (dwEndOffset-dwOffset+1)/2);
         }
         else
         {
            printf( "\nWORD Pattern Fill: %06lX -> %06lX", dwOffset, dwEndOffset);

            while (dwOffset < dwEndOffset)
            {
               dwPattern = AscToLong( szTmp );
               seWriteDisplayWords(dwOffset, (WORD) dwPattern, 1);
               dwOffset += 2;
               if (FALSE == FindNextArg( &szTmp ))
                  szTmp = szArg;
            }
         }
         break;
   
      /* BYTE */
      default:
      case 1:
         if (bOneArgPat)
         {
            printf( "\n       %06lX -> %06lX  %02X", dwOffset, dwEndOffset, (BYTE) dwPattern );
            dwPattern = AscToLong( szTmp );
   
            seWriteDisplayBytes(dwOffset, (BYTE) dwPattern, dwEndOffset-dwOffset+1);
         }
         else
         {
            printf( "\nBYTE Pattern Fill: %06lX -> %06lX", dwOffset, dwEndOffset);

            while (dwOffset < dwEndOffset)
            {
               dwPattern = AscToLong( szTmp );
               seWriteDisplayBytes(dwOffset, (BYTE) dwPattern, 1);
               ++dwOffset;
               if (FALSE == FindNextArg( &szTmp ))
                  szTmp = szArg;
            }
         }
         break;
   }
}

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

void DisplayHelpForRegInit(void)
{
   printf("\nI [?] {LCD|CRT|TV} [d=iCrtTv] [COMP | SVIDEO] [FLICKER=ON | OFF] - init reg"
          "\nI{C|I} {LCD|CRT|TV}   - init cursor or ink layer for given display"
          "\n"
          "\nd=iCrtTV:  integer selecting a default display combination"
          "\nCOMP:      select composite TV output"
          "\nSVIDEO:    select S-Video TV output"
          "\nFLICKER=   enable or disable flicker filter"
          "\nIC:        initialize hardware cursor"
          "\nII:        initialize ink layer");

   printf("\n"
          "\niCrtTv | Resolution   Type"
          "\n-------------------------------"
          "\n   0   | 640 x 480    CRT"
          "\n   1   | 800 x 600    CRT"
          "\n   2   | 752 x 484    TV (NTSC)"
          "\n   3   | 696 x 436    TV (NTSC)"
          "\n   4   | 640 x 480    TV (NTSC)"
          "\n   5   | 920 x 572    TV (PAL)"
          "\n   6   | 856 x 518    TV (PAL)"
          "\n   7   | 800 x 572    TV (PAL)"
          "\n   8   | 640 x 480    TV (PAL)");
}

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

   char *szDispMode[8] = {
      "NO DISPLAY",
      "LCD ONLY",
      "CRT ONLY",
      "CRT AND LCD",
      "TV WITH FLICKER FILTER OFF",
      "LCD AND TV WITH FLICKER FILTER OFF",
      "TV WITH FLICKER FILTER ON",
      "LCD AND TV WITH FLICKER FILTER ON" };

   defReg CRT640x480[] =
      {
        { REG_CRTTV_HDP,        0x4f },
        { REG_CRTTV_HNDP,       0x13 },
        { REG_CRTTV_HRTC_START, 0x01 },
        { REG_CRT_HRTC_PULSE,   0x0b },
        { REG_CRTTV_VDP1,       0x01 },
        { REG_CRTTV_VDP0,       0xdf },
        { REG_CRTTV_VNDP,       0x2b },
        { REG_CRTTV_VRTC_START, 0x09 },
        { REG_CRT_VRTC_PULSE,   0x01 },
        { REG_DISPLAY_MODE,     0x02 },  /* only bits 2-0 are used */
        { FINISHED_REG_CFG, 0 }
      };

   defReg CRT800x600[] =
      {
        { REG_CRTTV_HDP,        0x63 },
        { REG_CRTTV_HNDP,       0x1b },
        { REG_CRTTV_HRTC_START, 0x02 },
        { REG_CRT_HRTC_PULSE,   0x88 },
        { REG_CRTTV_VDP1,       0x02 },
        { REG_CRTTV_VDP0,       0x57 },
        { REG_CRTTV_VNDP,       0x18 },
        { REG_CRTTV_VRTC_START, 0x00 },
        { REG_CRT_VRTC_PULSE,   0x81 },
        { REG_DISPLAY_MODE,     0x02 },  /* only bits 2-0 are used */
        { FINISHED_REG_CFG, 0		 }
      };

   defReg NTSC752x484[] =
      {
        { REG_CRTTV_HDP,        0x5d },
        { REG_CRTTV_HNDP,       0x13 },
        { REG_CRTTV_HRTC_START, 0x02 },
        { REG_CRTTV_VDP1,       0x01 },
        { REG_CRTTV_VDP0,       0xe3 },
        { REG_CRTTV_VNDP,       0x13 },
        { REG_CRTTV_VRTC_START, 0x00 },
        { REG_TV_OUTPUT_CTRL,   0x00 },  /* only bit 0 is used */
        { REG_DISPLAY_MODE,     0x04 },  /* only bits 2-0 are used */
        { FINISHED_REG_CFG, 0		   }
      };

   defReg NTSC696x436[] =
      {
        { REG_CRTTV_HDP,        0x56 },
        { REG_CRTTV_HNDP,       0x1a },
        { REG_CRTTV_HRTC_START, 0x04 },
        { REG_CRTTV_VDP1,       0x01 },
        { REG_CRTTV_VDP0,       0xb3 },
        { REG_CRTTV_VNDP,       0x2b },
        { REG_CRTTV_VRTC_START, 0x0c },
        { REG_TV_OUTPUT_CTRL,   0x00 },  /* only bit 0 is used */
        { REG_DISPLAY_MODE,     0x04 },  /* only bits 2-0 are used */
        { FINISHED_REG_CFG, 0		   }
      };


   defReg NTSC640x480[] =
      {
        { REG_CRTTV_HDP,        0x4f },
        { REG_CRTTV_HNDP,       0x21 },
        { REG_CRTTV_HRTC_START, 0x08 },
        { REG_CRTTV_VDP1,       0x01 },
        { REG_CRTTV_VDP0,       0xdf },
        { REG_CRTTV_VNDP,       0x15 },
        { REG_CRTTV_VRTC_START, 0x01 },
        { REG_TV_OUTPUT_CTRL,   0x00 },  /* only bit 0 is used */
        { REG_DISPLAY_MODE,     0x04 },  /* only bits 2-0 are used */
        { FINISHED_REG_CFG, 0		   }
      };


   defReg PAL920x572[] =
      {
        { REG_CRTTV_HDP,        0x72 },
        { REG_CRTTV_HNDP,       0x1a },
        { REG_CRTTV_HRTC_START, 0x02 },
        { REG_CRTTV_VDP1,       0x02 },
        { REG_CRTTV_VDP0,       0x3b },
        { REG_CRTTV_VNDP,       0x19 },
        { REG_CRTTV_VRTC_START, 0x00 },
        { REG_TV_OUTPUT_CTRL,   0x01 },  /* only bit 0 is used */
        { REG_DISPLAY_MODE,     0x04 },  /* only bits 2-0 are used */
        { FINISHED_REG_CFG, 0		   }
      };

   defReg PAL856x518[] =
      {
        { REG_CRTTV_HDP,        0x6a },
        { REG_CRTTV_HNDP,       0x22 },
        { REG_CRTTV_HRTC_START, 0x05 },
        { REG_CRTTV_VDP1,       0x02 },
        { REG_CRTTV_VDP0,       0x05 },
        { REG_CRTTV_VNDP,       0x34 },
        { REG_CRTTV_VRTC_START, 0x0d },
        { REG_TV_OUTPUT_CTRL,   0x01 },  /* only bit 0 is used */
        { REG_DISPLAY_MODE,     0x04 },  /* only bits 2-0 are used */
        { FINISHED_REG_CFG, 0		   }
      };

   defReg PAL800x572[] =
      {
        { REG_CRTTV_HDP,        0x63 },
        { REG_CRTTV_HNDP,       0x29 },
        { REG_CRTTV_HRTC_START, 0x09 },
        { REG_CRTTV_VDP1,       0x02 },
        { REG_CRTTV_VDP0,       0x3b },
        { REG_CRTTV_VNDP,       0x19 },
        { REG_CRTTV_VRTC_START, 0x00 },
        { REG_TV_OUTPUT_CTRL,   0x01 },  /* only bit 0 is used */
        { REG_DISPLAY_MODE,     0x04 },  /* only bits 2-0 are used */
        { FINISHED_REG_CFG, 0		   }
      };

   defReg PAL640x480[] =
      {
        { REG_CRTTV_HDP,        0x4f },
        { REG_CRTTV_HNDP,       0x3d },
        { REG_CRTTV_HRTC_START, 0x13 },
        { REG_CRTTV_VDP1,       0x01 },
        { REG_CRTTV_VDP0,       0xdf },
        { REG_CRTTV_VNDP,       0x47 },
        { REG_CRTTV_VRTC_START, 0x16 },
        { REG_TV_OUTPUT_CTRL,   0x01 },  /* only bit 0 is used */
        { REG_DISPLAY_MODE,     0x04 },  /* only bits 2-0 are used */
        { FINISHED_REG_CFG, 0		   }
      };

   defReg *Reg[] =
      { CRT640x480,
        CRT800x600,
        NTSC752x484,
        NTSC696x436,
        NTSC640x480,
        PAL920x572,
        PAL856x518,
        PAL800x572,
        PAL640x480
      };

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

void DisplayBadConfiguration(unsigned DisplayMode)
{
   char str[10];

   if (DisplayMode & LCD)
      strcpy(str, "LCD");

⌨️ 快捷键说明

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