📄 adjust.c
字号:
#include <math.h>
#include "types.h"
#include "global.h"
#include "ms_reg.h"
#include "ms_rwreg.h"
#include "debug.h"
#include "msosd.h"
#include "board.h"
#include "menudef.h"
#include "misc.h"
#include "Adjust.h"
//===================================================
//1-8-1 //ASW Audio
//~~used PWM1 to contorl volume
#define T_VolumeMax 255
#define T_VolumeMin 0
void mStar_AdjustVolume(BYTE volume)
{
// if (!AudioMuteOnFlag)
// {
// hw_ClrMute();
// }
// else
// hw_SetMute();
//****eagle wu0108
volume=(DWORD)volume*255/100;
//volume=(DWORD)volume*4+95;
mStar_WriteByte(PWM1C, (0xFF-volume) );
}
// audio output step by step
void VolumeMuteOff(void)
{
BYTE VolumeTemp;
hw_SetMute();
mStar_AdjustVolume(0);
Delay1ms(10);
hw_ClrStandby();
Delay1ms(100);
VolumeTemp=0;
while(VolumeTemp<UserPrefVolume)
{
mStar_AdjustVolume(VolumeTemp);
VolumeTemp+=10;//10; dragon 0531 for bo-bo voice .
Delay1ms(50);
}
mStar_AdjustVolume(UserPrefVolume);
if (!AudioMuteOnFlag)
hw_ClrMute()
else
hw_SetMute();
}
void VolumeToPowerSaving(void)
{
/*
BYTE VolumeTemp;
VolumeTemp=50;
while(VolumeTemp > 10 )
{
mStar_AdjustVolume(VolumeTemp);
VolumeTemp-=10;
Delay1ms(50);
}
*/
hw_SetMute();
Delay1ms(50);
mStar_AdjustVolume(100);
Delay1ms(50);
hw_SetStandby();
}
//jon information
//===================================================
//===================================================
// Local function declaration
#if 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)
{ brightness=((DWORD)brightness*255)/100;
#if Quanta
mStar_WriteByte(PWM0C, 0xFF-brightness);
#else
mStar_WriteByte(PWM0C, brightness);
#endif
}
void mStar_AdjustContrast(BYTE contrast)
{
#if UsesRGB
contrast=0;
mStar_AdjustRedColor(UserPrefRedColor, UserPrefGreenColor, UserPrefBlueColor);
mStar_AdjustGreenColor(UserPrefRedColor, UserPrefGreenColor, UserPrefBlueColor);
mStar_AdjustBlueColor(UserPrefRedColor, UserPrefGreenColor, UserPrefBlueColor);
#else
BYTE rColor, gColor, bColor;
contrast=0;
if (UserPrefColorTemp==CTEMP_9300K)
{ rColor=UserPrefRedColor9300K;
gColor=UserPrefGreenColor9300K;
bColor=UserPrefBlueColor9300K;
}
else if (UserPrefColorTemp==CTEMP_6500K)
{ rColor=UserPrefRedColor6500K;
gColor=UserPrefGreenColor6500K;
bColor=UserPrefBlueColor6500K;
}
else
{ rColor=UserPrefRedColor;
gColor=UserPrefGreenColor;
bColor=UserPrefBlueColor;
}
mStar_AdjustRedColor(rColor);
mStar_AdjustGreenColor(gColor);
mStar_AdjustBlueColor(bColor);
#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)
{ mStar_WriteWord(SPRVST_H, position);
}
#if 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;// RedCoeff1(UserPrefContrast, color);
rColor=tempColor;
if (tempColor>0xFF)
rColor=0xFF;
else
rColor=(BYTE)tempColor;
mStar_WriteByte(CCR, rColor);//+UserPrefContrast);
}
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;// GreenCoeff1(UserPrefContrast, color);
gColor=tempColor;
if (tempColor>0xFF)
gColor=0xFF;
else
gColor=(BYTE)tempColor;
mStar_WriteByte(CCG, gColor);//+UserPrefContrast);
}
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;// BlueCoeff1(UserPrefContrast, color);
bColor=tempColor;
if (tempColor>0xFF)
bColor=0xFF;
else
bColor=(BYTE)tempColor;
mStar_WriteByte(CCB, bColor);//+UserPrefContrast);
}
#else
void mStar_AdjustRedColor(BYTE color)
{ color=((DWORD)color*(UserPrefContrast))>>7;
mStar_WriteByte(CCR, color);//+UserPrefContrast);
}
void mStar_AdjustGreenColor(BYTE color)
{ color=((DWORD)color*(UserPrefContrast))>>7;
mStar_WriteByte(CCG, color);//+UserPrefContrast);
}
void mStar_AdjustBlueColor(BYTE color)
{ color=((DWORD)color*(UserPrefContrast))>>7;
mStar_WriteByte(CCB, color);//+UserPrefContrast);
}
#endif
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 0
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 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);
}
void mStar_AdjustOffset(void)
{
mStar_WriteByte(BCR, UserPrefRedColorOffset);
mStar_WriteByte(BCG, UserPrefGreenColorOffset);
mStar_WriteByte(BCB, UserPrefBlueColorOffset);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -