📄 cc_tw88.c
字号:
return TRUE;
}
void MoveCursorInSameRow(BYTE indent)
{
WORD temp;
BYTE i;
//ljy082604
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPrintf("...Win%bd ", CCWin);
#endif
temp = CCWinInfo[CCWin-CCWIN1].X;
temp += CCWinInfo[CCWin-CCWIN1].Cnt;
if ( indent < CCWinInfo[CCWin-CCWIN1]. X ) {
CCPos = 0;
i = temp = CCWinInfo[CCWin-CCWIN1].X - indent;
CCWinInfo[CCWin-CCWIN1].X = indent;
CCWinInfo[CCWin-CCWIN1].Cnt += i;
if( (CCWinInfo[CCWin-CCWIN1].X+CCWinInfo[CCWin-CCWIN1].Cnt) > CC_MAX_CHARS )
CCWinInfo[CCWin-CCWIN1].Cnt = CC_MAX_CHARS - CCWinInfo[CCWin-CCWIN1].X;
temp = GetCCWindowSA(CCWin) - temp;
CCAddr = temp;
for(; i>0; i--)
CopyPrintableCCDataToOSD( ' ', 0); //CCPos and Length are changed in this routine.
CCPos = 0;
if( CCWinInfo[CCWin-CCWIN1].Cnt ) {
// temp = GetCCWindowSA(CCWin) - temp;
CCAddr = temp;
WaitVSync();
SetCCWindowW( CCWin, CCWinInfo[CCWin-CCWIN1].Cnt );
SetCCWindowSA(CCWin, temp);
SetCCWindowX( CCWin, CCWinInfo[CCWin-CCWIN1].X + CCWinInfo[CCWin-CCWIN1].Tab );
}
//ljy082604
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPrintf("...in the front(indent:%d) ", (WORD)indent);
#endif
}
else if( indent < temp ) {
CCPos = indent - CCWinInfo[CCWin-CCWIN1].X;
//ljy082604
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPrintf("...in the middle(indent:%d) ", (WORD)indent);
#endif
}
else {
CCPos = CCWinInfo[CCWin-CCWIN1].Cnt;
temp = indent - temp;
for(; temp>0; temp--)
CopyPrintableCCDataToOSD( ' ', 0); //CCPos and Length are changed in this routine.
//ljy082604
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC )
dPrintf("...in the rear(indent:%d) ", (WORD)indent);
#endif
}
}
//=================================================================================================
//
//=================================================================================================
// Changed Ram Font address by RYU
/*CODE WORD EX_CHAR[] = {
0x0c3,0x0c4,0x0c6,0x0c7, 0x0c2,0x0ae,0x120,0x121, 0x082,0x122,0x123,0x124, 0x125,0x126,0x083,0x022,
0x0af,0x0a4,0x127,0x0b0, 0x0b5,0x0bf,0x0ab,0x0b6, 0x0c0,0x0ac,0x0b7,0x0b3, 0x09f,0x0b8,0x128,0x129,
0x0b9,0x0a5,0x0c5,0x0b1, 0x09d,0x0b2,0x09e,0x0bc, 0x0a8,0x12a,0x12b,0x080, 0x12c,0x12d,0x12e,0x086,
0x0be,0x0aa,0x0c1,0x0ad, 0x12f,0x01f,0x130,0x131, 0x0c9,0x0c8,0x030,0x132, 0x133,0x134,0x135,0x136
};*/
CODE WORD EX_CHAR[] =
{
0x0c3,0x0c4,0x0c6,0x0c7, 0x0c2,0x0ae,0x100,0x101, 0x082,0x102,0x103,0x104, 0x105,0x106,0x083,0x022,
0x0af,0x0a4,0x107,0x0b0, 0x0b5,0x0bf,0x0ab,0x0b6, 0x0c0,0x0ac,0x0b7,0x0b3, 0x09f,0x0b8,0x108,0x109,
0x0b9,0x0a5,0x0c5,0x0b1, 0x09d,0x0b2,0x09e,0x0bc, 0x0a8,0x10a,0x10b,0x080, 0x10c,0x10d,0x10e,0x086,
0x0be,0x0aa,0x0c1,0x0ad, 0x10f,0x01f,0x110,0x111, 0x0c9,0x0c8,0x030,0x112, 0x113,0x114,0x115,0x116
};
WORD GetExtdCharCodeInUDFont(BYTE control_code, BYTE cc_data)
{
if( control_code==0x12 ) {
if( cc_data>=0x20 && cc_data<0x40 )
return EX_CHAR[cc_data-0x20];
}
else if( control_code==0x13 ) {
if( cc_data>=0x20 && cc_data<0x40 )
return EX_CHAR[cc_data-0x20+0x20];
}
return 0xff;
}
void ExtendedChar(BYTE control_code, BYTE cc_data)
{
WORD fnt;
fnt = GetExtdCharCodeInUDFont(control_code, cc_data);
if( fnt != 0xff ) { // Available
BackspaceToOSD();
if(fnt & 0x100)
CopyPrintableCCDataToOSD( (BYTE)fnt, 1); // RAM font
else
CopyPrintableCCDataToOSD( (BYTE)fnt, 0); // ROM font
}
#ifdef DEBUG_CCEDS
dPrintf("<*%04x> ", fnt);
if( DebugTypeCCEDS>=BASIC )
dPrintf("\r\n[...Extended Char: %02bx %02bx...]", control_code, cc_data);
#endif
}
//=================================================================================================
//
//=================================================================================================
void EraseDisplayedMemory(void)
{
BYTE i;
for(i=CCWIN1; i<= CCWIN4; i++)
ShowCCWindow(i, FALSE);
//ljy011504...CC_ADD_NONEED...if( CCMode!= POPON )
//ljy011504...CC_ADD_NONEED... CCMode = 0;
}
//ljy011404...CC_FIX_PAUSED_PAINTON
void EraseNonDisplayedMemory(void)
{
BYTE i;
//CCWin = 0;
for(i=CCWIN1; i <= CCWIN4; i++)
CCWinInfo[i-CCWIN1].Row = CCWinInfo[i-CCWIN1].Cnt = 0;
#ifdef DEBUG_CCEDS
dPrintf("\r\n(EraseNonDisplayedMemory:CCWinInfo.Cnt:0)");
#endif
}
//=================================================================================================
//
//=================================================================================================
BYTE StartPopOnMode(void)
{
CCAction = 2;
if( !( CCFLAG== CC_CC1 || CCFLAG==CC_CC2 || CCFLAG==CC_CC3 || CCFLAG==CC_CC4 ) ) {
OnUnwantedMode();
dPuts("(");
return FALSE;
}
OffUnwantedMode();
#ifdef DEBUG_CCEDS
dPuts(")");
if( DebugTypeCCEDS>=BASIC )
dPuts("\r\n[...Pop-on:resume caption loading...]");
#endif
//==============================
SaveCCEDSData();
//==============================
if( CCMode != POPON ) { //ljy011504...CC_
// Previous mode was not POPON
CCMode = POPON;
CCAddrBuf = CCAddr;
CCWinCnt = 0;
S_CCWin = GetLowerWinIndex(CCWin);
#ifdef DEBUG_CCEDS
ePrintf("\r\n---------- 1 New S_CCWin=%bd --------", S_CCWin);
#endif
}
return TRUE;
}
BYTE StartRollUpMode(WORD cc_data)
{
char i;
char curr;
CCAction = 4;
i = 2 + ( cc_data - 0x25 ); //row cnt.
if( !( CCFLAG== CC_CC1 || CCFLAG==CC_CC2 || CCFLAG==CC_CC3 || CCFLAG==CC_CC4 ) ) {
OnUnwantedMode();
dPuts("(");
return FALSE;
}
OffUnwantedMode();
#ifdef DEBUG_CCEDS
dPuts(")");
if( DebugTypeCCEDS>=BASIC )
dPrintf("\r\n[...Roll-up:%d rows...]", (WORD)i);
#endif
if( CCMode != cc_data ) {
//==============================
SaveCCEDSData();
//==============================
CCMode = cc_data; //ROLLUP2,3,4;
CCAddr =
CCAddrBuf = 0;
CCWin =
S_CCWin = ROLLUP_START_WIN;
CCWinCnt = i;
CCPos = 0;
EraseDisplayedMemory();
EraseNonDisplayedMemory();
for(curr=CCWin; i>0; i--, CCWin = GetLowerWinIndex(CCWin) ) {
SetCCWindowX( CCWin, 0 );
SetCCWindowY( CCWin, 16-i );
SetCCWindowW( CCWin, CCWinInfo[CCWin-CCWIN1].Cnt );
SetCCWindowSA( CCWin, CCAddr);
}
CCWin = GetUpperWinIndex( CCWin );
CCWinInfo[CCWin-CCWIN1].Row = 15; // save only base row. Forget about "Rows" of rest windows.
}
return TRUE;
}
//=================================================================================================
//
//=================================================================================================
BYTE StartPaintOnMode(void)
{
if( !( CCFLAG== CC_CC1 || CCFLAG==CC_CC2 || CCFLAG==CC_CC3 || CCFLAG==CC_CC4 ) ) {
OnUnwantedMode();
dPuts("(");
return FALSE;
}
OffUnwantedMode();
#ifdef DEBUG_CCEDS
dPuts(")");
if( DebugTypeCCEDS>=BASIC )
dPuts("\r\n[...Paint-on:Resume Direct Captioning...]");
#endif
// if( CCMode != PAINTON ) { //ljy011504...CC_
// Previous mode was not PAINTON
CCMode = PAINTON;
CCAddrBuf = CCAddr;
CCWinCnt = 0;
S_CCWin = GetLowerWinIndex(CCWin);
#ifdef DEBUG_CCEDS
ePrintf("\r\n---------- 2 New S_CCWin=%bd --------", S_CCWin);
#endif
// }
return TRUE;
}
//=================================================================================================
//
//=================================================================================================
BYTE StartTextMode(void)
{
BYTE i;
CCAction = 7;
if( !( CCFLAG== CC_T1 || CCFLAG==CC_T2 || CCFLAG==CC_T3 || CCFLAG==CC_T4 ) ) {
//ljy011204...CC_FIX_OVERFLOW_LINE
//ljy011304... CCMode = 0;
OnUnwantedMode();
dPuts("(");
return FALSE;
}
OffUnwantedMode();
#ifdef DEBUG_CCEDS
dPuts(")");
if( DebugTypeCCEDS>=BASIC )
dPrintf("\r\n[...Text Mode...]");
#endif
CCMode = TEXTMODE;
CCAddr = 0;
CCWin = TEXTMODE_WIN; //ljy011404...CC_ADD_TEXTMODE_WIN...;
//==============================
SaveCCEDSData();
//==============================
i = TEXTMODE_STARTROW;
CreateCCWindow(CCWin, 0, i, TEXTMODE_MAXCLMS, TEXTMODE_MAXROWS, CCAddr, BG_COLOR_BLACK);
//SetOSDHBorderWidth_TW88( CCWin+1, 12 ); // HHY 04/19/05
// Clear OSD RAM
WriteTW88(TW88_OSDRAMDATALO, BG_COLOR_BLACK|CH_COLOR_BLACK);
WriteTW88(TW88_OSDRAMDATAHI, ' ');
WriteTW88(TW88_ENABLERAM, 0x02);
while( ReadTW88(TW88_ENABLERAM) & 0x02 );
CCAddrBuf = CCAddr;
WaitVSync();
ShowCCWindow( CCWin, TRUE );
CCWinInfo[CCWin-CCWIN1].Row = TEXTMODE_STARTROW;
//
return TRUE;
}
//=================================================================================================
// This Function is called by CCEDS main loop
//=================================================================================================
bit IsNewField(void)
{
bit field;
// field = (ReadDecoder(CSTATUS) & 0x10) >> 4;
field = (ReadTW88(0x95) & 0x80 ) >> 7;
if( field==LastField ) return 0;
else {
LastField = field;
return 1;
}
}
void DoRollUp(void)
{
BYTE i, a2;
WORD v0, v;
if( lines>=CC_FONT_HEIGHT ) return;
if( !IsNewField() ) return;
P2_0 = !P2_0;
v0 = GetCCWindowYbyRow( StartRow );
for(i=0; i<WinCnt+1; i++) {
v = v0 - CC_FONT_HEIGHT*i - lines - CC_ZOOM;
WriteTW88(TW88_WINNUM, StartWin+i);
if( ( (v&0x300) != ((v+CC_ZOOM)&0x300) ) || ( lines>=CC_FONT_HEIGHT ) ) {
a2 = ReadTW88(TW88_WINSTART_HI);
WriteTW88( TW88_WINSTART_HI, (a2 & 0x0f) | ((v>>8)<<4) );
}
WriteTW88( TW88_WINYSTART, (BYTE)v );
}
lines += CC_ZOOM;
if( lines>=CC_FONT_HEIGHT ) {
WaitVSync1();
ShowCCWindow( CCWIN5, FALSE );
TurnOffTransWindow();
}
return;
}
void TriggerRollUpWindow(BYTE startwin, BYTE startrow, BYTE wincnt, WORD addr)
{
StartWin = startwin;
StartRow = startrow;
WinCnt = wincnt;
lines = 0;
addr &= 0x1ff;
EmptyTransWindow(addr);
SetCCWindowSA( CCWINTRANS1, addr );
SetCCWindowSA( CCWINTRANS2, addr );
TurnOnTransWindow( CCWINTRANS2, 0, StartRow - WinCnt - 1 ); // block upper
TurnOnTransWindow( CCWINTRANS1, 0, StartRow ); // block bottom
//Printf("\r\n____Scroll____ StartWin=%2bd StartRow=%2bd WinCnt=%bd TransRow=%2bd", StartWin, StartRow, WinCnt, StartRow - WinCnt-1 );
}
//=================================================================================================
// CR: For Roll-Up and Text mode
//=================================================================================================
void CarriageReturn(void)
{
BYTE w[5], sa[5], saH[5], attr[5];
WORD ypos, xpos[5];
BYTE rollcnt, dat;
char i;
#ifdef DEBUG_CCEDS
if( DebugTypeCCEDS>=BASIC ) {
dPrintf("\r\n[...Carriage return...]<CCWin=%bd, >", CCWin);
}
#endif
CC_attr = CH_COLOR_WHITE|BG_COLOR_BLACK;
if( CCMode==ROLLUP2 || CCMode==ROLLUP3 || CCMode==ROLLUP4 )
{
CCAction = 5;
rollcnt = CCMode - ROLLUP2 + 2;
//==============================
SaveCCEDSData();
//==============================
//----- Save and Change Window -----
for( i=0; i<rollcnt; i++ ) {
WriteTW88(TW88_WINNUM, CCWin+i); //- current window
w[i] = ReadTW88(TW88_WINWIDTH); // width
saH[i] = ReadTW88(TW88_WINSADDRHI); // start addr
sa[i] = ReadTW88(TW88_WINSADDRLO); // start addr
attr[i] = ReadTW88(TW88_WINATTR); // attr
xpos[i] = (ReadTW88(TW88_WINSTART_HI) & 0x07) << 8;
xpos[i] += ReadTW88(TW88_WINXSTART);
}
WaitVSync1();
//===== Time Critical =====
for( i=rollcnt-1; i>=0; i--) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -