?? karaoke.c
字號:
/*********************************************************************
Filename: karaoke.c
Author : Keung Fung
Date : 12th. August. 1996.
Purpose :
// ECHO-> delay time
I/O use: GPCR(b1-0), P1^4
*********************************************************************/
#include "vcd25.h"
#include "cc.h"
#include "w9925.h"
#include "karaoke.h"
#include "isr.h"
#include <intrins.h>
#ifdef KARAOKE
//#if 1
//#ifdef COMBO_SYSTEM
#if VCD_SYSTEM == VCD25Q_S
sbit __sbKARAOKEsda = P1 ^ 1;
sbit __sbKARAOKEsck = P1 ^ 2;
#endif // COMBO_SYSTEM
#if VCD_SYSTEM == VCD25Q_K1
sbit __sbKARAOKEsda= P3 ^ 0;
sbit __sbKARAOKEsck= P3 ^ 1;
#endif // VCD_SYSTEM
#define FCR 0x00
#define KSR 0x01
#define VCR_YSS 0x02
#define TMR_YSS 0x03
sbit YSS_YSS_CS = P1^4;
static BYTE bdata _GPCR_Value;
static BYTE bdata _DATA_Buffer;
sbit YSS_CLK = _GPCR_Value^0;
sbit YSS_DATA= _GPCR_Value^1;
sbit _DATA_Buffer_bit0 = _DATA_Buffer^0;
void _YSS_CS (BIT state);
void _SCK(BIT state);
void _SDA(BIT state);
void YSS_OutData( BYTE add, BYTE value) ;
BYTE FCR_Value = 0x4A;
BYTE KSR_Value = 0x20;
//BYTE VCR_Value = 0x03;
BYTE TMR_Value = 0x30;
//CR00,CR03, echo initial value 0x40
BYTE CR_DATA[] =
{ 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x7F, 0x70, 0x00, 0x7F, //0x7f
0x00, 0x20, 0x20, 0x60, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00};
void _YSS_CS(BIT state)
{
#ifdef COMBO_SYSTEM
CDROM_OutPA ( PA_KARAOKE_CS, state );
#else
YSS_YSS_CS= state;
#endif // COMBO_SYSTEM
}
// *********************************************************************
// Function : _SCK
// Description : It will control the GPCR bit 0 value
// Arguments : state
// Return : NULL
// Side Effect :
// *********************************************************************
void _SCK(BIT state)
{
YSS_CLK = state;
#if VCD_SYSTEM == VCD25Q_K
W9925_WriteReg (GPCR, _GPCR_Value);
#else
__sbKARAOKEsck= state;
#endif // COMBO_SYSTEM
}
// *********************************************************************
// Function : _SDA
// Description : It will control the GPCR bit 1 value
// Arguments : state
// Return : NULL
// Side Effect :
// *********************************************************************
void _SDA(BIT state)
{
YSS_DATA = state;
#if VCD_SYSTEM == VCD25Q_K
W9925_WriteReg (GPCR, _GPCR_Value);
#else
__sbKARAOKEsda= state;
#endif // COMBO_SYSTEM
}
// *********************************************************************
// Function : YSS_OutData
// Description : Perform write data to internal register
// Arguments : add, value
// Return : NULL
// Side Effect :
// *********************************************************************
void YSS_OutData( BYTE add, BYTE value)
{
BYTE i,j,k;
for (j =0;j<2; j++)
{
// write address first
if (j==0)
DATA_Buffer = add;
// then write data
else
DATA_Buffer = value;
//each write is through a 8-bit interface
//LSB first
for (i=0; i<8; i++)
{
_SDA(_DATA_Buffer_bit0);
_SCK(0); // /sck low
for (k=0; k<4; k++); //delay time > 450ns
_SCK(1); // /sck high and YSS216 receives one bit
DATA_Buffer >>=1; // LSB first
} //for i
} //for j
} //void
// *********************************************************************
// Function : YSS_Initial
// Description : Initial FCR, KSR, VCR, TMR, CR00-CR13
// Arguments : NULL
// Return : NULL
// Side Effect :
// *********************************************************************
void YSS_Initial(void)
{
BYTE i,j;
_SCK(1);
for (j=0; j<3;j++) ; //
// YSS_CS = 0;
_YSS_CS (0);
// Default FCR:
// Select YM7110 data input
// Digital input de-emphasis processing ON(coefficients is normal(44.1kHz)
// coefficients set by resisters CR00-CR13
// Output muting on
YSS_OutData(FCR, 0x42);
// Default KSR:
// Normal key
// Live surround???(bit 6-5=01'b)
YSS_OutData(KSR, 0x20);
// Default VCR:
//
YSS_OutData(VCR_YSS, 0x03);
// Default TNR:
// fading time 0.5 sec
YSS_OutData(TMR_YSS, 0x30);
for (i=0; i<20; i++)
YSS_OutData((0x20+i),CR_DATA[i]); //CR00 ~ CR13 0x20 ~ 0x33
// Output muting off
YSS_OutData(FCR, 0x4A);
_YSS_CS (1);
}
// *********************************************************************
// Function : YSS_KSR
// Description : Control the key shift
// Arguments : value(0 to 32 levels)
// Return : NULL
// Side Effect :
// *********************************************************************
void YSS_KSR(BYTE value)
{
BYTE j;
_SCK(1);
// delay time
for (j=0; j<3;j++) ; //
_YSS_CS(0);
// must keep the surround setting
KSR_Value = (KSR_Value & 0x60) | value ;
YSS_OutData(KSR, KSR_Value);
_YSS_CS (1);
}
// *********************************************************************
// Function : YSS_Echo
// Description : Delay time setting by changing the CR05, CR08
// Arguments : value
// Return : NULL
// Side Effect :
// *********************************************************************
void YSS_Echo(BYTE value)
{
BYTE j;
value = value * 18;
if (value >= 0x8A)
value = 0x8A;
_SCK(1);
for (j=0;j<3;j++) ;
_YSS_CS (0);
// CR05, bit0 must be 0
YSS_OutData(0x25, value);
// CR08, bit0 must be 0
YSS_OutData(0x28, value);
_YSS_CS (1);
}
// *********************************************************************
// Function : YSS_Surround
// Description : Change surround effect
// Arguments : value
// Return : NULL
// Side Effect :
// *********************************************************************
void YSS_Surround(BYTE value)
{
BYTE j;
_SCK(1);
for (j=0; j<3 ; j++);
_YSS_CS (0);
// YSS_OutData(FCR,0x5A); // clear "+"
// YSS_OutData(0x21, bCR01); //CR01
// YSS_OutData(0x24, bCR04); //CR04
// YSS_OutData(0x22, bCR02); //CR02
// YSS_OutData(0x26, bCR06); //CR06
switch(value)
{
case 0 : //normal
YSS_OutData(0x21, 0x00); //CR01
YSS_OutData(0x24, 0x00); //CR04
YSS_OutData(0x20, 0x00); //CR00
YSS_OutData(0x23, 0x00); //CR03
YSS_OutData(0x22, 0x7F); //CR02
YSS_OutData(0x26, 0x7F); //CR06
KSR_Value = (KSR_Value & 0x1F) | 0x20 ;
break;
case 1 : //simulation stereo
YSS_OutData(0x21, 0x00); //CR01
YSS_OutData(0x24, 0x7F); //CR04
YSS_OutData(0x22, 0x7F); //CR02
YSS_OutData(0x26, 0x7F); //CR06
KSR_Value &= 0x1F;
break;
case 2 : //live
YSS_OutData(0x24, 0x40); //CR04
YSS_OutData(0x22, 0x40); //CR02
YSS_OutData(0x21, 0x7F); //CR01
YSS_OutData(0x26, 0x7F); //CR06
KSR_Value = (KSR_Value & 0x1F) | 0x20;
break;
case 3 : //movie
YSS_OutData(0x24, 0x40); //CR04
YSS_OutData(0x22, 0x40); //CR02
YSS_OutData(0x21, 0x7F); //CR01
YSS_OutData(0x26, 0x7F); //CR06
KSR_Value = (KSR_Value & 0x1F) | 0x40;
break;
case 4 : //karaoke
YSS_OutData(0x21, 0x00); //CR01
YSS_OutData(0x20, 0x70); //CR00
YSS_OutData(0x23, 0x70); //CR03
YSS_OutData(0x24, 0x7F); //CR04
YSS_OutData(0x22, 0x7F); //CR02
YSS_OutData(0x26, 0x7F); //CR06
KSR_Value &= 0x1F;
break;
} //switch
YSS_OutData(KSR,KSR_Value);
// YSS_OutData(VCR_YSS, 0x03); //VCR_YSS
// YSS_OutData(0x29,0x7F);
// YSS_OutData(0x2F,0x7F);
// YSS_OutData(FCR, 0x5F);
YSS_OutData(FCR, 0x4A); //FCR
_YSS_CS (1);
}
#endif // KARAOKE
// *********************************************************************
// Function : KARAOKE_Initial
// Description : Initial KARAOKE chip
// Arguments : NULL
// Return : NULL
// Side Effect :
// *********************************************************************
void KARAOKE_Initial ()
{
#ifdef KARAOKE
YSS_Initial ();
return;
#else
// YSS_Initial (); // *** 0.45; Test BCA if has YSS216
#endif // KARAOKE
}
// *********************************************************************
// Function : KARAOKE_KeyShift
// Description : Control karaoke key shift
// Arguments : bKey, 0 to 32
// Return : NULL
// Side Effect :
// *********************************************************************
void KARAOKE_KeyShift ( BYTE bKey )
{
#ifdef KARAOKE
YSS_KSR ( bKey );
return;
#endif // KARAOKE
}
// *********************************************************************
// Function : KARAOKE_Surround
// Description : Control surround effect
// Arguments : bSurround, 0 to 4
// Return : NULL
// Side Effect :
// *********************************************************************
void KARAOKE_Surround ( BYTE bSurround )
{
#ifdef KARAOKE
YSS_Surround ( bSurround );
return;
#endif // KARAOKE
}
// *********************************************************************
// Function : KARAOKE_Echo
// Description : Adjust delay time
// Arguments : bEcho, 0 to 8
// Return : NULL
// Side Effect :
// *********************************************************************
void KARAOKE_Echo ( BYTE bEcho )
{
#ifdef KARAOKE
YSS_Echo ( bEcho );
return;
#endif // KARAOKE
}
// *********************************************************************
// Function : KARAOKE_VoicrCancel
// Description :
// Arguments : NULL
// Return : NULL
// Side Effect :
// *********************************************************************
void KARAOKE_VoiceCancel ( BYTE bCancel )
{
#ifdef KARAOKE
BYTE j;
_SCK(1);
for (j=0; j<3;j++) ; //
_YSS_CS (0);
switch(bCancel)
{
case 0x00 : //no voice cancellation
YSS_OutData(VCR_YSS, 0x03);
break;
default : //voice cancellation on
YSS_OutData(VCR_YSS, 0x13);
break;
}
_YSS_CS (1);
#endif // KARAOKE
}
// *********************************************************************
// Function : KARAOKE_MICControl
// Description : Close MIC-Input as it may cause that F/W can't cross standard
// Arguments : NULL
// Return : NULL
// Side Effect : // *** MULTI_DISC;
// *********************************************************************
void KARAOKE_MICControl ( BYTE bON )
{
#ifdef KARAOKE
BYTE j;
_SCK(1);
for (j=0; j<3;j++) ; //
_YSS_CS(0);
YSS_OutData(0x20, (bON * 0x70) );
YSS_OutData(0x23, (bON * 0x70) );
YSS_OutData(0x2D, (bON * 0x7F) );
_YSS_CS(1);
return;
#endif // KARAOKE
}
// *********************************************************************
// Function : KARAOKE_VolumeControl
// Description : Control Volume
// Arguments : NULL
// Return : NULL
// Side Effect : // *** MULTI_DISC;
// *********************************************************************
void KARAOKE_VolumeControl ( BYTE bLevel, BYTE bChannel )
{
#ifdef KARAOKE
BYTE i, j;
WORD wTemp;
if ( bLevel )
{
wTemp= 0x7f* (WORD)bLevel;
j= wTemp/ VOLUME_MAX;
}
else
j= NULL;
_SCK(1);
for (i=0; i<3;i++) ; //
_YSS_CS(0);
// YSS_OutData ( 0x22, 0x7F ); // CR02
// YSS_OutData ( 0x26, 0x7F ); // CR06
// seems conflict with spec.
switch ( bChannel )
{
case AUDIO_LL:
YSS_OutData ( 0x2E, 0x00 ); // CR0E
YSS_OutData ( 0x2F, 0x00 ); // CR0F
YSS_OutData ( 0x29, j ); // CR09, DL -> L
YSS_OutData ( 0x2A, j ); // CR0A, DL -> R
break;
case AUDIO_RR:
YSS_OutData ( 0x29, 0x00 ); // CR09
YSS_OutData ( 0x2A, 0x00 ); // CR0A
YSS_OutData ( 0x2E, j ); // CR0E, DR -> L
YSS_OutData ( 0x2F, j ); // CR0F, DR -> R
break;
case AUDIO_RL:
YSS_OutData ( 0x29, 0x00 ); // CR09, DL -> L
YSS_OutData ( 0x2F, 0x00 ); // CR0F, DR -> R
YSS_OutData ( 0x2A, j ); // CR0A, DL -> R
YSS_OutData ( 0x2E, j ); // CR0E, DR -> L
break;
case AUDIO_STEREO:
YSS_OutData ( 0x2A, 0x00 ); // CR0A, DL -> R
YSS_OutData ( 0x2E, 0x00 ); // CR0E, DR -> L
YSS_OutData ( 0x29, j ); // CR09, DL -> L
YSS_OutData ( 0x2F, j ); // CR0F, DR -> R
default:
break;
}
_YSS_CS(1);
/* // *** MULTI_DISC;
_YSS_CS(0);
YSS_OutData ( 0x22, j ); // CR02
YSS_OutData ( 0x26, j ); // CR06
_YSS_CS(1);
*/
return;
#endif // KARAOKE
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -