📄 cc_tw88.c
字号:
WriteTW88(TW88_WINNUM, CCWin+i+1); //- upper window
WriteTW88(TW88_WINWIDTH, w[i]); // width
if( saH[i] != saH[i+1] )
WriteTW88(TW88_WINSADDRHI, saH[i]); // start addrH
WriteTW88(TW88_WINSADDRLO, sa[i]); // start addr
WriteTW88(TW88_WINATTR, attr[i]); // attr
ypos = GetCCWindowYbyRow( CCWinInfo[CCWin-CCWIN1].Row-i );
dat = (xpos[i]>>8) | ((ypos>>8)<<4);
WriteTW88(TW88_WINSTART_HI, dat);
WriteTW88(TW88_WINYSTART, ypos);
if( xpos[i]!=xpos[i+1] )
WriteTW88(TW88_WINXSTART, xpos[i]);
}
//=========================
//----- Prepare next row -----
ShowCCWindow( CCWin, FALSE );
CCWinInfo[CCWin-CCWIN1].Cnt = 0;
CCWinInfo[CCWin-CCWIN1].Tab = 0;
CCWinInfo[CCWin-CCWIN1].X = 0;
CCPos = 0;
CCAddr = GetNextCCAddr;
SetCCWindowW( CCWin, 0 );
SetCCWindowSA( CCWin, CCAddr );
ypos = GetCCWindowYbyRow( CCWinInfo[CCWin-CCWIN1].Row+1 );
dat = ReadTW88(TW88_WINSTART_HI) & 0x0f;
dat = dat | ((ypos>>8)<<4);
WriteTW88(TW88_WINSTART_HI, dat);
WriteTW88(TW88_WINYSTART, ypos);
//----- Start Roll Up -----
TriggerRollUpWindow( CCWin, CCWinInfo[CCWin-CCWIN1].Row+1, rollcnt, CCAddr+CC_MAX_CHARS); // bottom win, row, win cnt
}
else if( CCMode==TEXTMODE ) {
CCAddrBuf += TEXTMODE_MAXCLMS;
CCAddr = CCAddrBuf;
CCWinInfo[CCWin-CCWIN1].Row++;
if( ( CCWinInfo[CCWin-CCWIN1].Row - TEXTMODE_STARTROW )== TEXTMODE_MAXROWS ) {
//==============================
SaveCCEDSData();
//==============================
WaitVSync();
SetCCWindowSA( CCWin, GetCCWindowSA(CCWin) + TEXTMODE_MAXCLMS );
CCWinInfo[CCWin-CCWIN1].Row--;
}
}
}
void StartToDisplay(void)
{
WORD temp;
BYTE winno, i;
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPuts("\r\n[...Pop-on:end of caption. Start to display to:");
#endif
// disable all windows before display
for(winno=CCWIN1; winno<=CCWIN4; winno++)
ShowCCWindow( winno, FALSE);
CCMode = POPON;
CCAction = 3;
//==============================
SaveCCEDSData();
//==============================
WaitVSync();
if( S_CCWin<CCWIN1 || S_CCWin>CCWIN4 ) {
S_CCWin = CCWIN1; // HHY 7/15/05 to protect malfunction
#ifdef DEBUG_CCEDS
ePrintf("??? why ???");
#endif
}
for(winno=S_CCWin, i=0; i<CCWinCnt; winno= GetLowerWinIndex(winno), i++ ) {
if( CCWinInfo[winno-CCWIN1].Cnt ) {
temp = CCAddrBuf + CC_MAX_CHARS*i + CCWinInfo[winno-CCWIN1].X;
//temp = CCAddrBuf + CC_MAX_CHARS*i;// + CCWinInfo[winno-CCWIN1].X;
SetCCWindowSA( winno, temp );
SetCCWindowX( winno, CCWinInfo[winno-CCWIN1].X + CCWinInfo[winno-CCWIN1].Tab );
SetCCWindowY( winno, CCWinInfo[winno-CCWIN1].Row );
SetCCWindowW( winno, CCWinInfo[winno-CCWIN1].Cnt );
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPrintf("\r\n Win%d ", (WORD)winno);
dPrintf(" SA=%04x .X=%02bx .Row=%02bx .Cnt=%02bx",
temp, CCWinInfo[winno-CCWIN1].X, CCWinInfo[winno-CCWIN1].Row, CCWinInfo[winno-CCWIN1].Cnt );
#endif
ShowCCWindow( winno, TRUE);
}
}
EraseNonDisplayedMemory();
//CCMode = 0;
S_CCWin = 0xff;
#ifdef DEBUG_CCEDS
ePrintf("\r\n-----> Clear S_CCWin");
#endif
}
void PreambleCode(BYTE control_code, BYTE cc_data)
{
BYTE indent=0, row, i, winno;
BYTE italics=0, underline=0;
CCAction = 6;
//==============================
SaveCCEDSData();
//==============================
CC_attr = CH_COLOR_WHITE|BG_COLOR_BLACK;
// row..................................................................
row = ((control_code&0x07)<<4) | ((cc_data & 0x60) >>4);
row = GetCCRow(row);
// Indent...............................................................
if( cc_data & 0x10 ) {
indent = (cc_data & 0x0e) << 1;
}
else {
indent=0;
// Color............................................................
CC_attr = GetCCColor(cc_data & 0x0e);
}
// Italics and Underline................................................
if( (cc_data & 0x1e) == 0x0e ) italics = 1; // HHY 04/19/05
if( (cc_data & 0x01) == 0x01 ) underline = 1; // HHY 04/19/05
SetOSDItalicsAndUnderline(italics, underline);
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPrintf("\r\n[...Preamble row:%bd, attr:%s, indent:%bd...]", row, CCAttrStr[(cc_data & 0x1e)>>1], indent);
dPrintf(" Italic=%bd Underline=%bd (CCMode=%02bx)", italics, underline, CCMode);
#endif
if( CCMode==POPON || CCMode==PAINTON ) {
// if( !FoundSameRowWin( row, indent ) ) {
if( !FoundSameRowWin( row ) ) {
CCWin = GetLowerWinIndex(CCWin);
SetCCWindowColor( CCWin, CC_attr & 0xf0 ); //### // HHY 04/19/05
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPrintf("... Win%d ", (WORD)CCWin);
#endif
// create new CC Win
CCPos=0;
CCWinInfo[CCWin-CCWIN1].Cnt = 0;
CCWinInfo[CCWin-CCWIN1].Row = row;
CCWinInfo[CCWin-CCWIN1].X = indent;
CCWinInfo[CCWin-CCWIN1].Tab = 0;
CCAddr = CCAddrBuf + CC_MAX_CHARS * CCWinCnt + indent; //ljy011204...CC_FIX_INDENT
if( CCMode==PAINTON ) {
SetCCWindowW(CCWin, 0);
SetCCWindowY(CCWin, row );
SetCCWindowX(CCWin, indent );
SetCCWindowSA(CCWin, CCAddr);
}
CCWinCnt ++;
if( CCWinCnt > CCWINCNT ) {
CCWinCnt = CCWINCNT;
//S_CCWin = GetLowerWinIndex(S_CCWin);
CCAddrBuf += CC_MAX_CHARS;
}
#ifdef DEBUG_CCEDS
dPrintf("\r\n.. win%bd S_CCWin=%bd SA=%04x(%04x) ", CCWin, S_CCWin, CCAddr, GetCCWindowSA(CCWin) );
#endif
if( S_CCWin==0xff ) {
S_CCWin = CCWin;
//CCAddrBuf = CCAddr;
CCAddrBuf = CCAddr - indent;
CCWinCnt = 1;
#ifdef DEBUG_CCEDS
ePrintf("\r\n---------- 3 New S_CCWin=%bd --------", S_CCWin);
#endif
}
//SetCCWindowSA(CCWin, CCAddr);
}
else {
//Move cursor in same row
#ifdef DEBUG_CCEDS
ePrintf("\r\n----$$$$$$$----");
#endif
MoveCursorInSameRow(indent);
}
}
else if( CCMode==ROLLUP2 || CCMode==ROLLUP3 || CCMode==ROLLUP4 ) {
if( row < (CCMode-ROLLUP2+2) ) row = CCMode-ROLLUP2+2;
if( row>16 ) row=15;
CCWinInfo[CCWin-CCWIN1].X = indent;
if( CCWinInfo[CCWin-CCWIN1].Row != row ) { // check base row
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPrintf("\r\n[...Changed ROLLUP mode(%02bx) Base row:previous row=%bd...]",
CCMode-ROLLUP2+2, CCWinInfo[CCWin-CCWIN1].Row);
#endif
CCWinInfo[CCWin-CCWIN1].Row = row;
for(i=0, winno = CCWin; i<CCWinCnt; i++, row--, winno = GetUpperWinIndex(winno) ) {
SetCCWindowY(winno, row );
//Printf("\r\n+++(SetCCWindowY) winno=%bd row=%02bx", winno, row );
}
#ifdef DEBUG_CCEDS
dPuts("\r\n------------------------");
#endif
}
}
}
void ProcessTab(void)
{
// This is needed to confirm mode by mode
if( CCWinInfo[CCWin-CCWIN1].Cnt==0 ) {
CCWinInfo[CCWin-CCWIN1].Tab++;
return;
}
if( CCPos == CCWinInfo[CCWin-CCWIN1].Cnt ) // need spaces
CopyPrintableCCDataToOSD( ' ', 0 );
else { // in the middle of line
CCAddr++;
IncCCPos();
}
}
//=================================================================================================
//
//=================================================================================================
#ifdef DEBUG_CCEDS
BYTE GetDebugTypeCCEDS(void)
{
return DebugTypeCCEDS;
}
void SetDebugTypeCCEDS(BYTE newd)
{
DebugTypeCCEDS = newd;
}
#endif // DEBUG_CCEDS
//=================================================================================================
//
//=================================================================================================
void SetCCControl(BYTE dat)
{
CC_control_byte1 = dat;
}
void ClearCCControl(void)
{
CC_control_byte1 = 0;
}
//=================================================================================================
// CC Processing
//=================================================================================================
BYTE ClosedCaption(BYTE cc_status, BYTE cc_data)
{
BYTE ret = TRUE;
if( GetDisplayedOSD() & RATINGINFO ) return FALSE;
if( !( CCFlag & CC_ACTIVE ) )
return FALSE;
if( cc_data && cc_data < 0x10 ) //maybe EDS data??
return FALSE;
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=ENHANCED1 ) {
if( cc_data >= 0x10 && cc_data <= 0x1f ) {
if( IsField1Data(cc_status) ) dPrintf("\r\nF1:%02bX[%02bX]:C ", cc_status, cc_data);
else dPrintf("\r\nF2:%02bX[%02bX]:C ", cc_status, cc_data);
}
else {
if( IsField1Data(cc_status) ) dPrintf("F1:%02bX[%02bX]:c ", cc_status, cc_data);
else dPrintf("F2:%02bX[%02bX]:c ", cc_status, cc_data);
}
}
#else
if( !cc_status )
cc_status = 0;
#endif
if ( cc_data == 0 )
return ret;
// cc_data: 1st control byte ------------------------------------------------
if( cc_data < 0x20 ) {
SetCCControl(cc_data);
return ret;
}
// cc_data: 2nd control byte or printable char ------------------------------
//ljy011204...CC_FIX_PROCESS_ANOTHER_CH_DATA...especially rollup mode because CCWin!=0.
if( IsForOtherCh() ) {
if( cc_data <= 0x7f ) {
return ret; // DO NOT process printable data for another channel
}
}
if( CC_control_byte1==0 ) {
//cc_data: printable char -----------------------------------------------
//ljy011404...CC_FIX_PROCESS_ANOTHER_MODE_DATA
if( IsUnwantedMode() )
return ret;
if( cc_data <= 0x7f && CCMode /*CCWin_*/ ) {
//==============================
SaveCCEDSData();
//==============================
CopyPrintableCCDataToOSD( cc_data, 0 );
//ljy010904...CC_FIX_CLEAR_ON_TIME
SetLastCCTime();
}
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS==BASIC )
dPrintf("%c,",(WORD)cc_data);
else if ( DebugTypeCCEDS > BASIC )
dPrintf("(%c)",(WORD)cc_data);
#endif
control_code_count=0;
return ret;
}
//cc_data: 2nd control byte --------------------------------------------------
//repeated control_code.......................................................
if( control_code_count==1 && cc_data==CC_control_byte2 ) {
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPrintf("\r\n[...Repeated...]");
#endif
//need to check prev_control_byte1??
ClearCCControl();
control_code_count=0;
return ret;
}
//control_code.................................................................
if( CC_control_byte1 & CC_CHANNEL2 ) {
if( !( CCFLAG == CC_CC2 || CCFLAG == CC_CC4 || CCFLAG==CC_T2 || CCFLAG==CC_T4 ) ) {
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPuts("\r\n[...Channel2 Data -- CC2, CC4, T2, or T4...]");
#endif
//ljy011204...CC_FIX_PROCESS_ANOTHER_CH_DATA...CC_control_byte1 = 0; //ignore this data
SetForOtherCh();
//ljy011204...CC_FIX_PROCESS_ANOTHER_CH_DATA...CCWin = 0;
//ljy012004...CC_control_byte1 = 0;
return ret;
}
}
else {
if( !( CCFLAG == CC_CC1 || CCFLAG == CC_CC3 || CCFLAG==CC_T1 || CCFLAG==CC_T3 ) ) {
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPuts("\r\n[...Channel1 Data -- CC1, CC3, T1, or T3...]");
#endif
//ljy011204...CC_FIX_PROCESS_ANOTHER_CH_DATA...CC_control_byte1 = 0; //ignore this data
SetForOtherCh();
//ljy011204...CC_FIX_PROCESS_ANOTHER_CH_DATA...CCWin = 0;
//ljy012004...CC_control_byte1 = 0;
return ret;
}
}
//ljy010904...CC_FIX_CLEAR_ON_TIME
SetLastCCTime();
control_code_count=1;
CC_control_byte1 &= 0x17; //clear channel info bit
CC_control_byte2 = cc_data;
if( CC_control_byte2 >= 0x20 && CC_control_byte2 <= 0x2f ) { //Misc , optional or Midrow
if( CC_control_byte1 == 0x10 ) { //Optional
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPrintf("\r\n[...Optional BG color: %s...]", CCAttrStr[(CC_control_byte2 & 0x0e)>>1]);
#endif
#ifdef SUPPORT_ENRICHED_CC
//Background Color..................................................
CC_attr = GetCC_BColor(CC_control_byte2 & 0x0e);
#endif
SetCCWindowColor( CCWin, CC_attr & 0xf0 ); //### // HHY 04/19/05
;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -