📄 play.c
字号:
// Get the fill pattern.
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 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 HandleRead( PCHAR szArg )
{
int MemSize = 1; /* 1 == bytes, 2 == words, 4 == dwords */
DWORD dwOffset;
DWORD dwLength;
DWORD count;
unsigned val;
DWORD dwVal;
int NoArguments;
char *szTmp;
char str[20];
AscToUpper(szArg);
dwLength = 16;
count = 0;
memset(str, 0, sizeof(str));
szTmp = szArg;
if (FALSE == FindNextArg( &szTmp ))
NoArguments = TRUE;
else
NoArguments = FALSE;
/*
** Check if there is a command modifier for word or dword reads.
*/
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 an offset.
*/
if (FALSE == FindNextArg( &szArg ))
{
DISPLAY_WHAT;
return;
}
dwOffset = AscToLong( szArg );
/*
** The next argument, if there is one, is the number of
** bytes/words to read. If nothing specified then we
** will read our default length (16) bytes.
*/
if (TRUE == FindNextArg( &szArg ))
dwLength = AscToLong( szArg );
while (count < dwLength)
{
switch (MemSize)
{
/* DWORD */
case 4:
if (0 == (count & 0x3))
{
if (TRUE == HaltDisplay())
break;
printf( "\n %06lX: ", dwOffset );
}
else
if (0 == (count & 1))
printf( " -" );
dwVal = seReadDisplayDword(dwOffset);
printf( " %08lX", dwVal );
dwOffset +=4;
break;
/* WORD */
case 2:
if (0 == (count & 0x7))
{
if (TRUE == HaltDisplay())
break;
printf( "\n %06lX: ", dwOffset );
}
else
if (0 == (count & 3))
printf( " -" );
val = seReadDisplayWord(dwOffset);
printf( " %04X", val );
dwOffset +=2;
break;
/* BYTE */
default:
case 1:
if (0 == (count & 0xF))
{
if (TRUE == HaltDisplay())
break;
printf(" %s", str);
str[0] = 0;
printf( "\n %06lX: ", dwOffset );
}
else
{
if (0 == (count & 7))
printf( " -" );
}
val = seReadDisplayByte(dwOffset);
if ((val >= ' ') && (val <= 0x80))
sprintf(&str[count & 0x0f], "%c", val);
else
sprintf(&str[count & 0x0f], ".");
printf( " %02X", val );
dwOffset++;
break;
}
count++;
}
if (MemSize == 1)
printf(" %s", str);
}
/*-----------------------------------------------------------------------*/
#ifdef INCLUDE_TIME_H
void CalcVndp(unsigned regVndp)
{
time_t StartTime, EndTime, CurrentTime;
int state;
unsigned RegVndp;
int VndpCount;
int FrameRate;
enum
{
SEARCH_FOR_HIGH_TO_LOW,
SEARCH_FOR_LOW_TO_HIGH
};
printf("\nCounting VNDP cycles...\n\n");
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("VNDP cycles: %u\n", VndpCount);
printf("Time Interval: %u\n", 5);
FrameRate = VndpCount / 5;
printf("Frame Rate: %uHz\n", FrameRate);
return;
}
/*-----------------------------------------------------------------------*/
void HandleVndp( PCHAR szArg )
{
if (FALSE != FindNextArg( &szArg ))
{
DISPLAY_WHAT;
return;
}
CalcVndp(REG_POWER_SAVE_CONFIG);
}
#endif //INCLUDE_TIME_H
/*-----------------------------------------------------------------------*/
void HandleWrite( PCHAR szArg )
{
int MemSize = 1; /* 1 == bytes, 2 == words, 4 == dwords */
DWORD dwOffset;
unsigned val;
DWORD dwVal;
int NoArguments;
char *szTmp;
szTmp = szArg;
if (FALSE == FindNextArg( &szTmp ))
NoArguments = TRUE;
else
NoArguments = FALSE;
/*
** Check if there is a command modifier for Word writes.
*/
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 an offset.
*/
if (FALSE == FindNextArg( &szArg ))
{
DISPLAY_WHAT;
return;
}
dwOffset = AscToLong( szArg );
/*
** For as long as we find arguments ... write to memory.
*/
while (FindNextArg( &szArg ))
{
dwVal = AscToLong( szArg );
val = (unsigned) dwVal;
switch (MemSize)
{
/* DWORD */
case 4:
seWriteDisplayDwords(dwOffset, dwVal, 1);
dwOffset+=2;
break;
/* WORD */
case 2:
seWriteDisplayWords(dwOffset, val, 1);
dwOffset+=2;
break;
/* BYTE */
default:
case 1:
seWriteDisplayBytes(dwOffset, val, 1);
dwOffset++;
break;
}
}
}
/*-----------------------------------------------------------------------*/
static char * szSTNTFT[] = { "STN", "TFT", "HR-TFT", "D-TFD" };
static char * szMonoColor[] = { "Mono", "Color" };
static char * szWidthSTN[] = { "4", "8", "16", "*ERR*" };
static char * szWidthTFT[] = { "9", "12", "18", "*ERR*" };
static char * szFormat2[] = { "" , "Format 2" };
static char * szEnabled[] = { "Disabled", "Enabled" };
static char * szDisabled[] = { "Enabled", "Disabled" };
/*
** HandleModeSet()
*/
void HandleModeSet( PCHAR szArg )
{
unsigned MainWinBpp, Width, Height, SubWinBpp, SubWinWidth, SubWinHeight;
char* pWidth;
unsigned regBclkMclkCfg, regPClkCfg, regPanelType, regDispMode;
unsigned regSpecialEffects;
unsigned long regMainWinStartAddr, regSubWinStartAddr;
unsigned x1, y1, x2, y2;
DWORD HTotal, VTotal, dwFrameRate;
DWORD dwPClkFreq=0;
unsigned long VirtWidth, SubWinVirtWidth;
int bpp, PclkDiv, ClkItoBclkDiv, result;
static char str[80];
WORD wSrcClk_Int, wSrcClk_Frac;
unsigned val;
AscToUpper(szArg);
seGetMainWinResolution(&Width, &Height);
seGetSubWinResolution(&SubWinWidth, &SubWinHeight);
MainWinBpp = seGetBitsPerPixel();
SubWinBpp = MainWinBpp;
ClkItoBclkDiv = seReadRegByte(0x02)>>6; //read in the status of CNF[7:6]
regBclkMclkCfg = seReadRegByte(REG_BUSCLK_MEMCLK_CONFIG);
regPClkCfg = seReadRegByte(REG_PCLK_CONFIG);
regPanelType = seReadRegByte(REG_PANEL_TYPE);
regDispMode = seReadRegByte(REG_DISPLAY_MODE);
regSpecialEffects = seReadRegByte(REG_SPECIAL_EFFECTS);
x1 = seReadRegWord(REG_SUB_WIN_X_START_POS0);
y1 = seReadRegWord(REG_SUB_WIN_Y_START_POS0);
x2 = seReadRegWord(REG_SUB_WIN_X_END_POS0);
y2 = seReadRegWord(REG_SUB_WIN_Y_END_POS0);
if (regSpecialEffects&1) //SwivelView 90 or 270 degree
{
y1 = y1 * 32/MainWinBpp;
y2 = (y2+1)*32/MainWinBpp-1;
}
else //normal or 180 degree
{
x1 = x1 * 32/MainWinBpp;
x2 = (x2+1)*32/MainWinBpp -1;
}
HTotal = (seReadRegByte(REG_HORIZ_TOTAL) + 1) * 8;
VTotal = seReadRegByte(REG_VERT_TOTAL0) + (seReadRegByte(REG_VERT_TOTAL1)<<8) + 1;
//we first have to calculate dwPclkFreq here
switch ( regPClkCfg & 0x3 )
{
case 0:
dwPClkFreq = dwBusClkFreq/( ((regBclkMclkCfg & 0x30)>>4) + 1 );
break;
case 1:
dwPClkFreq = dwBusClkFreq; //this bus clock from 13706cfg already considered CNF divide pin
break;
case 2:
dwPClkFreq = dwClkiFreq;
break;
case 3:
dwPClkFreq = dwClki2Freq;
break;
}
switch ( (regPClkCfg & 0x70)>>4 )
{
case 0:
PclkDiv = 1;
break;
case 1:
dwPClkFreq = dwPClkFreq/2;
PclkDiv = 2;
break;
case 2:
dwPClkFreq = dwPClkFreq/3;
PclkDiv = 3;
break;
case 3:
dwPClkFreq = dwPClkFreq/4;
PclkDiv = 4;
break;
case 4:
default:
dwPClkFreq = dwPClkFreq/8;
PclkDiv = 8;
break;
}
dwFrameRate = ((DWORD) dwPClkFreq * 10000L) / (HTotal * VTotal); //Actual Hz *10
/*
** If there is an argument for the pixel depth then set the mode.
*/
if (TRUE == FindNextArg( &szArg ))
{
if ('?' == szArg[0])
{
printf("\nM [?] [bpp]");
printf("\n\nThis command will get or set the pixel mode.");
printf("\n\nTyping \"M\" will display detailed hardware information (see note below).");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -