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

📄 kar_m.c

📁 Zoran VP2K731 DVD源代码,极具参考价值!
💻 C
字号:
/***********************************************************************/
/* File:															   */
/*	  Copyright (c) 2000 ZORAN Corporation, All Rights Reserved		   */
/*	  THIS IS PROPRIETARY SOURCE CODE OF ZORAN CORPORATION             */
/*																	   */
/* ===========                                                         */
/* Descripton:                                                         */
/* ===========                                                         */
/*                                                                     */
/* Log:                                                                */
/* ===                                                                 */
/* $Name: V_1_1A V_1_19 $                                                            
/* $Header: v:/dsg/rcs/dsg/vp2k/Customer/MENU/newzoran/KAR_M.C 1.2 2001/09/18 07:22:29 dragonwg Exp $                                                          
/* $Log: KAR_M.C $										                       
/* Revision 1.2  2001/09/18 07:22:29  dragonwg										                       
/* Remove something for not defined D_OLD_LR										                       
/* Revision 1.1  2001/06/26 08:04:47  dingming										                       
/* Initial revision										                       
/* Revision 1.1  2001/03/20 08:40:38  fwang										                       
/* Initial revision										                       
/* Revision 1.1  2001/03/14 04:11:58  cliff										                       
/* Initial revision										                       
/* Revision 1.28  2001/02/14 02:01:32  leslie										                       
/* Remove ECHO menu item with compile switch EXTERNAL_ECHO										                       
/* Revision 1.18  2001/01/21 08:29:38  leslie										                       
/* Update ZCH Database after working in XQ										                       
/* Revision 1.19  2001/01/16 07:58:25  fwang										                       
/* Revision 1.18  2001/01/15 09:12:56  fwang										                       
/* Revision 1.17  2000/12/08 07:04:50  adamw										                       
/* Revision 1.27  2000/11/19 04:46:49  charlie										                       
/* Changed 30 to MS_LINE_HEIGHT										                       
/* Revision 1.26  2000/11/17 18:54:12  charlie										                       
/* Use C_FOCUSED										                       
/* Revision 1.25  2000/11/09 04:07:30  cliff										                       
/***********************************************************************/
#include <stdio.h>
#include <string.h>
#include "sysdefs.h"
#include "..\..\..\ui\menu_sys\ms_wdgt.h"
#include "..\..\..\ui\menu_sys\ms_lib.h"
#include "..\..\..\ui\menu_sys\osd_drv.h"
#include "..\..\..\decoder\osdrendr.h"
#include "..\..\..\decoder\osdlayou.h"
#include "..\..\..\customer\dragon\strings\strings.h"
#include "menu_var.h"
#include "..\..\..\playcore\ps\ps.h"
#ifdef D_NO_KARAOKE_DEFAULT
#else
#include "..\..\playcore\coremain\coregdef.h"
#endif // D_NO_KARAOKE_DEFAULT
#include "..\..\..\kernel\eventdef.h"
#include "..\..\..\Decoder\decoder.h"

#ifdef D_OLD_LR
#else
#include "lr.h"
#endif // D_OLD_LR
#define USE_UNION
#ifdef USE_UNION
#define MEMBER(_member_)	gu_ms.m_karm._member_
#else
static MS_SLIDER *key_shift_slider;
#endif

#ifdef D_OLD_LR
static const MS_POS	screen_pos = {104,	MS_LINE_2,	504, MS_LINE(4)};
#else
static const MS_POS	screen_pos = {104,	MS_LINE_2,	504, MS_LINE(3)};
#endif

const MS_POS	kar_pos		= {150, MS_LINE_0, 256, MS_LINE_HEIGHT};
#ifdef D_OLD_LR
const MS_POS	channels_pos	= {150, MS_LINE_1, 256, MS_LINE_HEIGHT};
#endif
const MS_POS	pos_dont_care	= {150, MS_LINE_2, 0, 0};

#ifdef D_OLD_LR
static const MS_POS	key_slider_pos = {150, (MS_LINE_2 + 4), 256, 22};
#else
static const MS_POS	key_slider_pos = {150, (MS_LINE_1 + 4), 256, 22};
#endif
#define NUM_KEYSHIFT_SLIDER_STEPS	15

#ifndef EXTERAL_ECHO
static MS_SLIDER *echo_slider;
#ifdef D_OLD_LR
static const MS_POS	echo_slider_pos = {150,	(MS_LINE_3 + 4), 256, 22};
#else
static const MS_POS	echo_slider_pos = {150,	(MS_LINE_2 + 4), 256, 22};
#endif
#define NUM_ECHO_SLIDER_STEPS	16
#endif //EXTERAL_ECHO

const MS_STATIC karaoke = {
	{
	0,
	ALIGN_LEFT,
	I_COLOR,
	{16,0,200,MS_LINE_HEIGHT},
	NO_PARENT,
	static_user_op,
	},
	(void *)S_KARAOKE
};
#ifdef D_OLD_LR
const MS_STATIC channels = {
	{
	0,
	ALIGN_LEFT,
	I_COLOR,
	{16, MS_LINE_1, 200, MS_LINE_HEIGHT},
	NO_PARENT,
	static_user_op,
	},
	(void *)S_LR_MODE
};
#endif
const MS_STATIC key_shift = {
	{
	0,
	ALIGN_LEFT,
	I_COLOR,
#ifdef D_OLD_LR
	{16, MS_LINE_2, 200, MS_LINE_HEIGHT},
#else
	{16, MS_LINE_1, 200, MS_LINE_HEIGHT},
#endif
	NO_PARENT,
	static_user_op,
	},
	(void *)S_KEY_SHIFT
};

#ifndef EXTERAL_ECHO
const MS_STATIC echo = {
	{
	0,
	ALIGN_LEFT,
	I_COLOR,
#ifdef D_OLD_LR
	{16, MS_LINE_3, 200, MS_LINE_HEIGHT},
#else
	{16, MS_LINE_2, 200, MS_LINE_HEIGHT},
#endif	
	
	NO_PARENT,
	static_user_op,
	},
	(void *)S_ECHO
};
#endif  //EXTERAL_ECHO

// Karaoke choice items

const OSD_MESSAGES kar_list_c[] = {
	S_OFF,
	S_ON
};

const MS_TEXT_LIST kar_list = {
	2,(int *)kar_list_c
};

#ifdef D_OLD_LR
// Channels choice items
#define ITEMNUM_STEREO			0
#define ITEMNUM_LEFT			1
#define ITEMNUM_RIGHT			2
#define ITEMNUM_PARTNER_LEFT	3
#define ITEMNUM_PARTNER_RIGHT	4

const OSD_MESSAGES channels_list_c[] = {
	S_STEREO,
	S_LEFT,
	S_RIGHT,
	S_PARTNER_LEFT,
	S_PARTNER_RIGHT
};

const MS_TEXT_LIST channels_list = {
	5,(int *)channels_list_c
};
#endif // D_OLD_LR

#ifdef D_NO_KARAOKE_DEFAULT
#else
//
// Map the current karaoke setting to the menu choice number
//
void kar_choice(MS_CHOICE *msChoice)
{
  switch ( gtps.mKaraoke )
  {
	case KARAOKE_SETTING_ON:
	  msChoice->current_choice = 1;
	  break;
	case KARAOKE_SETTING_OFF:
	  // Fall through!
	default:
	  msChoice->current_choice = 0;
	  break;
  }
}
#endif // D_NO_KARAOKE_DEFAULT

#ifdef D_UNHOOK_KARAOKE
#else
void channels_action(int num);
#endif // D_UNHOOK_KARAOKE

void kar_display(MS_WIDGET *msWidget)
{
  MS_display(msWidget);
}

void slider_display(MS_WIDGET *msWidget)
{
  MS_display(msWidget);
}

void disable_karaoke_on_items(void)
{
#ifdef D_OLD_LR
  SET_NONSELECTABLE(choice2);
#endif
  SET_NONSELECTABLE(MEMBER(key_shift_slider));
#ifndef EXTERAL_ECHO
  SET_NONSELECTABLE(echo_slider);
#endif //EXTERAL_ECHO  
}

void enable_karaoke_on_items(void)
{
#ifdef D_OLD_LR
  SET_SELECTABLE(choice2);
#endif
  SET_SELECTABLE(MEMBER(key_shift_slider));
 #ifndef EXTERAL_ECHO  
  SET_SELECTABLE(echo_slider);
#endif //EXTERAL_ECHO  
}

#ifndef EXTERAL_ECHO
int CalcEcho( int iHwValue )
{
  return iHwValue * (NUM_ECHO_SLIDER_STEPS - 1) / 240;
}
#endif //EXTERAL_ECHO

int CalcKeyShift( int iHwValue )
{
	int iKeyShift;
	
	// Convert hardware value to slider value
	iKeyShift = iHwValue;
	if ( iKeyShift & (oHWLimit.mMaxKeyShift + 1) )
	{
	  iKeyShift = -( iKeyShift & ~(oHWLimit.mMaxKeyShift + 1) );
	}
	iKeyShift = ( iKeyShift + (oHWLimit.mMaxKeyShift + 1) ) * NUM_KEYSHIFT_SLIDER_STEPS / ( (oHWLimit.mMaxKeyShift + 1) * 2 );

	return iKeyShift;
}

#ifdef D_OLD_LR
#ifdef D_NO_KARAOKE_DEFAULT
#else
//
// Map the current karaoke setting to the menu choice number
//
void channels_choice(MS_CHOICE *msChoice)
{
  int iChoice;

  switch ( gtps.mDMM )
  {
	case DMM_SETTING_LEFT_ONLY:
	  if ( gtps.mPartner == PARTNER_SETTING_OFF )
		iChoice = 1;
	  else
		iChoice = 3;
	  break;

	case DMM_SETTING_RIGHT_ONLY:
	  if ( gtps.mPartner == PARTNER_SETTING_OFF )
		iChoice = 2;
	  else
		iChoice = 4;
	  break;

    case DMM_SETTING_NORMAL:
	  // Fall through!
	
	default:
	  iChoice = 0;
	  break;
  }

  msChoice->current_choice = iChoice;
}

#endif // D_NO_KARAOKE_DEFAULT
#endif // D_OLD_LR

#ifdef D_OLD_LR
void channels_action(int num)
{
#ifdef D_UNHOOK_KAR_CHANNELS
	printf("Channels is %d\n",num);
#else
  DWORD d_Cmd;
  int iKarDMM[] = { DMM_SETTING_NORMAL, DMM_SETTING_LEFT_ONLY, DMM_SETTING_RIGHT_ONLY, DMM_SETTING_LEFT_ONLY, DMM_SETTING_RIGHT_ONLY };
  int iKarPartner[] = { PARTNER_SETTING_OFF, PARTNER_SETTING_OFF, PARTNER_SETTING_OFF, PARTNER_SETTING_ON, PARTNER_SETTING_ON };

  dbouts("\nKaraoke channels is ");
  dbouti( num );

  d_Cmd = iKarDMM[ num ];
  d_Cmd += (((DWORD)PS_UPDATE_DMM_SETTING)<<16);
  ie_send_ex(IE_CORE_UPDATE_PS, (void *)d_Cmd);

  d_Cmd = iKarPartner[ num ];
  d_Cmd += (((DWORD)PS_UPDATE_PARTNER_SETTING)<<16);
  ie_send_ex(IE_CORE_UPDATE_PS, (void *)d_Cmd);
#endif // D_UNHOOK_KAR_CHANNELS
}
#else // D_OLD_LR
/*
void channels_action(int num)
{
  choice2->action(num);
}
*/
#endif // D_OLD_LR

static void layout (void)
{

	go_CurrentLayout.m_bBigMemMap = FALSE;//USE_BIGMEMMAP_WHEN_REQUIRED;
	go_CurrentLayout.m_cPixRes = 0;
	go_CurrentLayout.m_wOriginX = 0;
	go_CurrentLayout.m_wOriginY = MS_LINE_2;
	go_CurrentLayout.m_wWidth = 720;
	go_CurrentLayout.m_wHeight = MS_MAX_LINES_SMALLMM/*144*/;
	go_CurrentLayout.m_cNbrHole = 0;
	go_CurrentLayout.m_cInitColor = 0;
	go_CurrentLayout.m_cNbrColor = 16;
	go_CurrentLayout.m_pColorPalette = (OSD_Palette *)MenuBitmapColor;

	OSDSetLayout();
	OSDSetFont(0);

	printf("KARAOKE LAYOUT\n");
}

static void on_karaoke_close(void)
{
#ifdef NO_C_STDLIB
	dbouts("\nKaraoke screen closed");
#endif
	SAFELY_DELETE(choice1)
#ifdef D_OLD_LR
	SAFELY_DELETE(choice2)
#endif
	SAFELY_DELETE(MEMBER(key_shift_slider))

#ifndef EXTERAL_ECHO	
	SAFELY_DELETE(echo_slider)
#endif //EXTERAL_ECHO	
}

void on_key_shift_change(unsigned char cur)
{
#ifdef D_UNHOOK_KAR_KEYSHIFT
	printf("key shift change to %d\n",(int)cur);
#else
  DWORD d_Cmd;
  int iKeyShift;

  dbouts("\nkey shift change to ");
  dbouti( cur );

  // Convert slider value to hardware value
  iKeyShift = ((int) cur * (oHWLimit.mMaxKeyShift * 2 + 1) / NUM_KEYSHIFT_SLIDER_STEPS) - oHWLimit.mMaxKeyShift;
  if ( iKeyShift < 0 )
  {
	iKeyShift = -iKeyShift;
	iKeyShift |= oHWLimit.mMaxKeyShift + 1;
  }
  
  d_Cmd = (((DWORD)PS_UPDATE_KARKEYSHIFT_SETTING)<<16) + (DWORD) iKeyShift;
  ie_send_ex(IE_CORE_UPDATE_PS, (void *)d_Cmd);
#endif // D_UNHOOK_KAR_KEYSHIFT
}

#ifndef EXTERAL_ECHO
void on_echo_change(unsigned char cur)
{
#ifdef D_UNHOOK_KAR_ECHO
	printf("echo change to %d\n",(int)cur);
#else
  DWORD d_Cmd;
  int iEcho;

  dbouts("\nEcho change to ");
  dbouti( cur );

  // Scale ui value to hardware range
  iEcho = (int) cur * 240 / ( NUM_ECHO_SLIDER_STEPS - 1);
  
  d_Cmd = (((DWORD)PS_UPDATE_KARECHOSCALE_SETTING)<<16) + (DWORD) iEcho;
  ie_send_ex(IE_CORE_UPDATE_PS, (void *)d_Cmd);
#endif // D_UNHOOK_KAR_ECHO
}
#endif //EXTERAL_ECHO

void kar_menu_set_3d_effect( void )
{
  EVENT evt = 0;
  void *param = NULL;

  evt = IE_CORE_UPDATE_PS;
  param = (void *)((((DWORD)PS_UPDATE_3DEFFECT_SETTING)<<16) + (DWORD) EFFECT3D_SETTING_OFF);
  ie_send_ex( evt, param );
}

void kar_action(int num)
{
#ifdef D_UNHOOK_KARAOKE
	printf("Karaoke is %d\n",num);
#else
  DWORD d_Cmd;
  int iKaraoke[] = { KARAOKE_SETTING_OFF, KARAOKE_SETTING_ON };
  int iUiValue;

  dbouts("\nKaraoke is ");
  dbouti( num );

  num = iKaraoke[ num ];
  d_Cmd = (((DWORD)PS_UPDATE_KARAOKE_SETTING)<<16) + (DWORD) num;
  ie_send_ex(IE_CORE_UPDATE_PS, (void *)d_Cmd);

  // If Karaoke is changed to off, set channels to Stereo
  if ( num == ITEMNUM_KAR_OFF )
  {
#ifdef D_OLD_LR
	channels_action( ITEMNUM_STEREO );
	choice2->current_choice = ITEMNUM_STEREO;
	kar_display( choice2 );
#else
	//lr_adjust( choice2, KARAOKE_SETTING_OFF );
	//channels_action( ITEMNUM_STEREO );
	//choice2->current_choice = ITEMNUM_STEREO;
#endif // D_OLD_LR
//	kar_display( choice2 );
	disable_karaoke_on_items();
  }
  else
  {
#ifdef D_OLD_LR
	lr_adjust( choice2, KARAOKE_SETTING_ON );
	channels_action( ITEMNUM_STEREO );
	choice2->current_choice = ITEMNUM_STEREO;
	kar_display( choice2 );
#endif	
#ifdef D_KEEP_KEYSHIFT_AND_ECHO
#else
	//kar_display( choice2 );

	iUiValue = CalcKeyShift( (int) ADP_KAR_DEFAULT_KEY_SHIFT_PAR );
	on_key_shift_change( iUiValue );
	MEMBER(key_shift_slider)->cur_ratio = iUiValue;
	slider_display( MEMBER(key_shift_slider) );
#ifndef EXTERAL_ECHO
	iUiValue = CalcEcho( (int) ADP_KAR_DEFAULT_ECHO_PAR );
	on_echo_change(iUiValue);
	echo_slider->cur_ratio = iUiValue;
	slider_display( echo_slider );
#endif //EXTERAL_ECHO
	if ( EFFECT3D_SETTING_ON == gtps.m3dEffect )
	{
	  kar_menu_set_3d_effect();
	}
#endif // D_KEEP_KEYSHIFT_AND_ECHO
	enable_karaoke_on_items();
  }
#endif // D_UNHOOK_KARAOKE
}

void open_karaoke(void)
{
	int iKeyShift;
	
	// Convert hardware value to slider value
	iKeyShift = CalcKeyShift( (int) gtps.mKarKeyShift );
	
	screen = MS_create_screen((MS_POS *)&screen_pos, screen_color, 0, on_karaoke_close,layout);
	
	
	// Create the keyshift slider
	MEMBER(key_shift_slider) = MS_create_slider((MS_POS *)&key_slider_pos,
							i_color,
							NUM_KEYSHIFT_SLIDER_STEPS - 1,
#ifdef D_NO_KEYSHIFT_DEFAULT
							16,
#else
							iKeyShift,
#endif // D_NO_KEYSHIFT_DEFAULT
							1,
							on_key_shift_change,
							NUM_KEYSHIFT_SLIDER_STEPS / 2,
							MS_HOT_SPOT|MS_SLIDER_POINT);

#ifndef EXTERAL_ECHO
	// Create the echo slider
	echo_slider = MS_create_slider((MS_POS *)&echo_slider_pos,
							i_color,
							NUM_ECHO_SLIDER_STEPS - 1,
#ifdef D_NO_ECHO_DEFAULT
							0,
#else
							// Scale ui value from hardware range
							//gtps.mKarEchoDelay * (NUM_ECHO_SLIDER_STEPS - 1) / 240,
							CalcEcho( (int) gtps.mKarEchoDelay ),
#endif // D_NO_ECHO_DEFAULT
							1,
							on_echo_change,
							-1,
							MS_HOT_SPOT);
#endif //EXTERAL_ECHO

	// Create the Karaoke on/off choice
	choice1 = MS_create_choice(&kar_pos,i_color,(MS_TEXT_LIST *)&kar_list,&pos_dont_care,kar_action,MS_HOT_SPOT);
#ifdef D_NO_KARAOKE_DEFAULT
#else
	kar_choice(choice1);
#endif // D_NO_KARAOKE_DEFAULT

#ifdef D_OLD_LR
	choice2 = MS_create_choice(&channels_pos,i_color,&channels_list,&pos_dont_care,channels_action,MS_HOT_SPOT);
#ifdef D_NO_KARAOKE_DEFAULT
#else
	channels_choice(choice2);
#endif // D_NO_KARAOKE_DEFAULT
#else
	//choice2 = open_lr_choice(&channels_pos, i_color, &pos_dont_care);
#endif // D_OLD_LR

	MS_add_item((MS_DIALOG*)screen,(MS_WIDGET*)choice1, C_FOCUSED);
#ifdef D_OLD_LR
	MS_add_item((MS_DIALOG*)screen,(MS_WIDGET*)choice2, !C_FOCUSED);
#endif
	MS_add_item((MS_DIALOG*)screen,(MS_WIDGET*)MEMBER(key_shift_slider), !C_FOCUSED);
	
#ifndef EXTERAL_ECHO	
	MS_add_item((MS_DIALOG*)screen,(MS_WIDGET*)echo_slider, !C_FOCUSED);
#endif //EXTERAL_ECHO	
	MS_add_item((MS_DIALOG*)screen,(MS_WIDGET*)&karaoke, !C_FOCUSED);
	MS_add_item((MS_DIALOG*)screen,(MS_WIDGET*)&key_shift, !C_FOCUSED);
#ifndef EXTERAL_ECHO	
	MS_add_item((MS_DIALOG*)screen,(MS_WIDGET*)&echo, !C_FOCUSED);
#endif //EXTERAL_ECHO	
#ifdef D_OLD_LR
	MS_add_item((MS_DIALOG*)screen,(MS_WIDGET*)&channels, !C_FOCUSED);
#endif

	MS_dialog_display((MS_DIALOG*)screen);
	if ( choice1->current_choice == ITEMNUM_KAR_OFF )
	{
	  disable_karaoke_on_items();
	}
}

⌨️ 快捷键说明

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