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

📄 gsearch.c

📁 dvr
💻 C
字号:
/*
********************************************************************************
*
* (c) Copyright 2002, Vineyard Technologies, Inc.
*
* Filename : gsearch.c
* Programmer(s): Steve KyeongHyeon Lee
* Created : 2003/05/07
* Modified :
*
* Description : 
********************************************************************************
*/
#include "types.h"

#include <stdio.h>                       /* standard I/O .h-file              */
#include "eprom.h"
#include "ghdd.h"
#include "gio.h"
#include "gsearch.h"
#include "lib.h"

//######################################################################
//
//######################################################################
extern xdata u8 gv_time_data[6];

//######################################################################
//
//######################################################################
#define REW_TIME 100

//######################################################################
//
//######################################################################

//===============================================================================
//
//===============================================================================
u32 mktime(u8 timedate[])
{
	xdata u32 year;
	xdata char mon;

	year = timedate[5]+2000;
	mon  = timedate[4];

	if (0 >= (int)(mon -= 2))
	{
		mon += 12;
		year -= 1;
	}
   return (((u32) (year/4 - year/100 + year/400 + 367*mon/12 + timedate[3] +
          year*365 - 719499)
          *24 + timedate[2])
          *60 + timedate[1])
          *60 + timedate[0]; 
}

//===============================================================================
//
//===============================================================================
u8 check_range(u32 srcTime, u8 hddIndex, u32 startLBA, u32 endLBA)
{
	xdata u8 i;
	xdata u32 stTime, edTime;
	
	u32 curLBA;

#ifdef DEBUG_SEARCH_BLOCK
	printf("\n\rcheck_range:");
#endif

	HDD_Search_LBA(hddIndex,startLBA);
	stTime = mktime(gv_time_data);

#ifdef DEBUG_SEARCH_BLOCK
	printf("\n\r [%lu] %lu ", startLBA, stTime);	disp_time(gv_time_data);
#endif

	HDD_Search_LBA(hddIndex,endLBA);
	edTime = mktime(gv_time_data);
	
#ifdef DEBUG_SEARCH_BLOCK
	printf("\n\r~[%lu] %lu ", endLBA, edTime);	disp_time(gv_time_data);
#endif
	

	if(	(srcTime >= stTime)&&
		(srcTime <= edTime))
	{
		gv_HDD_play_hdd_index = hddIndex;
		
		for(i=0; i<20;i++)
		{
			curLBA = startLBA + ((float)(endLBA-startLBA))/2;
			HDD_Search_LBA(hddIndex,curLBA);
			stTime = mktime(gv_time_data);

#ifdef DEBUG_SEARCH_BLOCK
	printf("\n\r <%lu> %lu ", curLBA, stTime);	disp_time(gv_time_data);
#endif
			if(srcTime == stTime)
			{
				gv_RCurrent_LBA[gv_HDD_play_hdd_index] = curLBA;
				break;
			}
			else if(srcTime < stTime)
			{
				endLBA = curLBA;
				gv_RCurrent_LBA[gv_HDD_play_hdd_index] = curLBA;
			}
			else if(srcTime > stTime)
			{
				startLBA = curLBA;
				gv_RCurrent_LBA[gv_HDD_play_hdd_index] = startLBA;
			}
		}

#ifdef DEBUG_SEARCH_BLOCK
		printf("\n\rFound target LBA");
#endif
		return 1;	
	}
	
#ifdef DEBUG_SEARCH_BLOCK
	printf("\n\rFail to find target LBA");
#endif

	return 0;
}

//===============================================================================
//
//===============================================================================
u8 search_block()
{
	xdata u32	src_time;
	//xdata u8 	tempWrappingFlag;
	//xdata u32	tempWCurrentLBA;
	
	dv03_enable();
#ifdef DEBUG_SEARCH_BLOCK
	printf("\n\rTarget time: "); disp_time(gv_time_data);
#endif
	
	src_time = mktime(gv_time_data);	// user input time from TIME_SEARCH_input() // [AVH]
	   
	// check master top ~ wp-1
	if(gv_WCurrent_LBA[gv_HDD_play_hdd_index]>1) 
	{
		if(	check_range(
				src_time,
				gv_HDD_play_hdd_index,
				HDD_TOP,
				(gv_WCurrent_LBA[gv_HDD_play_hdd_index]-1)
				)
			)// if hit
		{
			return 1;
		}
	}

	if(Val_EPROM_WRAPPING_FLAG[gv_HDD_play_hdd_index]) 
	{	// if hdd full
		if(gv_WCurrent_LBA[gv_HDD_play_hdd_index]<gv_HDD_size[gv_HDD_play_hdd_index])
		{
			if(	check_range(
					src_time,
					gv_HDD_play_hdd_index,
					gv_WCurrent_LBA[gv_HDD_play_hdd_index],
					(gv_HDD_size[gv_HDD_play_hdd_index]-1)
					)
				)// if hit
			{
				return 1;
			}
		}
	}
	return 0;
}

⌨️ 快捷键说明

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