📄 adjust.c
字号:
#include <math.h>
#include "types.h"
#include "board.h"
#include "global.h"
#include "ms_reg.h"
#include "ms_rwreg.h"
#include "debug.h"
#include "msosd.h"
#include "misc.h"
#include "Menudef.h"
#include "NVRam.h"
//===================================================
// Local function declaration
#if 0//UsesRGB
void mStar_AdjustRedColor(BYTE rColor, BYTE gColor, BYTE bColor);
void mStar_AdjustGreenColor(BYTE rColor, BYTE gColor, BYTE bColor);
void mStar_AdjustBlueColor(BYTE rColor, BYTE gColor, BYTE bColor);
#else
void mStar_AdjustRedColor(BYTE color);
void mStar_AdjustGreenColor(BYTE color);
void mStar_AdjustBlueColor(BYTE color);
#endif
void mStar_AdjustBrightness(BYTE brightness)
{
#if UsePWMBrightness
mStar_WriteByte(BRC, mStar_ReadByte(BRC)&~BRC_B);
brightness=((DWORD)brightness*(UserPrefPWM0Cmax-UserPrefPWM0Cmin))/100+UserPrefPWM0Cmin;
#if MSTMCU
mStar_WriteByte(PWM2C, brightness);
#else
mStar_WriteByte(PWM0C, brightness);
#endif
#else
mStar_WriteByte(BRC, BRC_B);
brightness=((DWORD)brightness*(MaxBrightnessValue-MinBrightnessValue))/100+MinBrightnessValue;
printData("brightness=%d", brightness);
mStar_WriteByte(BCR, brightness);
mStar_WriteByte(BCG, brightness);
mStar_WriteByte(BCB, brightness);
#endif
}
void mStar_AdjustVolume(BYTE Volume)
{
unsigned char tempVolume;
tempVolume=Volume;
printData("Volume %d ",tempVolume);
if(Volume== 0)
SetAudio(0);
else
{//Volume=MaxVol-Volume;
if(PowerOnFlag)
{
if(Volume>MidVol)
Volume=(((WORD)(Volume-MidVol))*(PWM_MaxVol-PWM_MidVol))/(MaxVol-MidVol)+PWM_MidVol;
else
Volume=(((WORD)Volume)*(PWM_MidVol-PWM_MinVol))/(MidVol-MinVol)+PWM_MinVol;
mStar_WriteByte(PWM1C, Volume);
SetAudio(1);
}
}
}
void mStar_AdjustContrast(BYTE contrast)
{
#if DisplayModeSelect
if(UserPreDisplayMode==DisplayMode_Text||UserPreDisplayMode==DisplayMode_Web||UserPreDisplayMode==DisplayMode_Movie)
return;
#endif
contrast=0;
#if 0//UsesRGB
mStar_AdjustRedColor(UserPrefRedColor, UserPrefGreenColor, UserPrefBlueColor);
mStar_AdjustGreenColor(UserPrefRedColor, UserPrefGreenColor, UserPrefBlueColor);
mStar_AdjustBlueColor(UserPrefRedColor, UserPrefGreenColor, UserPrefBlueColor);
#else
/* mStar_AdjustRedColor(UserPrefRedColor);
mStar_AdjustGreenColor(UserPrefGreenColor);
mStar_AdjustBlueColor(UserPrefBlueColor);
*/
if(UserPrefColorTemp==CTEMP_USER)
{
mStar_AdjustRedColor(UserPrefRedColor);
mStar_AdjustBlueColor(UserPrefBlueColor);
mStar_AdjustGreenColor(UserPrefGreenColor);
}
if(UserPrefColorTemp==CTEMP_9300K)
{
mStar_AdjustRedColor(UserPrefRedColor9300K);
mStar_AdjustBlueColor(UserPrefBlueColor9300K);
mStar_AdjustGreenColor(UserPrefGreenColor9300K);
}
if(UserPrefColorTemp==CTEMP_5800K)
{
mStar_AdjustRedColor(UserPrefRedColor5800K);
mStar_AdjustBlueColor(UserPrefBlueColor5800K);
mStar_AdjustGreenColor(UserPrefGreenColor5800K);
}
if(UserPrefColorTemp==CTEMP_6500K)
{
mStar_AdjustRedColor(UserPrefRedColor6500K);
mStar_AdjustBlueColor(UserPrefBlueColor6500K);
mStar_AdjustGreenColor(UserPrefGreenColor6500K);
}
#endif
}
void mStar_AdjustHTotal(WORD htotal)
{
mStar_WriteByte(REGBK, REGBANKADC);
htotal-=3;
mStar_WriteByte(PLLDIVM, htotal>>4);
mStar_WriteByte(PLLDIVL, (htotal&0xF)<<4);
mStar_WriteByte(REGBK, REGBANKSCALER);
}
void mStar_AdjustPhase(BYTE phase)
{
mStar_WriteByte(REGBK, REGBANKADC);
mStar_WriteByte(CLKCTRL1, phase+8);
mStar_WriteByte(CLKCTRL2, phase);
mStar_WriteByte(REGBK, REGBANKSCALER);
}
void mStar_AdjustHPosition(WORD position)
{
mStar_WriteWord(SPRHST_H, position);
}
void mStar_AdjustVPosition(WORD position)
{
#if WidePanel // sail add
if(position>=BlackVstartOffset)
mStar_WriteWord(SPRVST_H, position-BlackVstartOffset);
Delay1ms(20);
#else
mStar_WriteWord(SPRVST_H, position);
#endif
}
#if 0//UsesRGB
// Note: Contrast range should be form 0.4 to 1
#define RedCoeff1(contrast, color)\
(Slong)(((Slong)299*(contrast+45))/300+701)*color/500
#define RedCoeff(contrast, color)\
(Slong)((Slong)((Slong)299*(contrast+45))/300+701)*color
#define RedCoeff2(contrast, color, divider)\
(Slong)((Slong)((Slong)299*(contrast+45))/300-299)*color*128/(Slong)divider
#define GreenCoeff1(contrast, color)\
(Slong)((Slong)((Slong)587*(contrast+45))/300+413)*color/500
#define GreenCoeff(contrast, color)\
(Slong)((Slong)((Slong)587*(contrast+45))/300+413)*color
#define GreenCoeff2(contrast, color, divider)\
(Slong)((Slong)((Slong)587*(contrast+45))/300-587)*color*128/(Slong)divider
#define BlueCoeff1(contrast, color)\
(Slong)((Slong)((Slong)114*(contrast+45))/300+886)*color/500
#define BlueCoeff(contrast, color)\
(Slong)((Slong)((Slong)114*(contrast+45))/300+886)*color
#define BlueCoeff2(contrast, color, divider)\
(Slong)((Slong)((Slong)114*(contrast+45))/300-114)*color*128/(Slong)divider
void mStar_AdjustRedColor(BYTE rColor, BYTE gColor, BYTE bColor)
{
Slong tempColor, tempColor1;
tempColor1=RedCoeff(UserPrefContrast, rColor);
tempColor=GreenCoeff2(UserPrefContrast, gColor, tempColor1);
if (tempColor<0)
tempColor=abs(tempColor)|BIT7;
mStar_WriteByte(SRGB12, tempColor);
tempColor=BlueCoeff2(UserPrefContrast, bColor, tempColor1);
if (tempColor<0)
tempColor=abs(tempColor)|BIT7;
mStar_WriteByte(SRGB13, tempColor);
tempColor=(Slong)tempColor1/500;
rColor=tempColor;
if (tempColor>0xFF)
rColor=0xFF;
else
rColor=(BYTE)tempColor;
mStar_WriteByte(CCR, rColor);
}
void mStar_AdjustGreenColor(BYTE rColor, BYTE gColor, BYTE bColor)
{ Slong tempColor, tempColor1;
tempColor1=GreenCoeff(UserPrefContrast, gColor);
tempColor=RedCoeff2(UserPrefContrast, rColor, tempColor1);
if (tempColor<0)
tempColor=abs(tempColor)|BIT7;
mStar_WriteByte(SRGB21, tempColor);
tempColor=BlueCoeff2(UserPrefContrast, bColor, tempColor1);
if (tempColor<0)
tempColor=abs(tempColor)|BIT7;
mStar_WriteByte(SRGB23, tempColor);
tempColor=(Slong)tempColor1/500;
gColor=tempColor;
if (tempColor>0xFF)
gColor=0xFF;
else
gColor=(BYTE)tempColor;
mStar_WriteByte(CCG, gColor);
}
void mStar_AdjustBlueColor(BYTE rColor, BYTE gColor, BYTE bColor)
{ Slong tempColor, tempColor1;
tempColor1=BlueCoeff(UserPrefContrast, bColor);
tempColor=RedCoeff2(UserPrefContrast, rColor, tempColor1);
if (tempColor<0)
tempColor=abs(tempColor)|BIT7;
mStar_WriteByte(SRGB31, tempColor);
tempColor=GreenCoeff2(UserPrefContrast, gColor, tempColor1);
if (tempColor<0)
tempColor=abs(tempColor)|BIT7;
mStar_WriteByte(SRGB32, tempColor);
tempColor=(Slong)tempColor1/500;
bColor=tempColor;
if (tempColor>0xFF)
bColor=0xFF;
else
bColor=(BYTE)tempColor;
mStar_WriteByte(CCB, bColor);
}
#else
//----------------------------------------------------------------
void mStar_AdjustRedColor(BYTE color)
{
BYTE tempContrast;
if (UserPrefContrast<MinRealContrastValue)
tempContrast=MinRealContrastValue;
else
tempContrast=UserPrefContrast;
color=((DWORD)color*(tempContrast))>>7;
mStar_WriteByte(CCR, color);
}
void mStar_AdjustGreenColor(BYTE color)
{
BYTE tempContrast;
if (UserPrefContrast<MinRealContrastValue)
tempContrast=MinRealContrastValue;
else
tempContrast=UserPrefContrast;
color=((DWORD)color*(tempContrast))>>7;
mStar_WriteByte(CCG, color);
}
void mStar_AdjustBlueColor(BYTE color)
{
BYTE tempContrast;
if (UserPrefContrast<MinRealContrastValue)
tempContrast=MinRealContrastValue;
else
tempContrast=UserPrefContrast;
color=((DWORD)color*(tempContrast))>>7;
mStar_WriteByte(CCB, color);
}
#endif //endif USERGB
//----------------------------------------------------------------
void mStar_AdjustAdcGain(BYTE rGain, BYTE gGain, BYTE bGain)
{ mStar_WriteByte(REGBK, REGBANKADC);
mStar_WriteByte(REDGAIN, 0xFF-rGain);
mStar_WriteByte(GRNGAIN, 0xFF-gGain);
mStar_WriteByte(BLUGAIN, 0xFF-bGain);
mStar_WriteByte(REGBK, REGBANKSCALER);
}
void mStar_AdjustAdcOffset(BYTE rOffset, BYTE gOffset, BYTE bOffset)
{ mStar_WriteByte(REGBK, REGBANKADC);
mStar_WriteByte(REDOFST, 0xFF-rOffset);
mStar_WriteByte(GRNOFST, 0xFF-gOffset);
mStar_WriteByte(BLUOFST, 0xFF-bOffset);
mStar_WriteByte(REGBK, REGBANKSCALER);
}
#if 1
void mStar_AdjustAdcRedGain(BYTE gain)
{ mStar_WriteByte(REGBK, REGBANKADC);
mStar_WriteByte(REDGAIN, 0xFF-gain);
mStar_WriteByte(REGBK, REGBANKSCALER);
}
void mStar_AdjustAdcGreenGain(BYTE gain)
{ mStar_WriteByte(REGBK, REGBANKADC);
mStar_WriteByte(GRNGAIN, 0xFF-gain);
mStar_WriteByte(REGBK, REGBANKSCALER);
}
void mStar_AdjustAdcBlueGain(BYTE gain)
{ mStar_WriteByte(REGBK, REGBANKADC);
mStar_WriteByte(BLUGAIN, 0xFF-gain);
mStar_WriteByte(REGBK, REGBANKSCALER);
}
void mStar_AdjustAdcRedOffset(BYTE offset)
{ mStar_WriteByte(REGBK, REGBANKADC);
mStar_WriteByte(REDOFST, 0xFF-offset);
mStar_WriteByte(REGBK, REGBANKSCALER);
}
void mStar_AdjustAdcGreenOffset(BYTE offset)
{ mStar_WriteByte(REGBK, REGBANKADC);
mStar_WriteByte(GRNOFST, 0xFF-offset);
mStar_WriteByte(REGBK, REGBANKSCALER);
}
void mStar_AdjustAdcBlueOffset(BYTE offset)
{ mStar_WriteByte(REGBK, REGBANKADC);
mStar_WriteByte(BLUOFST, 0xFF-offset);
mStar_WriteByte(REGBK, REGBANKSCALER);
}
#endif
#if 1
#if 0
void mStar_WaitForDataBlanking(void)
{ WORD retry=500;
while (mStar_ReadByte(ASCTRLL)&IVB_B && retry--);
retry=500;
while (retry-- && !(mStar_ReadByte(ASCTRLL)&IVB_B));
}
#else
void mStar_WaitForDataBlanking(void)
{ WORD retry=500;
while (retry-- && !(mStar_ReadByte(ASCTRLL)&IVB_B));
}
#endif
void mStar_AdjustBackgoundColor(BYTE pattern)
{ BYTE rColor=0;
BYTE gColor=0;
BYTE bColor=0;
if (pattern==0)
rColor=0xFF;
else if (pattern==1)
gColor=0xFF;
else if (pattern==2)
bColor=0xFF;
else if (pattern==4)
{ rColor=0xFF;
gColor=0xFF;
bColor=0xFF;
}
mStar_WaitForDataBlanking();
mStar_WriteByte(FCR, rColor);
mStar_WriteByte(FCG, gColor);
mStar_WriteByte(FCB, bColor);
}
#endif
#if 0//(MSTMCU|MTV512)
void DoGeometry_Reset(void)
{
UserPrefHTotal=StandardModeHTotal;
UserPrefHStart=StandardModeHStart;
UserPrefVStart=StandardModeVStart;
mStar_AdjustHTotal(UserPrefHTotal);
mStar_AdjustHPosition(UserPrefHStart);
mStar_AdjustVPosition(UserPrefVStart);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -