📄 play.c
字号:
printf("\n\nTyping \"M bpp\" will change the bits-per-pixel mode.");
printf("\nbpp: integer selecting 1, 2, 4, 8, or 16\n");
return;
}
else
{
bpp = atoi(&szArg[0]);
if ((bpp != 1) && (bpp != 2) && (bpp != 4) && (bpp != 8) && (bpp != 16))
{
DISPLAY_WHAT;
return;
}
result = seSetMode(bpp);
if (result == ERR_NOT_ENOUGH_MEMORY)
{
printf("ERROR: Not enough memory in %d bits-per-pixel.\n",bpp);
return;
}
if (result == ERR_FAILED)
{
printf("ERROR: Invalid bpp value.\n");
return;
}
}
return;
}
/*
** Get mode infomation by reading and interpreting registers.
*/
/*
** "MainWin Orientation: LANDSCAPE, SWIVELVIEW 90, SWIVELVIEW 180, SWIVELVIEW 270"
*/
printf("\nMainWin Orientation: ");
val = regSpecialEffects & 0x3;
switch (val)
{
case 0:
default:
printf("Landscape");
break;
case 1:
printf("SwivelView 90 Degrees");
break;
case 2:
printf("SwivelView 180 Degrees");
break;
case 3:
printf("SwivelView 270 Degrees");
break;
}
HaltDisplay();
/*
** i.e. "CLKI: 25.175 MHz"
*/
wSrcClk_Int = (WORD) (dwClkiFreq / 1000);
wSrcClk_Frac = (WORD) (dwClkiFreq - (wSrcClk_Int * 1000));
printf("\nCLKI: %u.%03u MHz", wSrcClk_Int, wSrcClk_Frac);
HaltDisplay();
/*
** i.e.: "CLKI2: 17.734 MHz"
*/
wSrcClk_Int = (WORD) (dwClki2Freq / 1000);
wSrcClk_Frac = (WORD) (dwClki2Freq - (wSrcClk_Int * 1000));
printf("\nCLKI2: %u.%03u MHz", wSrcClk_Int, wSrcClk_Frac);
HaltDisplay();
/*
** i.e.: "BUSCLK: 8.000 MHz"
*/
wSrcClk_Int = (WORD) (dwBusClkFreq / 1000);
wSrcClk_Frac = (WORD) (dwBusClkFreq - (wSrcClk_Int * 1000));
if ( regBclkMclkCfg & 1 )
printf("\nBUSCLK: %u.%03u MHz (=CLKI2)", wSrcClk_Int, wSrcClk_Frac);
else
{
printf("\nBUSCLK: %u.%03u MHz (=CLKI/%d)", wSrcClk_Int, wSrcClk_Frac, ClkItoBclkDiv+1);
if ( dwBusClkFreq != dwClkiFreq/(ClkItoBclkDiv+1) )
printf("\n Error: BUSCLK divide from 13706CFG doesn't match CNF[7:6]!");
}
HaltDisplay();
/*
** i.e.: "MCLK: 8.000 MHz (=BCLK/1)"
*/
val = (regBclkMclkCfg & 0x30)>>4;
printf("\nMCLK: %u.%03u MHz (=BCLK/%d)", wSrcClk_Int, wSrcClk_Frac, (val+1));
HaltDisplay();
/*
** i.e.: "PCLK: 8.000 MHz (=MCLK)" "
*/
wSrcClk_Int = (WORD) (dwPClkFreq / 1000);
wSrcClk_Frac = (WORD) (dwPClkFreq - (wSrcClk_Int * 1000));
printf("\nPCLK: %d.%d MHz (=", wSrcClk_Int, wSrcClk_Frac);
switch ( regPClkCfg & 0x3 )
{
case 0:
printf("MCLK");
break;
case 1:
printf("BCLK");
break;
case 2:
printf("CLKI");
break;
case 3:
printf("CLKI2");
break;
}
printf("/%d)",PclkDiv);
HaltDisplay();
/*
** i.e.: "Frame Rate: 75 Hz "
*/
wSrcClk_Int = (WORD) (dwFrameRate / 10);
wSrcClk_Frac = (WORD) (dwFrameRate - (wSrcClk_Int * 10));
printf("\nFrame Rate: ");
sprintf(str, "%u.%d Hz", wSrcClk_Int, wSrcClk_Frac);
printf("%-15s", str);
HaltDisplay();
/*
** i.e.: "Display Type: Single 8-bit Color TFT ---"
*/
printf("\nDisplay Type: ");
if ((regPanelType & 1) || ((regPanelType&3)==2) )
pWidth = szWidthTFT[(regPanelType>>4) & 3];
else
pWidth = szWidthSTN[(regPanelType>>4) & 3];
sprintf(str, "Single %s-bit %s %s %s",
pWidth,
szMonoColor[(regPanelType >> 6) & 1],
szSTNTFT[regPanelType & 3],
szFormat2[(regPanelType&0x80)>>7] );
printf("%s", str);
HaltDisplay();
/*
** i.e.: "Dithering: Enabled"
*/
printf("\nDithering: %s",szDisabled[(regDispMode & 0x40)>>6]);
HaltDisplay();
/*
** i.e.: "Display Blank: Not Blanked "
*/
printf("\nDisplay Blank: ");
if (regDispMode & 0x80)
printf("Blanked");
else
printf("Not Blanked");
HaltDisplay();
/*
** i.e.: "H/W Video Invert: Disabled"
*/
printf("\nH/W Video Invert: %s", szEnabled[(regDispMode & 0x20)>>5] );
HaltDisplay();
/*
** i.e.: "S/W Video Invert: Disabled"
*/
printf("\nS/W Video Invert: %s", szEnabled[(regDispMode & 0x10)>>4] );
HaltDisplay();
/* ie.: Sub-Window (x1,y1,x2,y2): Enabled */
sprintf(str, "Sub-Window (Start:%dt %dt End:%dt %dt): %s", x1, y1, x2, y2,szEnabled[(regSpecialEffects&0x10)>>4] );
printf("\n%-15s", str);
HaltDisplay();
printf( "\n");
HaltDisplay();
#ifdef LINEAR_ADDRESSES_SUPPORTED
printf( "\nRegister Linear Address: %08lX"
"\nDisplay Linear Address: %08lX",
seGetLinearRegAddress(), seGetLinearDisplayAddress());
#endif
HaltDisplay();
HaltDisplay();
printf("\n");
HaltDisplay();
printf("\n MainWin Parameters SubWin Parameters");
HaltDisplay();
printf("\n-----------------------------------------------------------");
HaltDisplay();
/*
** i.e.: "Resolution: 640 x 480 x 8 bpp 200 x 100 x 8 bpp"
*/
printf("\nResolution: ");
sprintf(str, "%u x %u x %u bpp", Width, Height, MainWinBpp);
printf("%-23s ", str);
sprintf(str, "%u x %u x %u bpp", SubWinWidth, SubWinHeight, SubWinBpp);
printf("%s", str);
HaltDisplay();
/*
** i.e.: "Virtual Width: 640 640"
*/
printf("\nVirtual Width: ");
HaltDisplay();
/*
** Convert from dwords to bytes
*/
VirtWidth = seReadRegWord(REG_MAIN_WIN_ADDR_OFFSET0) * 4;
SubWinVirtWidth = seReadRegWord(REG_SUB_WIN_ADDR_OFFSET0) * 4;
switch (MainWinBpp)
{
case 1:
VirtWidth *= 8;
SubWinVirtWidth *= 8;
break;
case 2:
VirtWidth *= 4;
SubWinVirtWidth *= 4;
break;
case 4:
VirtWidth *= 2;
SubWinVirtWidth *= 2;
break;
case 8:
default:
break;
case 16:
VirtWidth /= 2;
SubWinVirtWidth /= 2;
break;
}
printf("%-10lu ", VirtWidth); //in pixels
printf("%lu", SubWinVirtWidth);
HaltDisplay();
/*
** i.e.: "Bytes/Line: 640 "
*/
printf("\nBytes/Line: %-10u ", seGetMainWinBytesPerScanline());
printf("%u", seGetSubWinBytesPerScanline());
HaltDisplay();
/*
** i.e.: "Start Addr: 1FF000-1FFFFF "
*/
regMainWinStartAddr = seReadRegDword(REG_MAIN_WIN_DISP_START_ADDR0);
regSubWinStartAddr = seReadRegDword(REG_SUB_WIN_DISP_START_ADDR0);
printf("\nStart Address: %05lX %05lX\n",
regMainWinStartAddr*4, regSubWinStartAddr*4 );
}
/*-----------------------------------------------------------------------*/
/*
** SetDisplayHalt()
**
** This function is called to set the number of lines to display before
** HaltDisplay() halts the output.
*/
void SetDisplayHalt( PCHAR szArg )
{
int nTmp;
if (TRUE == FindNextArg( &szArg ))
{
nTmp = (int)AscToLong( szArg );
gnHaltCount = nTmp;
}
printf("\nCurrent Halt setting: %d lines", gnHaltCount);
}
//double checked the following with Barton's current HAL Lib.
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_MREG;
}
else if (!strncmp(szArg, "CLKI", 4))
{
Clock = CLKI;
regClkChip = CLK_VREG0;
}
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: an index to select a specific frequency\n");
printf("\nPreset Frequency Values for iFreq (CLKI|CLKI2):\n");
printf("\niFreq Frequency Clock Chip Word");
printf("\n--------------------------------");
gnLineCount = 8; // for halt command (halt after a given number of lines)
for (i = 0; i < MAX_FREQ_INDEX; ++i)
{
if (TRUE == HaltDisplay())
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 (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_VREG0 ? "" : "2",
bits,
dwFreq / 1000L,
dwFreq - ((dwFreq / 1000L) * 1000L));
}
/*-------------------------------------------------------------------------*/
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));
reg = CLK_VREG0;
_ProgramClockChip(bits, reg);
}
void HandleTest( PCHAR szArg )
{
long i=0;
long Seconds, LoopCount;
if (FALSE == FindNextArg( &szArg ))
{
LoopCount = 90000000;
printf("\n Reading VNDP status bit for about 1 minute ...\n");
}
else
{
Seconds = AscToLong( szArg );
LoopCount = (Seconds * 90000000)/60;
printf("\n Reading VNDP status bit for about %ld seconds ...\n", Seconds);
}
while ( i<LoopCount )
{
seReadRegByte(REG_POWER_SAVE_CONFIG);
i++;
}
}
/*-----------------------------------------------------------------------*/
// Read word without swapping bytes if endian of system is big-endian.
unsigned ReadRegWord(DWORD index)
{
#ifndef LINEAR_ADDRESSES_SUPPORTED
return seReadRegWord(index);
#else
return *((volatile LPWORD) (regLinearAddr + index));
#endif //LINEAR_ADDRESSES_SUPPORTED
}
/*-----------------------------------------------------------------------*/
// Write word without swapping bytes if endian of system is big-endian.
void WriteRegWord(DWORD index, unsigned value)
{
#ifndef LINEAR_ADDRESSES_SUPPORTED
seWriteRegWord(index, value);
#else
*((LPWORD) (regLinearAddr + index)) = (WORD) value;
#endif //LINEAR_ADDRESSES_SUPPORTED
}
/*-------------------------------------------------------------------------*/
// Read dword without swapping bytes if endian of system is big-endian.
DWORD ReadRegDword(DWORD index)
{
#ifndef LINEAR_ADDRESSES_SUPPORTED
return seReadRegDword(index);
#else
return *((volatile LPDWORD) (regLinearAddr + index));
#endif //LINEAR_ADDRESSES_SUPPORTED
}
/*-------------------------------------------------------------------------*/
// Write dword without swapping bytes if endian of system is big-endian.
void WriteRegDword(DWORD index, DWORD value)
{
#ifndef LINEAR_ADDRESSES_SUPPORTED
seWriteRegDword(index, value);
#else
*((LPDWORD) (regLinearAddr + index)) = value;
#endif //LINEAR_ADDRESSES_SUPPORTED
}
/*-------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -