⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msvd.lst

📁 Maria2 CarTV 20060707 Tony
💻 LST
📖 第 1 页 / 共 5 页
字号:
 825   1          {
 826   2              if( ucSignalType == SIG_NTSC_443 )
 827   2              {
 828   3                  msWriteByteMask(BK3_48_BSTLVL_TH, 0x20, 0x30); // Pipe delay
 829   3                  msWriteByteMask(BK3_21_COMB2DCFGB, 0x03, 0x07); // Notch mode of C
 830   3              }
 831   2              else
 832   2              {
 833   3                  msWriteByteMask(BK3_48_BSTLVL_TH, 0x00, 0x30); // Pipe delay off
 834   3                  msWriteByteMask(BK3_21_COMB2DCFGB, 0x07, 0x07); // Notch mode of C
 835   3              }
C51 COMPILER V8.01   MSVD                                                                  11/28/2006 08:08:13 PAGE 15  

 836   2      
 837   2              msWriteByte( BK3_62, 0xA0 );
 838   2              msWriteByte( BK3_2F, 0x00 );
 839   2          }
 840   1          else if( IsSVideoInUse())// SV
 841   1          {
 842   2              if( SIG_NTSC_443 == ucSignalType || SIG_NTSC == ucSignalType )
 843   2                  msWriteByteMask(BK3_48_BSTLVL_TH, 0x20, 0x30); // Pipe delay
 844   2              else
 845   2                  msWriteByteMask(BK3_48_BSTLVL_TH, 0x00, 0x30); // Pipe delay off
 846   2      
 847   2              msWriteByte( BK3_62, 0x5F );  //20060222
 848   2              msWriteByte( BK3_2F, 0xC0 );
 849   2          }
 850   1      
 851   1          msVDCombLineBufferCtl( MSVD_COMB_LINE_BUFFER_CTL_HW_AUTO );
 852   1      
 853   1          msWriteByte( BK0_00_REGBK, ucBank );
 854   1      }
 855          
 856          void msCommSetupMode()
 857          {
 858   1          msFieldDetectCtl();
 859   1      
 860   1          // Setup interlace relative register
 861   1          msDetectInterlace(1); // For setup mode
 862   1      
 863   1          if( IsCVBSInUse())
 864   1          {
 865   2              #if TV_ENABLE
 866   2              if( IsTVInUse() )
 867   2                  msLPFCtl(LPF_CTL_TV_STRONG);
 868   2              else
 869   2              #endif
 870   2                  msLPFCtl(LPF_CTL_TV_NORMAL);
 871   2          }
 872   1      }
 873          
 874          #if( ENABLE_SECAM )
 875          XDATA BYTE g_ucMSVDSecamCtl;
 876          void msVDSecamColorCtl( BOOL bColorOn )
 877          {
 878   1          BYTE ucData = 0x0C;
 879   1          BYTE ucBank;
 880   1          ucBank=msReadByte(BK0_00_REGBK);
 881   1      
 882   1          if( bColorOn )
 883   1              ucData = 0x00;
 884   1          msWriteByte( BK0_00_REGBK, REG_BANK3_COMB);
 885   1      
 886   1          msWriteByteMask( BK3_C5, ucData, 0x0C);
 887   1          msWriteByte(BK0_00_REGBK, ucBank);
 888   1      }
 889          
 890          void msVDSecamHandler(void)
 891          {
 892   1          BYTE ucBank;
 893   1      
 894   1          if( g_ucVDSecamHandlerTimer )
 895   1              return;
 896   1      
 897   1          g_ucVDSecamHandlerTimer = 20;
C51 COMPILER V8.01   MSVD                                                                  11/28/2006 08:08:13 PAGE 16  

 898   1      
 899   1          ucBank = msReadByte( BK0_00_REGBK);
 900   1      
 901   1          {
 902   2              WORD wVdStatus;
 903   2      
 904   2              wVdStatus = msVDGetSyncStatus();
 905   2      
 906   2              if(wVdStatus&VD_HSYNC_LOCKED)
 907   2              {
 908   3                  msVDSecamColorCtl(_ENABLE);
 909   3              }
 910   2              else
 911   2              {
 912   3                  msVDSecamColorCtl(_DISABLE);
 913   3              }
 914   2          }
 915   1      
 916   1          // Adjust Secam detect threoshold by burst mag
 917   1          // BurstMag>>4 = 6, 0B0A09 = 002160
 918   1          {
 919   2              BYTE ucBurstMag;
 920   2              DWORD dwData;
 921   2              BYTE ucNoiseMag;
 922   2              BYTE ucBurstPhsErr;
 923   2              BYTE ucSecamBurstPhsErr;
 924   2      
 925   2      
 926   2              ucBurstMag = msDSP_Std_GetBurstMag()>>4;
 927   2              dwData = ((DWORD)0x2160*(DWORD)ucBurstMag)/6;
 928   2              dwData = (dwData>>3)+ (g_dwVDSecamHandler_PreMagThl-(g_dwVDSecamHandler_PreMagThl>>3));
 929   2      
 930   2              ucBurstPhsErr = msDSP_Std_GetPhaseError();
 931   2              ucSecamBurstPhsErr = msDSP_Std_GetSecamPhaseError();
 932   2      
 933   2              ucNoiseMag = msDSP_Std_GetNoiseMag()>>1;
 934   2      
 935   2              g_wVDSecamHandler_PreNoiseMag = ucNoiseMag;
 936   2      
 937   2              if ((g_VdInfo.ucVideoSystem == SIG_PAL) && (ucNoiseMag >= 0x10))
 938   2              {
 939   3                  if (ucSecamBurstPhsErr <= 0x5B)
 940   3                      g_ucVDSecamThdCnt ++ ;
 941   3                  else if (ucSecamBurstPhsErr >= 0x60)
 942   3                      g_ucVDSecamThdCnt -= 8 ;
 943   3                  if (g_ucVDSecamThdCnt > 128) // negative
 944   3                      g_ucVDSecamThdCnt = 0 ;
 945   3                  else if (g_ucVDSecamThdCnt > 48)
 946   3                      g_ucVDSecamThdCnt = 48 ;
 947   3      
 948   3              }
 949   2              else
 950   2                      g_ucVDSecamThdCnt = 0 ;
 951   2              if( g_VdInfo.ucVideoSystem == SIG_SECAM )
 952   2              {
 953   3                  if( ucNoiseMag < 3 )
 954   3                  {
 955   4                      if( dwData < 0x000590 )
 956   4                          dwData = 0x000590;
 957   4                  }
 958   3                  else if( ucNoiseMag < 10 )
 959   3                  {
C51 COMPILER V8.01   MSVD                                                                  11/28/2006 08:08:13 PAGE 17  

 960   4                      if( dwData < 0x0010B0 )
 961   4                          dwData = 0x0010B0;
 962   4                  }
 963   3                  else if( (ucBurstMag<5 )||(ucNoiseMag >= 0x10) )
 964   3                      dwData = 0x001BD0;
 965   3                  g_dwVDSecamHandler_PreMagThl = dwData ;
 966   3                  dwData -= 0x100;
 967   3              }
 968   2              else
 969   2              {
 970   3                  if ( (g_ucVDSecamThdCnt > 24) || (ucNoiseMag >= 0x64) )  // notice ucNoiseMag is >>1
 971   3                          dwData = 0x00FFFF;
 972   3                  else if ((ucBurstPhsErr > 0x20) && (ucNoiseMag < 3)) // Clean signal. Threshold for SECAM coul
             -d be lower.
 973   3                  {
 974   4                      if (dwData < 0x000590)
 975   4                          dwData = 0x000590;
 976   4                  }
 977   3                  else if ((ucBurstPhsErr > 0x20) && (ucNoiseMag < 13)) // Clean signal. Threshold for SECAM cou
             -ld be lower.
 978   3                  {
 979   4                      if (dwData < 0x0010B0)
 980   4                          dwData = 0x0010B0;
 981   4                  }
 982   3                  else if (ucBurstPhsErr > 0x50) // Large burst phase error might come from SECAM signal but thr
             -eshold shall not be too low if signal is not clean
 983   3                  {
 984   4                      if((ucBurstMag<5 )||(ucNoiseMag >= 0x13))
 985   4                          dwData = 0x001BD0;
 986   4                  }
 987   3                  else  // To avoid mis-judging PAL to SECAM (set higher threshold if burst phase error is small
             -)
 988   3                  {
 989   4                      if( dwData < 0x001BD0 )
 990   4                          dwData = 0x001BD0;
 991   4                  }
 992   3                  g_dwVDSecamHandler_PreMagThl = dwData ;
 993   3              }
 994   2      //        printf("  01====%x", ucBurstMag);
 995   2      //        printf("  02====%x", ucBurstPhsErr);
 996   2      //        printf("  03====%x", ucSecamBurstPhsErr);
 997   2      //        printf("  04====%x", ucNoiseMag);
 998   2      //        printf("  05====%x", g_ucVDSecamThdCnt);
 999   2      
1000   2      //        printf("  01====%x", msDSP_Std_GetBurstMag());
1001   2      //        printf("  02====%x", msDSP_Std_GetPhaseError());
1002   2      //        printf("  03====%x", msDSP_Std_GetSecamPhaseError());
1003   2      //        printf("  04====%x", msDSP_Std_GetNoiseMag());
1004   2      //        printf("  05====%x", ((dwData>>8)&0xFF));
1005   2      //        printMsg("\r\n");
1006   2              msWriteByte(BK0_00_REGBK, REG_BANK3_COMB);
1007   2      
1008   2              msWriteByte(BK3_A9, dwData&0xFF);
1009   2              msWriteByte(BK3_AA, (dwData>>8)&0xFF);
1010   2              msWriteByteMask(BK3_AB, (dwData>>16), 0x0F);
1011   2          }
1012   1          msWriteByte( BK0_00_REGBK, ucBank );
1013   1      }
1014          #endif
1015          
1016          #ifdef VD_PATCH_001
              // Call this function one time when no signal
C51 COMPILER V8.01   MSVD                                                                  11/28/2006 08:08:13 PAGE 18  

              BOOL msVD_Patch_001(void)
              {
                  if( (msVDSpecialRead( 0x00, BK2_01 )&0xF0) == 0x30 )
                  {
                      //msVDReset();
                      msVD_FSM_Reset();
                      return TRUE;
                  }
                  return FALSE;
              }
              #endif
1029          
1030          #ifdef VD_PATCH_002
1031          // Call this function when mode change!
1032          BOOL msVD_Patch_002( BYTE ucCurVideoSystem )
1033          {
1034   1          BOOL bResult = 0;
1035   1      
1036   1          if( ucCurVideoSystem == SIG_NTSC )
1037   1          {
1038   2              if( g_msVD_Patch002_LastVideoSystem != SIG_NTSC )
1039   2              {
1040   3                  putstr("\r\nPatch002:-> NTSC");
1041   3                  bResult = 1;
1042   3              }
1043   2          }
1044   1      
1045   1          if( bResult )
1046   1              msVD_FSM_Reset();
1047   1      
1048   1          g_msVD_Patch002_LastVideoSystem = ucCurVideoSystem;
1049   1      
1050   1          //printf("\r\nExit msVD_Patch_002 ->%d", bResult);
1051   1          return bResult;
1052   1      }
1053          #endif
1054          
1055          #ifdef VD_PATCH_003
1056          XDATA BYTE g_msVD_Patch003_StableCounter;
1057          BOOL msVD_Patch_003(BYTE ucFlag)
1058          {
1059   1          if( (ucFlag == 0)||( !msVDGetColorLockBit()) )
1060   1          {
1061   2              g_msVD_Patch003_StableCounter = 0;
1062   2          }
1063   1          else
1064   1          {
1065   2              if( (msVDSpecialRead( 0x0E, 0x01 ) > 0x70)
1066   2                &&(msDSP_Std_GetNoiseMag() < 0x20)) // Clean signal
1067   2              {
1068   3                  ++ g_msVD_Patch003_StableCounter;
1069   3                  if( g_msVD_Patch003_StableCounter > 3 )
1070   3                  {
1071   4                      g_msVD_Patch003_StableCounter = 0;
1072   4                      putstr("\r\nPatch003: Phase Error!");
1073   4                      msVD_FSM_Reset();
1074   4                      return TRUE;
1075   4                  }
1076   3              }
1077   2              else
1078   2              {
1079   3                  g_msVD_Patch003_StableCounter = 0;
C51 COMPILER V8.01   MSVD                                                                  11/28/2006 08:08:13 PAGE 19  

1080   3              }
1081   2          }
1082   1          return FALSE;
1083   1      }
1084          #endif
1085          
1086          #ifdef VD_PATCH_004
              XDATA g_msVD_Patch004_StableCounter;
              void msVD_Patch_004( BOOL bEnable )
              {
                  if( bEnable )
                  {
                      int iTmp = msVDGetVTotal();
                      if( abs(iTmp - msGetVerticalTotal()) >= 50  )
                          ++ g_msVD_Patch004_StableCounter;
                      else
                          g_msVD_Patch004_StableCounter = 0;
              
                      if( g_msVD_Patch004_StableCounter > 10 )
                      {
                          msVD_FSM_Reset();
                          //msVDReset();
                          g_msVD_Patch004_StableCounter = 0;
                      }
                  }
                  else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -