📄 tw88.lst
字号:
1154 1 #ifdef DEBUG_PC
1155 1 dPrintf("\r\n === SetVBackPorch(%d)", (WORD)val);
1156 1 #endif
1157 1 WriteDecoder(0xb9, val);
1158 1 }
1159
1160 void SetPVP(WORD period )
1161 {
C51 COMPILER V7.50 TW88 04/01/2008 15:02:37 PAGE 20
1162 1 BYTE val;
1163 1
1164 1 // TW8804 write LSByte first
1165 1 val = ReadDecoder(0xbb);
1166 1 val = val & 0xf0;
1167 1 val = val | (BYTE)(period>>8);
1168 1 WriteDecoder(0xbb, val);
1169 1 WriteDecoder(0xb7, (BYTE)period); // A4, A8 = Panel Vsync Period
1170 1 }
1171
1172 void SetPHP(WORD php)
1173 {
1174 1 BYTE val;
1175 1
1176 1 #ifdef DEBUG
1177 1 dPrintf("\r\n SetPHP : %04x----------", (WORD)php); // test only
1178 1 #endif
1179 1 // TW8804 write LSByte first
1180 1 val = ReadDecoder(0xb6);
1181 1 val &= 0xf0; //0xf8; cut D
1182 1 val |= (BYTE)(php>>8);
1183 1 WriteDecoder(0xb6, val);
1184 1 WriteDecoder(0xb2, php); // A9, AD = Panel Hsync Cycle
1185 1 }
1186
1187 #endif //#if defined SUPPORT_PC || defined SUPPORT_DTV
1188
1189
1190 /////////////////////////////////////////////////////////////////////////////
1191 // Mapping( int fromValue, CRegInfo fromRange,
1192 // int * toValue, CRegInfo toRange )
1193 // Purpose: Map a value in certain range to a value in another range
1194 // Input: int fromValue - value to be mapped from
1195 // CRegInfo fromRange - range of value mapping from
1196 // CRegInfo toRange - range of value mapping to
1197 // Output: int * toValue - mapped value
1198 // Return: Fail if error in parameter, else Success
1199 // Comment: No range checking is performed here. Assume parameters are in
1200 // valid ranges.
1201 // The mapping function does not assume default is always the mid
1202 // point of the whole range. It only assumes default values of the
1203 // two ranges correspond to each other.
1204 //
1205 // The mapping formula is:
1206 //
1207 // For fromRange.Min() <= fromValue <= fromRange.Default():
1208 //
1209 // (fromValue -fromRange.Min())* (toRange.Default() - toRange.Min())
1210 // -------------------------------------------------------------------- + toRange.Min()
1211 // fromRange.Default() - fromRange.Min()
1212 //
1213 // For fromRange.Default() < fromValue <= fromRange.Max():
1214 //
1215 // (fromValue - fromRange.Default()) * (toRange.Max() - toRange.Default())
1216 // --------------------------------------------------------------------- + toRange.Default()
1217 // fromRange.Max() - fromRange.Default()
1218 ////
1219 ////////////////////////////////////////////////////////////////////////////
1220 BYTE Mapping1( int fromValue, CODE_P struct RegisterInfo *fromRange,
1221 int * toValue, CODE_P struct RegisterInfo *toRange ){
1222 1
1223 1 // calculate intermediate values
C51 COMPILER V7.50 TW88 04/01/2008 15:02:37 PAGE 21
1224 1 int a;
1225 1 int b;
1226 1
1227 1 // perform mapping
1228 1 if ( fromValue <= fromRange->Default ) {
1229 2 a = toRange->Default - toRange->Min;
1230 2 b = fromRange->Default - fromRange->Min;
1231 2 // prevent divide by zero
1232 2 if( b==0 ) return (FALSE);
1233 2 *toValue = (int) ( (DWORD)fromValue- (DWORD)fromRange->Min ) * a / b
1234 2 +(DWORD)toRange->Min;
1235 2 }
1236 1 else {
1237 2 a = toRange->Max - toRange->Default;
1238 2 b = fromRange->Max - fromRange->Default;
1239 2 // prevent divide by zero
1240 2 if( b==0 ) return (FALSE);
1241 2 *toValue = (int) ( (DWORD)fromValue - (DWORD)fromRange->Default ) * a / b
1242 2 + (DWORD)toRange->Default;
1243 2 }
1244 1
1245 1 #ifdef DEBUG_OSD
dPrintf("\r\n++(Mapping1)%d(%d-%d-%d)", (WORD)fromValue, (WORD)fromRange->Min, (WORD)fromRange->Default,
-(WORD)fromRange->Max );
dPrintf("->%d(%d-%d)", (WORD)*toValue, (WORD)toRange->Min, (WORD)toRange->Max);
#endif
1249 1
1250 1 return ( TRUE );
1251 1
1252 1 }
1253
1254 #ifndef KEILC
#ifdef SUPPORT_PC
BYTE Mapping2( int fromValue, IDATA_P struct RegisterInfo *fromRange,
int * toValue, CODE_P struct RegisterInfo *toRange ){
// calculate intermediate values
int a;
int b;
// perform mapping
if ( fromValue <= fromRange->Default ) {
a = toRange->Default - toRange->Min;
b = fromRange->Default - fromRange->Min;
// prevent divide by zero
if( b==0 ) return (FALSE);
*toValue = (int) ( (DWORD)fromValue- (DWORD)fromRange->Min ) * a / b
+(DWORD)toRange->Min;
}
else {
a = toRange->Max - toRange->Default;
b = fromRange->Max - fromRange->Default;
// prevent divide by zero
if( b==0 ) return (FALSE);
*toValue = (int) ( (DWORD)fromValue - (DWORD)fromRange->Default ) * a / b
+ (DWORD)toRange->Default;
}
#ifdef DEBUG_OSD
dPrintf("\r\n++(Mapping2)%d(%d-%d-%d)", (WORD)fromValue, (WORD)fromRange->Min, (WORD)fromRange->Default,
(WORD)fromRange->Max );
C51 COMPILER V7.50 TW88 04/01/2008 15:02:37 PAGE 22
dPrintf("->%d(%d-%d)", (WORD)*toValue, (WORD)toRange->Min, (WORD)toRange->Max);
#endif
return ( TRUE );
}
#endif
BYTE Mapping3( int fromValue, CODE_P struct RegisterInfo *fromRange,
int * toValue, IDATA_P struct RegisterInfo *toRange ){
// calculate intermediate values
int a;
int b;
// perform mapping
if ( fromValue <= fromRange->Default ) {
a = toRange->Default - toRange->Min;
b = fromRange->Default - fromRange->Min;
// prevent divide by zero
if( b==0 ) return (FALSE);
*toValue = (int) ( (DWORD)fromValue- (DWORD)fromRange->Min ) * a / b
+(DWORD)toRange->Min;
}
else {
a = toRange->Max - toRange->Default;
b = fromRange->Max - fromRange->Default;
// prevent divide by zero
if( b==0 ) return (FALSE);
*toValue = (int) ( (DWORD)fromValue - (DWORD)fromRange->Default ) * a / b
+ (DWORD)toRange->Default;
}
#ifdef DEBUG_OSD
dPrintf("\r\n++(Mapping3)%d(%d-%d-%d)", (WORD)fromValue, (WORD)fromRange->Min, (WORD)fromRange->Default,
(WORD)fromRange->Max );
dPrintf("->%d(%d-%d)", (WORD)*toValue, (WORD)toRange->Min, (WORD)toRange->Max);
#endif
return ( TRUE );
}
#endif
1329
1330
1331 //Hans
1332 #if (defined SUPPORT_PC) || (defined SUPPORT_DTV)
1333 void ResetStatusRegs(void)
1334 {
1335 1 ClearEnDet();
1336 1 WriteTW88(STATUS0, 0xff); // clear status
1337 1 WriteTW88(STATUS1, 0xff); // clear status
1338 1 SetEnDet();
1339 1 }
1340 #endif
1341
1342 //Hans
1343 BYTE FindDecodeSettingIndex(cMode)
1344 {
1345 1 BYTE i;
1346 1
C51 COMPILER V7.50 TW88 04/01/2008 15:02:37 PAGE 23
1347 1 for (i=0;i<4;i++)
1348 1 {
1349 2 if (cMode == cModeIndex[i])
1350 2 break;
1351 2 }
1352 1 if (i > 3) i = 0; // default 480i
1353 1
1354 1 return i;
1355 1 }
1356
1357 //Hans
1358 void SetDecodeWindow(BYTE cIndex)
1359 {
1360 1 BYTE cTemp;
1361 1
1362 1 #ifdef DEBUG_DECODER
dPrintf("\r\n++(SetDecodeWindow)decode setting index:%02x", (BYTE)cIndex);
#endif
1365 1
1366 1 cTemp = (BYTE)((DecoderFormat[cIndex].VDelay & 0x300) >> 2); // bit6-bit7 of reg 0x007
1367 1 cTemp |= (BYTE)((DecoderFormat[cIndex].VActive & 0x300) >> 4); // bit4-bit5 of reg 0x007
1368 1 cTemp |= (BYTE)((DecoderFormat[cIndex].HDelay & 0x300) >> 6); // bit2-bit3 of reg 0x007
1369 1 cTemp |= (BYTE)((DecoderFormat[cIndex].HActive & 0x300) >> 8); // bit0-bit1 of reg 0x007
1370 1 WriteTW88(0xff, 0x00); // page 0
1371 1 WriteDecoder(0x1C, 0x0f); // Disable the shadow registers.
1372 1 WriteDecoder(0x07, cTemp);
1373 1 WriteDecoder(0x08, (BYTE)(DecoderFormat[cIndex].VDelay & 0xff)); // vdelay
1374 1 WriteDecoder(0x09, (BYTE)(DecoderFormat[cIndex].VActive & 0xff)); // vactive
1375 1 WriteDecoder(0x0A, (BYTE)(DecoderFormat[cIndex].HDelay & 0xff)); // hdelay
1376 1 WriteDecoder(0x0B, (BYTE)(DecoderFormat[cIndex].HActive & 0xff)); // hactive
1377 1 }
1378
1379 // Hans
1380 void InputSetup(void)
1381 {
1382 1 BYTE cTemp;
1383 1 BYTE cReg38=0x80; // Input from Decoder path
1384 1 BYTE cReg42, cReg44;
1385 1
1386 1 #ifdef DEBUG
1387 1 dPrintf("\r\n InputSetup ==========");
1388 1 #endif
1389 1
1390 1 AudioOff();
1391 1 PanelMute(TRUE);
1392 1
1393 1 WriteTW88(0xff, 0); // page 0
1394 1
1395 1 switch(InputSelection)
1396 1 {
1397 2 #ifdef SUPPORT_SVIDEO
1398 2 case SVIDEO:
1399 2 break;
1400 2 #endif
1401 2
1402 2 #ifdef SUPPORT_COMPONENT
1403 2 case COMPONENT:
1404 2 break;
1405 2 #endif
1406 2
1407 2 #ifdef SUPPORT_PC
1408 2 case PC:
C51 COMPILER V7.50 TW88 04/01/2008 15:02:37 PAGE 24
1409 2 cReg38 = 0; // change Anti Aliasing filter path to RGB
1410 2 AutoPHPCalDisable();
1411 2 break;
1412 2
1413 2 #endif
1414 2
1415 2 #ifdef SUPPORT_DTV
case DTV:
cReg42 |= 0x80; //Enable field detection for Digital input port
AutoPHPCalDisable();
break;
#endif
1422 2
1423 2 #ifdef SUPPORT_TV
1424 2 case TV:
1425 2 GetFirstChannel();
1426 2 break;
1427 2 #endif
1428 2
1429 2 case COMPOSITE:
1430 2 default:
1431 2 InputSelection = COMPOSITE; // default to composite source
1432 2 break;
1433 2 }
1434 1
1435 1 cReg42 = InputMatrix[InputSelection].cDataOrder;
1436 1 cReg44 = InputMatrix[InputSelection].cDataFormat | InputMatrix[InputSelection].cInputRoute;
1437 1
1438 1 cTemp = 0x40; // Input crystal clock frequency is 27MHz.
1439 1 cTemp |= InputMatrix[InputSelection].cIFSEL;
1440 1 cTemp |= (InputMatrix[InputSelection].cYSEL & 0x03) << 2;
1441 1 cTemp |= (InputMatrix[InputSelection].cCSEL & 0x02) << 6; // bit7 of reg002
1442 1 cTemp |= (InputMatrix[InputSelection].cCSEL & 0x01) << 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -