📄 play.c
字号:
** is updated to point to the start of non-whitespace forming the argument.
**
** Returns:
** TRUE - if another argument is found - szArg is updated.
** FALSE - if no other arguments found - szArg is not updated.
*/
BOOL FindNextArg( char ** szArg )
{
PCHAR ptr = *szArg;
/*
** Look for the first whitespace.
*/
while (!isspace(*ptr) && (*ptr != '\0'))
ptr++;
if (*ptr == '\0')
return FALSE;
/*
** Look for the first non-whitespace.
*/
while (isspace(*ptr) && (*ptr != '\0') && (*ptr != ';'))
ptr++;
/*
** If we came to an EOL or a comment then return FALSE.
*/
if (('\0' == *ptr) || (';' == *ptr))
return FALSE;
/*
** Return TRUE if we didn't hit an EOL.
*/
*szArg = ptr;
return TRUE;
}
/*-----------------------------------------------------------------------*/
/*
** DisplayAllLutEntries()
**
** This function reads the entire internal LUT and
** diplays the results to stdout.
**
** NOTE:
** This routine reads the absolute index.
** (i.e. There is no attempt to have a read from index 0 come
** from the 0th index of the currently active LUT area)
*/
void DisplayAllLutEntries( void )
{
BYTE LUT[NUM_LUT][3];
int nIdx;
seGetLut( gDevID, &LUT[0][0], NUM_LUT );
for (nIdx = 0; nIdx < NUM_LUT; nIdx++ )
{
if ((nIdx & 3) == 0)
{
if (TRUE == ThrottleDisplay())
break;
printf( "\nL[%02X]", nIdx );
}
printf( " %02X %02X %02X",
LUT[nIdx][0], LUT[nIdx][1], LUT[nIdx][2] );
}
}
/*-----------------------------------------------------------------------*/
/*
** DisplayAllRegisters()
**
** This function reads and displays the contents of all the 13505
** control registers. No interpretation is done.
*/
void DisplayAllRegisters( void )
{
WORD wIdx;
BYTE byVal;
char szBinary[10];
char ch;
for (wIdx = 0; wIdx <= MAX_REG; wIdx++)
{
ch = (char)((wIdx & 1) ? '\t' : '\n');
if (ERR_OK == seGetReg( gDevID, wIdx, &byVal ))
{
IntToBin( (DWORD)byVal, 8, szBinary );
if ('\n' == ch)
if (TRUE == ThrottleDisplay())
break;
printf( "%c[%02X] > %02X %sb %03dt",
ch, wIdx, (WORD)byVal, szBinary, (WORD)byVal );
}
}
}
/*== Command Handlers ===================================================*/
void HandleSetFreq( PCHAR szArg )
{
DWORD freq;
/*
** Set default frequency.
*/
if (FALSE != FindNextArg(&szArg))
{
freq = atol(szArg);
if (freq > 0)
dwClkI = freq;
else
{
DISPLAY_WHAT;
return;
}
}
}
/*-------------------------------------------------------------------------*/
/*
** Completes the parsing and executes the (L)UT command.
*/
void HandleLutIO( PCHAR szArg )
{
int nIdx;
BYTE byLut[3];
/*
** Are we to dump all the LUT registers?
*/
if ('A' == toupper(*(szArg + 1)))
{
DisplayAllLutEntries();
return;
}
/*
** Otherwise ensure the command is all by itself.
*/
if (!isspace( *(szArg + 1)))
{
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 ))
{
seGetLutEntry( gDevID, nIdx, &byLut[0] );
printf( "\n L[%02X] > %02X %02X %02X",
nIdx, byLut[0], byLut[1], byLut[2] );
return;
}
/*
** We found an argument - therefore - we MUST have 3 arguments.
*/
byLut[RED] = (BYTE)AscToLong( szArg );
if (FALSE == FindNextArg( &szArg ))
{
DISPLAY_WHAT;
return;
}
byLut[GREEN] = (BYTE)AscToLong( szArg );
if (FALSE == FindNextArg( &szArg ))
{
DISPLAY_WHAT;
return;
}
byLut[BLUE] = (BYTE)AscToLong( szArg );
seSetLutEntry( gDevID, nIdx, &byLut[0] );
}
/*-----------------------------------------------------------------------*/
/*
**
*/
void HandleRegIO( PCHAR szArg )
{
int wIdx;
BYTE bVal;
char szBinary[50];
WORD wVal;
int RegSize = 1;
/*
** Are we to dump all the registers?
*/
if ('A' == toupper( *(szArg + 1) ))
{
DisplayAllRegisters();
return;
}
if ('W' == toupper ( *(szArg + 1) ))
RegSize = 2;
else
RegSize = 1;
/*
** Otherwise ensure the command is all by itself.
*/
if ((RegSize == 1) && !isspace( *(szArg + 1)))
{
DISPLAY_WHAT;
return;
}
if (FALSE == FindNextArg( &szArg ))
{
DISPLAY_WHAT;
return;
}
/*
** The only thing allowed is hex digits.
*/
if (!isxdigit(*szArg))
{
DISPLAY_WHAT;
return;
}
wIdx = (int) AscToLong( szArg );
if (wIdx > MAX_REG)
{
DISPLAY_WHAT;
return;
}
if (FALSE == FindNextArg( &szArg ))
{
switch (RegSize)
{
case 2:
if (ERR_OK == seGetWordReg(gDevID,wIdx, &wVal))
{
IntToBin( wVal, 16, szBinary );
printf( "\n [%X] > %04X %sb %3ut",
wIdx, wVal, szBinary, wVal );
}
break;
default:
if (ERR_OK == seGetReg(gDevID,wIdx, &bVal))
{
IntToBin( bVal, 8, szBinary );
printf( "\n [%X] > %02X %sb %3ut",
wIdx, bVal, szBinary, bVal );
}
break;
}
return;
}
else
{
switch (RegSize)
{
case 2:
wVal = (WORD) AscToLong(szArg);
seSetWordReg(gDevID, wIdx, wVal);
printf( "\n [%X] < %04X", wIdx, wVal );
break;
default:
bVal = (BYTE) AscToLong(szArg);
seSetReg(gDevID, wIdx, bVal);
printf( "\n [%X] < %02X", wIdx, bVal );
break;
}
return;
}
}
/*-----------------------------------------------------------------------*/
/*
**
*/
#ifdef INTEL
void HandleVndp( PCHAR szArg )
{
time_t StartTime, EndTime, CurrentTime;
int state;
BYTE RegVndp;
int VndpCount;
int FrameRate;
BYTE regDisplayMode;
BYTE regMisc;
BYTE regPanelType;
enum
{
SEARCH_FOR_HIGH_TO_LOW,
SEARCH_FOR_LOW_TO_HIGH
};
if (FALSE != FindNextArg( &szArg ))
{
DISPLAY_WHAT;
return;
}
printf("\nCounting VNDP cycles...\n\n");
state = SEARCH_FOR_LOW_TO_HIGH;
VndpCount = 0;
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
{
seGetReg(gDevID, REG_VERT_NONDISP_PERIOD, &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);
printf("VNDP cycles: %d\n", VndpCount);
printf("Time Interval: %d\n", 5);
seGetReg(gDevID, REG_DISPLAY_MODE, ®DisplayMode);
seGetReg(gDevID, REG_MISC, ®Misc);
seGetReg(gDevID, REG_PANEL_TYPE, ®PanelType);
/*
** If half frame buffer is used, double frame rate.
*/
if ( ((regDisplayMode & 0x03) == 0x01) &&
(regPanelType & 0x2) &&
!(regMisc & 0x01) )
FrameRate = (VndpCount * 2) / 5;
else
FrameRate = VndpCount / 5;
printf("Frame Rate: %dHz\n", FrameRate);
return;
}
#endif
/*-----------------------------------------------------------------------*/
void HandleFill( PCHAR szArg )
{
BOOL bDoWordWrites;
BOOL bOneArgPat;
DWORD dwOffset, dwEndOffset;
WORD wPattern;
BYTE byPattern;
char * szTmp;
bDoWordWrites = FALSE;
bOneArgPat = FALSE;
/*
** Check if there is a (W)ord modifier.
*/
if ('W' == toupper(*(szArg + 1)))
bDoWordWrites = TRUE;
/*
** 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;
wPattern = (WORD)AscToLong( szTmp );
byPattern = (BYTE)AscToLong( szTmp );
if (bDoWordWrites)
{
printf( "\n %06lX -> %06lX %04X",
dwOffset, dwEndOffset, wPattern );
if (bOneArgPat)
{
wPattern = (WORD)AscToLong( szTmp );
seWriteDisplayWords( gDevID, dwOffset, wPattern, (dwEndOffset-dwOffset+1)/2 );
}
else
{
while (dwOffset < dwEndOffset)
{
wPattern = (WORD)AscToLong( szTmp );
seWriteDisplayWords( gDevID, dwOffset, wPattern, 1 );
dwOffset+=2;
if (FALSE == FindNextArg( &szTmp ))
szTmp = szArg;
}
}
}
else
{
printf( "\n %06lX -> %06lX %02X",
dwOffset, dwEndOffset, byPattern );
if (bOneArgPat)
{
byPattern = (BYTE)AscToLong( szTmp );
seWriteDisplayBytes( gDevID, dwOffset, byPattern, dwEndOffset-dwOffset+1 );
}
else
while (dwOffset < dwEndOffset)
{
byPattern = (BYTE)AscToLong( szTmp );
seWriteDisplayBytes( gDevID, dwOffset, byPattern, 1 );
dwOffset++;
if (FALSE == FindNextArg( &szTmp ))
szTmp = szArg;
}
}
}
/*-------------------------------------------------------------------------*/
static char *szDispMode[MAX_DISP_MODE] = { "LCD", "CRT", "SIMULTANEOUS" };
void HandleInit( PCHAR szArg )
{
int DisplayMode;
int count;
int NewDisplayMode;
if (HalInfo.dwFlags & fDEFAULT_CRT)
DisplayMode = DISP_MODE_CRT;
else if (HalInfo.dwFlags & fDEFAULT_LCDCRT)
DisplayMode = DISP_MODE_LCDCRT;
else
DisplayMode = DISP_MODE_LCD;
NewDisplayMode = -1;
/*
** Check if there is a modifier for LCD, CRT, or SIMUL.
** If not, then just initialize with defaults.
*/
if (FALSE != FindNextArg(&szArg))
{
AscToUpper(szArg);
for (count = 0; count < 3; ++count)
{
/*
** Must determine whether szArg is for one of the following:
** "LCD", "CRT", or "LCD CRT" (simultaneous)
*/
if (strncmp(szArg, "LCD", 3) == 0)
{
if (NewDisplayMode == DISP_MODE_CRT)
NewDisplayMode = DISP_MODE_LCDCRT;
else
NewDisplayMode = DISP_MODE_LCD;
}
else if (strncmp(szArg, "CRT", 3) == 0)
{
if (NewDisplayMode == DISP_MODE_LCD)
NewDisplayMode = DISP_MODE_LCDCRT;
else
NewDisplayMode = DISP_MODE_CRT;
}
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -