📄 cc_tw88.c
字号:
}
else if( CC_control_byte1==0x12 || CC_control_byte1==0x13 ) { // Extended Char
//ljy010904...CC_ADD_EXTCHAR...ExtendedChar(CC_control_byte2);
ExtendedChar(CC_control_byte1, CC_control_byte2); //ljy010904...CC_ADD_EXTCHAR
}
else if( CC_control_byte1 == 0x17 ) { // Tab or Optional
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPrintf("\r\n[...Tab or Optional BG/CH color or Closed Group Extension <%02bx>...]", CC_control_byte2);
#endif
switch( CC_control_byte2 ) {
case 0x23: ProcessTab(); // tab3
case 0x22: ProcessTab(); // tab2
case 0x21: ProcessTab(); // tab1
break;
#ifdef SUPPORT_ENRICHED_CC
case 0x2d:
// transparent BG color
//if( DebugTypeCCEDS>=BASIC )
// dPrintf("\r\n[...Optional BG color: transparent...]");
CC_attr = BG_COLOR_TRANS | ( CC_attr & CH_COLOR_MASK );
break;
case 0x2e:
case 0x2f:
//if( DebugTypeCCEDS>=BASIC )
// dPrintf("\r\n[...Optional CH color: black...]");
CC_attr = CH_COLOR_BLACK | ( CC_attr & BG_COLOR_MASK );
break;
#endif
}
;
}
else if( CC_control_byte1 == 0x11 ) { //Midrow
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPrintf("\r\n[...Midrow: %s...]", CCAttrStr[(CC_control_byte2 & 0x0e)>>1]);
#endif
CopyPrintableCCDataToOSD( ' ', 0 ); // HHY 7/15/05 Put space between color
//Color.................................................................
CC_attr = GetCCColor(CC_control_byte2 & 0x0e);
// Italics and Underline................................................
{
BYTE italics=0, underline=0;
if( (CC_control_byte2 & 0x1e) == 0x0e ) italics = 1; // HHY 04/19/05
if( (CC_control_byte2 & 0x01) == 0x01 ) underline = 1; // HHY 04/19/05
SetOSDItalicsAndUnderline(italics, underline);
#ifdef DEBUG_CCEDS
dPrintf("\r\nMidrow Italic=%bd Underline=%bd", italics, underline);
#endif
}
}
else if( CC_control_byte1==0x14 || CC_control_byte1==0x15) { //Misc
//Misc
switch( CC_control_byte2 ) {
case 0x20: // Pop-On mode(row1-4 or row12-15):Resume caption loading
StartPopOnMode();
break;
case 0x21: // backspace
BackspaceToOSD();
break;
case 0x22:
case 0x23: // reserved
break;
case 0x24: // delete to end of row
DeleteEndOfRow();
break;
case 0x25: // Roll-Up mode: 2rows(row14-15)
case 0x26: // Roll-Up mode: 3rows(row13-15)
case 0x27: // Roll-Up mode: 4rows(row12-15)
StartRollUpMode(CC_control_byte2);
break;
case 0x28: // Flash On
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPuts("\r\n[...Falsh On...]");
#endif
CC_attr |= CH_BLINK;
break;
case 0x29: // Paint-On mode:Resume Direct Captioning.
StartPaintOnMode();
break;
case 0x2a:
case 0x2b: // Text mode
StartTextMode();
break;
case 0x2C: // Erase displayed memory
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPuts("\r\n[...Erase displayed memory...]");
#endif
EraseDisplayedMemory();
break;
case 0x2d: // Carrige return
if( !IsUnwantedMode() )
CarriageReturn();
break;
case 0x2E: // Pop-On mode:erase nondisplayed memory
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPuts("\r\n[...Erase nondisplayed Memory...]");
#endif
EraseNonDisplayedMemory(); //ljy011404...CC_FIX_PAUSED_PAINTON
break;
case 0x2F: // Pop-On mode:end of caption. Start to display
StartToDisplay();
break;
}
}
}
else if( CC_control_byte2 >= 0x30 && CC_control_byte2 <= 0x3f ) { // Special chars.
if( CC_control_byte1==0x12 || CC_control_byte1==0x13 ) { // Extended Char
//ljy010904...CC_ADD_EXTCHAR...ExtendedChar(CC_control_byte2);
ExtendedChar(CC_control_byte1, CC_control_byte2); //ljy010904...CC_ADD_EXTCHAR
}
else {
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPuts("\r\n[...Special chars...]");
#endif
//==============================
SaveCCEDSData();
//==============================
CopyPrintableCCDataToOSD( SpecialCharToPrintable( CC_control_byte2 ), 0 );
}
}
else if( CC_control_byte2 >= 0x40 && CC_control_byte2 <= 0x7f ) { //Preamble
PreambleCode(CC_control_byte1, CC_control_byte2);
}
ClearCCControl();
return ret;
}
//=================================================================================================
//
//=================================================================================================
BYTE IsFullCCEDSDataBuf(void)
{
return ( CCEDSDataBuf_front == CCEDSDataBuf_rear ? 1 : 0 );
}
BYTE IsEmptyCCEDSDataBuf(void)
{
BYTE new_front, ret;
new_front = ( CCEDSDataBuf_front + 1 ) % MAX_CCEDS_BUF;
if( new_front==CCEDSDataBuf_rear ) ret= 1;
else ret=0;
return ret;
}
BYTE ReadCCEDSData(BYTE *cc_status, BYTE *cc_data)
{
*cc_status = GetCCStatus();
if( !( (*cc_status) & 0x04 ) ) { // Data is NOT available.........
return 0;
}
// Data is available.........................................................
*cc_data = GetCCData() & 0x7f; // extract parity bit
if( (*cc_status) & 0x08 ) { // overflow ?----------------
#ifdef DEBUG_CCEDS
ePrintf("\r\nf?:%02x[xx]:O(%d) ", (WORD)*cc_status, (WORD)CCAction);
ePrintf("--Prev CCAction:%d", (WORD)CCAction);
ePrintf("--Buf_front:%d, Buf_rear:%d", (WORD)CCEDSDataBuf_front, (WORD)CCEDSDataBuf_rear);
#endif
RecoverCCOverflow();
return 0xff;
}
if( CC_remove_pair ) {
CC_remove_pair = 0;
return 0xfc;
}
if( (*cc_status) & 0x10 ) { // parity error?
#ifdef DEBUG_CCEDS
dPrintf("\r\nf?:%02x[%02x]:P ", (WORD)*cc_status, (WORD)*cc_data);
#endif
if( !HIGHBYTE_DATA )
CC_remove_pair = 1;
return 0xfe; // Throw away.
}
if( (*cc_data)==0 ) { // LOW byte data ? 0
if( !HIGHBYTE_DATA ) {
CC_remove_pair = 1;
return 0xfd;
}
}
return 1;
}
//=================================================================================================
//
//=================================================================================================
BYTE DoesCCFlagNeedDataFor( BYTE field)
{
switch( CCFLAG ) {
case CC_CC1:
case CC_CC2:
case CC_T1:
case CC_T2:
return (field==FIELD1 ? 1 : 0);
case CC_CC3:
case CC_CC4:
case CC_T3:
case CC_T4:
return (field==FIELD2 ? 1 : 0);
}
return 0;
}
//=================================================================================================
// Save CC/EDS data from FIFO to buffer
//=================================================================================================
void SaveCCEDSData(void)
{
BYTE cc_status, cc_data, res;
while(1) {
if( IsFullCCEDSDataBuf() ) {
#ifdef DEBUG_CCEDS
ePuts("#");
#endif
return;
}
res = ReadCCEDSData(&cc_status, &cc_data);
if( res==1 ) {
// valid data..................................................................
if(
( IsField1Data(cc_status) && DoesCCFlagNeedDataFor(FIELD1) ) ||
( !IsField1Data(cc_status) &&
( DoesCCFlagNeedDataFor(FIELD2)
//|| GetTVRating() || GetMPAARating()
|| EnabledVChip()
) )
) {
CCEDSStatusBuf[CCEDSDataBuf_rear] = cc_status;
CCEDSDataBuf[CCEDSDataBuf_rear] = cc_data;
CCEDSDataBuf_rear = ( CCEDSDataBuf_rear + 1 ) % MAX_CCEDS_BUF;
}
}
else if( res==0 )
return;
}
}
//=================================================================================================
//
//=================================================================================================
void InitClosedCaption_TW88(void)
{
BYTE i;
SetDisplayedOSD( CC );
//Initialize for OSD
CC_attr = CH_COLOR_WHITE|BG_COLOR_BLACK;
for(i=CCWIN1; i<=CCWIN4; i++) {
CCWinInfo[i].Row = 0;
CCWinInfo[i].Cnt = 0;
CCWinInfo[i].Tab = 0;
}
if ( CCFLAG==CC_CC1 || CCFLAG==CC_CC2 || CCFLAG==CC_T1 || CCFLAG==CC_T2 ) EnableCC();
else if( CCFLAG==CC_CC3 || CCFLAG==CC_CC4 || CCFLAG==CC_T3 || CCFLAG==CC_T4 ) EnableEDS();
CC_control_byte1=0;
CC_control_byte2 = 0;
CCFlag |= CC_ACTIVE; // CC_active
// Clear All OSD Window Information
for( CCWin=CCWIN1; CCWin <= CCWIN4+1 ; CCWin++ ) {
CreateCCWindow(CCWin, 0, 0, 0, 1, 0, BG_COLOR_BLACK );
}
CreateTransWindow(); // For block top of scrolling
Reset_OSDColorLookup(); // Reset LUT to default
ClearBlending(); // Reset Blending color
#ifdef QVGA
WriteTW88( TW88_OSDRAMADDRHI, 0x30 ); // HHY 04/22/05 H-extend font
#else
WriteTW88( TW88_OSDRAMADDRHI, 0x10 ); // HHY 04/22/05 H-extend font
#endif
CCWin = CCWIN1; //0;
CCWinCnt = 0;
CCAction=0;
control_code_count = 0;
CCMode=0;
}
void ClearClosedCaption_TW88(void)
{
switch( CCFLAG ) {
case CC_CC1:
case CC_CC2:
case CC_T1:
case CC_T2:
DisableCC();
break;
case CC_CC3:
case CC_CC4:
case CC_T3:
case CC_T4:
//if( !( GetTVRating() || GetMPAARating() ) )
if( !EnabledVChip())
DisableEDS();
break;
}
CCFlag &= ( ~(CC_ACTIVE) ); // clear CC_ACTIVE
#ifdef DEBUG_CCEDS
dPrintf("\r\n(ClearClosedCaption)CCFlag:%d \r\n__", (WORD)CCFlag);
#endif
ClearDisplayedOSD(CC);
#ifdef DEBUG_CCEDS
Printf("\r\n++(ClearClosedCaption_TW88)++ ClearDisplayedOSD=>CC ");
#endif
WaitVSync();
ClearOSD_TW88();
InitOSDMenu(); // reset OSD window and prepare menu
Change_OSDColorLookup();
}
//=================================================================================================
//
//=================================================================================================
BYTE GetSavedCCEDSData(BYTE *cc_data)
{
CCEDSDataBuf_front = ( CCEDSDataBuf_front + 1 ) % MAX_CCEDS_BUF;
*cc_data = CCEDSDataBuf[CCEDSDataBuf_front];
return CCEDSStatusBuf[CCEDSDataBuf_front] ;
}
//=================================================================================================
//
// CC Main called by main loop
//
//=================================================================================================
void CheckCCEDS(void)
{
BYTE cc_status, cc_data;
if( GetDisplayedOSD() & MENU ) return;
DoRollUp(); //
// while ( 1 ) {
//==============================
SaveCCEDSData();
//==============================
if( !IsEmptyCCEDSDataBuf() )
cc_status = GetSavedCCEDSData(&cc_data);
else if( ReadCCEDSData(&cc_status, &cc_data) != 1) {
return;
}
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=ENHANCED1 ) {
if( IsField1Data(cc_status) )
dPrintf("\r\n-F1:%02X[%02X]", (WORD)cc_status, (WORD)cc_data);
else
dPrintf("\r\n-F2:%02X[%02X]", (WORD)cc_status, (WORD)cc_data);
}
#endif
if( !IsField1Data(cc_status) ) { //Field 2 data--CC3, CC4, T3, T4, EDS
if( !DoesCCFlagNeedDataFor(FIELD2) ) { //don't need to care about CC
#ifdef DEBUG_CCEDS
if(DebugTypeCCEDS >= ENHANCED2 )
dPuts("((Vchip--a))");
#endif
CheckVchip(cc_status,cc_data);
}
else {
if( CC_control_byte1 ) {
#ifdef DEBUG_CCEDS
if(DebugTypeCCEDS >= ENHANCED2 )
dPuts("((CC--A))");
#endif
if( !ClosedCaption(cc_status, cc_data) ) {
#ifdef DEBUG_CCEDS
if(DebugTypeCCEDS >= ENHANCED2 )
dPuts("((Vchip--A))");
#endif
CheckVchip(cc_status,cc_data);
}
}
else {
#ifdef DEBUG_CCEDS
if(DebugTypeCCEDS >= ENHANCED2 )
dPuts("((Vchip--b))");
#endif
if( ! CheckVchip(cc_status,cc_data) ) {
#ifdef DEBUG_CCEDS
if(DebugTypeCCEDS >= ENHANCED2 )
dPuts("((CC--b))");
#endif
ClosedCaption(cc_status, cc_data);
}
}
}
}
else { //Field 1 data--CC1, CC2, T1, T2
if( DoesCCFlagNeedDataFor(FIELD1) ) { // don't need to care about EDS
#ifdef DEBUG_CCEDS
if(DebugTypeCCEDS >= ENHANCED2 )
dPuts("((CC--c))");
#endif
ClosedCaption(cc_status, cc_data);
}
}
// }
}
//=================================================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -