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

📄 setuphandler.c

📁 神龙卡开发原代码
💻 C
字号:
/* * C Source file for setuphandler * Copyright (c) Sigma Designs 2002-2003.  All Rights Reserved. */#include "setuphandler.h"enum SETUP_ITEMS { AUDIO_SETUP = 0, VIDEO_SETUP, INI_SETUP};static int setupSel = AUDIO_SETUP;void SetupKeydownHandler(OSD_WINDOW *wPtr,DATA_POINTER ptr){	GR_EVENT *event;	int prevSel;	    event=wPtr->lastevent;	switch(event->keystroke.ch) {	// Up	case SHOW_UP_KEYDOWN:		prevSel = setupSel;		if (setupSel > 0) setupSel--;		goto Update;		break;	// Down	case SHOW_DOWN_KEYDOWN:		prevSel = setupSel;		if (setupSel < 2) setupSel++;				Update:			//UnHilite prev sel.  (Just change the bitmap number and redraw)			setupMenu[prevSel].img[7] = '0';			OsdDrawPictureEx(wPtr,SETUP_XPOS,setupMenu[prevSel].y,85,100,setupMenu[prevSel].img);							//Hilite new sel.			setupMenu[setupSel].img[7] = '1';			OsdDrawPictureEx(wPtr,SETUP_XPOS,setupMenu[setupSel].y,85,100,setupMenu[setupSel].img);						DrawSub1Menu(wPtr, setupMenu[setupSel].pSub1, setupMenu[setupSel].subItems);		break;		case SHOW_RIGHT_KEYDOWN:	case SHOW_ENTER_KEYDOWN:		if (MapSub1Handler(wPtr, setupMenu[setupSel].pSub1, setupMenu[setupSel].subItems) != -1) {			setupMenu[setupSel].img[7] = '2';			OsdDrawPictureEx(wPtr,SETUP_XPOS,setupMenu[setupSel].y,85,100,setupMenu[setupSel].img);		}		break;		// Quit	case SHOW_POWER_KEYDOWN:	case SHOW_OPEN_KEYDOWN:			case SHOW_SETUP_KEYDOWN:		//Save all parameters				SaveSettings(wPtr);		MapMainWindow(wPtr, (DATA_POINTER)GR_TRUE);				break;			default:		break;	}}void MapSetupHandler(OSD_WINDOW *wPtr, DATA_POINTER dptr){	int reset = (int)dptr;	wPtr->KbdHandler = SetupKeydownHandler;	wPtr->KbdHandler_dptr = NULL;		if (reset) {		setupSel = AUDIO_SETUP;		GrDestroyTimer(wPtr->osdTid);		GrClearWindow(wPtr->wid, GR_FALSE);				//Redraw all buttons		setupMenu[VIDEO_SETUP].img[7] = '0';		OsdDrawPictureEx(wPtr, SETUP_XPOS, setupMenu[VIDEO_SETUP].y, 85, 100, setupMenu[VIDEO_SETUP].img);		setupMenu[INI_SETUP].img[7] = '0';		OsdDrawPictureEx(wPtr, SETUP_XPOS, setupMenu[INI_SETUP].y, 85, 100, setupMenu[INI_SETUP].img);	}			//Change image name to on	setupMenu[setupSel].img[7] = '1';	OsdDrawPictureEx(wPtr,SETUP_XPOS,setupMenu[setupSel].y,SETUP_WIDTH,SETUP_HEIGHT,setupMenu[setupSel].img);	DrawSub1Menu(wPtr, (SUB_ITEM *)setupMenu[setupSel].pSub1,setupMenu[setupSel].subItems);	return;}//Use current foreground colorstatic void DrawSquare(GR_WINDOW_ID wid, GR_GC_ID gc, GR_COORD x, GR_COORD y){	GrPoint(wid,gc,x,y);	GrPoint(wid,gc,x+1,y);	GrPoint(wid,gc,x,y+1);	GrPoint(wid,gc,x+1,y+1);}static void DrawOutline(GR_WINDOW_ID wid, GR_GC_ID gc, GR_RECT *rect){	GR_COORD x, y, x2,y2;		x = rect->x;  				y = rect->y;	x2 = x + rect->width - 1; 	y2 = y + rect->height - 1;		GrLine(wid, gc, x+4,y, x2-4, y);	GrLine(wid, gc, x+4,y+1, x2-4, y+1);		DrawSquare(wid,gc,x+2,y+1);	DrawSquare(wid,gc,x+1,y+2);		GrLine(wid, gc, x,  y+4, x,   y2-4);	GrLine(wid, gc, x+1,y+4, x+1, y2-4);		DrawSquare(wid,gc,x+1,y2-3);	DrawSquare(wid,gc,x+2,y2-2);				GrLine(wid, gc, x+4,y2, x2-4, y2);	GrLine(wid, gc, x+4,y2-1, x2-4, y2-1);		DrawSquare(wid,gc,x2-2,y2-3);	DrawSquare(wid,gc,x2-3,y2-2);			GrLine(wid, gc, x2,  y+4, x2, y2-4);	GrLine(wid, gc, x2-1,y+4, x2-1, y2-4);		DrawSquare(wid,gc,x2-3,y+1);	DrawSquare(wid,gc,x2-2,y+2);}void DrawHilite(OSD_WINDOW *wPtr, GR_RECT *rect){		GrSetGCForeground(wPtr->gc_pal6, MWPALINDEX(244));	DrawOutline(wPtr->wid, wPtr->gc_pal6, rect);	GrSetGCForeground(wPtr->gc_pal6, MWPALINDEX(6));	}void DrawUnHilite(OSD_WINDOW *wPtr, GR_RECT *rect){		//GrSetGCForeground(wPtr->gc, MWPALINDEX(6));	DrawOutline(wPtr->wid, wPtr->gc_pal6, rect);}#if 0void DrawSelect(OSD_WINDOW *wPtr, GR_RECT *rect){	GR_COORD x = rect->x;	GR_COORD y = rect->y;	GR_SIZE w = rect->width;	GR_SIZE h = rect->height;		GrSetGCForeground (wPtr->gc, MWPALINDEX(139));		GrRect(wPtr->wid, wPtr->gc, x-1, y-1, w+2, h+2);		GrRect(wPtr->wid, wPtr->gc, x-2, y-2, w+4, h+4);		GrRect(wPtr->wid, wPtr->gc, x-3, y-3, w+6, h+6);		GrRect(wPtr->wid, wPtr->gc, x-4, y-4, w+8, h+8);	}#endifvoid DrawUpperLeft(GR_WINDOW_ID wid, GR_GC_ID gc, GR_COORD x, GR_COORD y){	//Upper left corner	GrPoint(wid,gc,x,y);	GrPoint(wid,gc,x+1,y);	GrPoint(wid,gc,x+2,y);	GrPoint(wid,gc,x+3,y);	GrPoint(wid,gc,x,y+1);	GrPoint(wid,gc,x,y+2);	GrPoint(wid,gc,x,y+3);	GrPoint(wid,gc,x+1,y+1);}void DrawLowerLeft(GR_WINDOW_ID wid, GR_GC_ID gc, GR_COORD x, GR_COORD y){	GrPoint(wid,gc,x,y);	GrPoint(wid,gc,x+1,y);	GrPoint(wid,gc,x+2,y);	GrPoint(wid,gc,x+3,y);	GrPoint(wid,gc,x,y-1);	GrPoint(wid,gc,x,y-2);	GrPoint(wid,gc,x,y-3);	GrPoint(wid,gc,x+1,y-1);	}void DrawUpperRight(GR_WINDOW_ID wid, GR_GC_ID gc, GR_COORD x, GR_COORD y){	GrPoint(wid,gc,x,y);	GrPoint(wid,gc,x-1,y);	GrPoint(wid,gc,x-2,y);	GrPoint(wid,gc,x-3,y);	GrPoint(wid,gc,x,y+1);	GrPoint(wid,gc,x,y+2);	GrPoint(wid,gc,x,y+3);	GrPoint(wid,gc,x-1,y+1);}void DrawLowerRight(GR_WINDOW_ID wid, GR_GC_ID gc, GR_COORD x, GR_COORD y){	GrPoint(wid,gc,x,y);	GrPoint(wid,gc,x-1,y);	GrPoint(wid,gc,x-2,y);	GrPoint(wid,gc,x-3,y);	GrPoint(wid,gc,x,y-1);	GrPoint(wid,gc,x,y-2);	GrPoint(wid,gc,x,y-3);	GrPoint(wid,gc,x-1,y-1);}void DrawButton(OSD_WINDOW *wPtr, GR_RECT *rect){		GR_COORD x = rect->x;	GR_COORD y = rect->y;	GR_SIZE w = rect->width;	GR_SIZE h = rect->height;	GR_COORD x2 = x + w - 1;	GR_COORD y2 = y + h - 1;	GR_WINDOW_ID wid = wPtr->wid;		//GrSetGCForeground (wPtr->gc, MWPALINDEX(6));	GrFillRect(wid, wPtr->gc_pal6, x, y, w, h);		//GrSetGCForeground (wPtr->gc, MWPALINDEX(0));		DrawUpperLeft(wid, wPtr->gc_pal0, x, y);	DrawLowerLeft(wid, wPtr->gc_pal0, x, y2);	DrawLowerRight(wid, wPtr->gc_pal0, x2, y2);	DrawUpperRight(wid, wPtr->gc_pal0, x2, y);	}static GR_PIXELVAL *saveSettingPixels;void SaveSettings(OSD_WINDOW *wPtr){	audio_setting _audio_setting;	ini_setting _ini_setting;	video_setting _video_setting;	dvi_setting _dvi_setting;				SaveRect(wPtr, &saveSettingPixels, (620-250),40, 250, 54, MWPALINDEX(6));	DrawOsd(wPtr,"img/wait.png",OSD_NO_TIMEOUT);	_audio_setting.audioOut = audSub1[0].selected;	_video_setting.HDOut = vidSub1[0].selected;	_video_setting.DVIOut = vidSub1[1].selected;	_video_setting.TVOut = vidSub1[2].selected;	_ini_setting.PBC = iniSub1[0].selected;	_ini_setting.Parental = iniSub1[1].selected;	_ini_setting.TVType = iniSub1[2].selected;	_ini_setting.Password = iniSub1[3].selected;		_ini_setting.OSDLanguage = 0;	//iniSub1[4].selected;	_ini_setting.ScreenSaver = 0;	//iniSub1[5].selected;		_ini_setting.RegionCode = regionCode;	_ini_setting.Macrovision = mcrovision;							_dvi_setting.HorFreq = atoi(DVISettings[0][0].val);	_dvi_setting.VerFreq = atoi(DVISettings[0][1].val);	_dvi_setting.VidWidth = atoi(DVISettings[1][0].val);	_dvi_setting.VidHeight = atoi(DVISettings[1][1].val);	_dvi_setting.HSyncTotal = atoi(DVISettings[2][0].val);	_dvi_setting.PreHSync = atoi(DVISettings[2][1].val);	_dvi_setting.HSyncActive = atoi(DVISettings[3][0].val);	_dvi_setting.PostHSync = atoi(DVISettings[3][1].val);		_dvi_setting.VSyncTotal = atoi(DVISettings[4][0].val);	_dvi_setting.PreVSync = atoi(DVISettings[4][1].val);	_dvi_setting.VSyncActive = atoi(DVISettings[5][0].val);	_dvi_setting.PostVSync = atoi(DVISettings[5][1].val);	_dvi_setting.HSyncPolarity = atoi(DVISettings[6][0].val);	_dvi_setting.VSyncPolarity = atoi(DVISettings[6][1].val);		SavePlayerSetup(&_audio_setting, &_video_setting, &_ini_setting, &_dvi_setting);	RestoreRect(wPtr,&saveSettingPixels, (620-250),40, 250, 54);	}void InitPlayerSetup(audio_setting *a, video_setting *v, ini_setting *i, dvi_setting *dvi){	audSub1[0].selected = a->audioOut;	vidSub1[0].selected = v->HDOut;	vidSub1[1].selected = v->DVIOut;	vidSub1[2].selected = v->TVOut;	iniSub1[0].selected = i->PBC;	iniSub1[1].selected = i->Parental;	iniSub1[2].selected = i->TVType;	iniSub1[3].selected = (i->Password > 9999)?9999:i->Password;	//iniSub1[4].selected = i->OSDLanguage;	//iniSub1[5].selected = i->ScreenSaver;	if (v->ScartOut == SCART_OUT_FALSE) {		tvOut[2].enabled = GR_FALSE;		tvOut[5].enabled = GR_FALSE;	}			regionCode = i->RegionCode;	mcrovision = i->Macrovision;			itoa(dvi->HorFreq, DVISettings[0][0].val,5);	itoa(dvi->VerFreq, DVISettings[0][1].val,4);	itoa(dvi->VidWidth, DVISettings[1][0].val,4);	itoa(dvi->VidHeight, DVISettings[1][1].val,4);	itoa(dvi->HSyncTotal, DVISettings[2][0].val,4);		itoa(dvi->PreHSync, DVISettings[2][1].val,4);		itoa(dvi->HSyncActive, DVISettings[3][0].val,4);	itoa(dvi->PostHSync, DVISettings[3][1].val,4);	itoa(dvi->VSyncTotal, DVISettings[4][0].val,4);	itoa(dvi->PreVSync, DVISettings[4][1].val,4);	itoa(dvi->VSyncActive, DVISettings[5][0].val,4);	itoa(dvi->PostVSync, DVISettings[5][1].val,4);	itoa(dvi->HSyncPolarity, DVISettings[6][0].val,4);	itoa(dvi->VSyncPolarity, DVISettings[6][1].val,4);}

⌨️ 快捷键说明

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