fsosd.c

来自「一个不错的硬盘播放器程序,包含VFD显示程序,红外线遥控程序,硬盘读写程序,及解」· C语言 代码 · 共 636 行 · 第 1/2 页

C
636
字号
	*/
        osd_region_ptr->end = osd_region_ptr->start + (char)new_count;
      
	/* If message is too long we need to suppress region(s) that follows */
	if (region_mask & (OSD_SECT_1|OSD_SECT_2)) 
	{   /* first or second region in line */
	    if (osd_region_ptr->end > ((osd_region_ptr + 1)->start) )
	    {   /* Message overlaps next region */
		tmp_mask = (region_mask << 1);
		/* suppress display of next region */
		OSD_suppressed_regions |= tmp_mask;
		/* unset scheduled clear */   
		OSD_scheduled_regions &= ~tmp_mask;
		if (!(tmp_mask & (OSD_TRACK_REGION_MASK|OSD_TIME_REGION_MASK)))
		    OSD_displayed_regions &= ~tmp_mask;
		
		/* Fill in suppressed areas with blanks */                                  
		curr_end = (int)((osd_region_ptr + 1)->end -
				 osd_region_ptr->start);
		if (curr_end > OSD_MAX_CHAR)
		    curr_end = OSD_MAX_CHAR;
		for ( ; new_count < curr_end; new_count++) {
		    asm("nop");
		    OSD_new[new_count] = ' ';    
		}

    	       if (region_mask & OSD_SECT_1)   /* first region in line */
	       {
		  tmp_mask = (region_mask << 2);
		  if (osd_region_ptr->end > (osd_region_ptr + 2)->start)
		  {   /* Message is longer than current and next region */
		      /* Next 2 regions will be suppressed */
		      OSD_suppressed_regions |= tmp_mask;
		      OSD_scheduled_regions &= ~tmp_mask; 
		      if (!(tmp_mask & (OSD_TRACK_REGION_MASK|OSD_TIME_REGION_MASK)))
			 OSD_displayed_regions &= ~tmp_mask;
		    
		      /* Fill in suppressed areas with blanks */
		      curr_end = OSD_MAX_CHAR;
		      for ( ; new_count < curr_end; new_count++) {
		         asm("nop");
			 OSD_new[new_count] = ' '; 
		      }
		  }
                  else  /* unsuppress last region in line just in case */
		      OSD_suppressed_regions &= ~tmp_mask;
	       }
	       /* Reset end for added 'blanks' */
		if (new_count == curr_end)
		    osd_region_ptr->end = osd_region_ptr->start + curr_end;
            }
	}
	/* Restrict message length */
        if (osd_region_ptr->end > OSD_MAX_CHAR)
            osd_region_ptr->end = OSD_MAX_CHAR;
    }            

    /*
     * If a non-zero duration is specified, then schedule an event
     * at some future time to clear this message. If no duration is
     * specified, then OSD_schedule_time needs to be cleared. In any
     * case, a previous scheduled event is dumped.
     */
    {
	if (!FOSD_ShowTrack) gOSDClearTm = 5;
    else gOSD_ShowTrackTm = 2;
    FOSD_ShowTrack = 0;
	if (!duration) {
            OSD_scheduled_regions &= ~region_mask;  /* clear bit */
 	} else {
#ifdef BILINGUAL_OSD
	    if (duration != OSD_KEEP_TIMEOUT)
#endif
	    {
	    	OSD_schedule_time[region-1] = glbTimer + 
					      ((int) ONE_SECOND * duration);
            	OSD_scheduled_regions |= region_mask;  /* set bit */
	    }
	}
    
    }

    /* Set displayed and update flags */
    OSD_displayed_regions |= region_mask; 
    OSD_update_regions |= region_mask;  /* set for copy to dram */

    OSD_update_info();		/* Let this routine update the screen*/
}

/*
 * OSD_update_info():
 * This routine updates track and/or time information. Track and time
 * display can be controlled by defines.
 */
void OSD_update_info()
{
    int     i, tmp;




    /* Actual updating of OSD's DRAM locations */
    OSD_copy_data(0);
}


/*
 *  OSD_clear_region():
 *  This function is used to clear a specified OSD region.
 *
 *  Inputs:
 *      region -    OSD region to be cleared (1 to OSD_MAX_REGIONS).
 */
void
OSD_clear_region(int region)
{
    int     i;
    char    *string;
    unsigned short  tmp_mask;
    unsigned short  region_mask = ptrLshift[region-1];
  
    if ( !(OSD_displayed_regions & region_mask) )
        return;  /* no osd showing in region..don't bother */

    if ( region_mask & (OSD_TIME_REGION_MASK|OSD_TRACK_REGION_MASK) )
    {
        if (region_mask == OSD_TIME_REGION_MASK) {
            string = OSD_new_time;	    
	} else { /* TRACK_REGION */
            string = OSD_new_track;
        }
        for (i = 0; i < ( (region_mask == OSD_TIME_REGION_MASK) ?
		         OSD_TIME_SIZE : OSD_TRACK_SIZE ); i++)
        {
            string[i] = ' ';                            
        }
    }
    else  /* Generic OSD region */
    {
        EPRINTF(("I'm clearing generic\n"));
        for (i = 0; i < OSD_MAX_CHAR; i++)
        {
	    asm("nop");
            OSD_new[i] = ' ';
        }

        /* Do clean up if this region's message overlapped on other regions */
        if ( region_mask & (OSD_SECT_1|OSD_SECT_2) )
        {   /* "Unsuppress" regions */
	    /* Check adjacent region */
	    tmp_mask = region_mask << 1;
	    if (OSD_suppressed_regions & tmp_mask) { 
                OSD_suppressed_regions &= ~tmp_mask;

		/* Check last region in line, if in first section */
		if (region_mask & OSD_SECT_1) {
		    tmp_mask = region_mask << 2;
		    if (OSD_suppressed_regions & tmp_mask) { 
			OSD_suppressed_regions &= ~tmp_mask;
		    } 
		}
 	    } 
        }
	            
    }
    OSD_update_regions |= region_mask;

    OSD_copy_data(0); /* Clear OSD region */
    OSD_displayed_regions &= ~region_mask;

}

/*
 *  OSD_clear_all():
 *  This function is used to clear all of the OSD regions at once. 
 *  Calling this function is much more efficient than clearing fifteen 
 *  regions with repeated calls to OSD_clear_region().
 *
 *  NOTE: moved to osdcore.c.. used in time critical situation.
 */




#ifdef ECHO

#if !(defined(P315) || defined(CUST3))
/*
 * OSD for echo. We support up to 15 levels.
 */
#define ECHO_LEVEL_POS	6
#define CECHO_LEVEL_POS	4

unsigned char echo_msg[] = "ECHO +0 ";
#ifdef BILINGUAL_OSD
unsigned char c_echo_msg[] = { CN_HUI2, CN_SHENG1, ' ', '+', '0', ' ', 0};
#endif

void OSD_echo()
{
    int tmp, pos, cpos;
    if (vcx_echo == -1) {
 	OUTOSD(OSD_KARAOKE_REGION, MSG_mic_off, MSG_c_mic_off, 5);
    } else {
	if (vcx_echo == 0){
	    OUTOSD(OSD_KARAOKE_REGION, MSG_mic_on, MSG_c_mic_on, 5);
	} else {
	    tmp = vcx_echo;
	    pos = ECHO_LEVEL_POS;
	    cpos = CECHO_LEVEL_POS;

	    if (vcx_echo >= 10) {
		echo_msg[ECHO_LEVEL_POS] = '1';
#ifdef BILINGUAL_OSD
		c_echo_msg[CECHO_LEVEL_POS] = '1';
#endif
		tmp -= 10;
		pos++;
		cpos++;
	    }
	    
	    echo_msg[ECHO_LEVEL_POS+1] = ' ';
	    echo_msg[pos] = '0' + tmp;
#ifdef BILINGUAL_OSD
	    c_echo_msg[CECHO_LEVEL_POS+1] = ' ';
	    c_echo_msg[cpos] = '0' + tmp;
#endif

	    OUTOSD(OSD_KARAOKE_REGION, echo_msg, c_echo_msg, 5);
	}
    }
}
#endif /* #if !(defined(P315) || defined(CUST3)) */
#endif /* #ifdef ECHO */


#if !(defined(CUST3)||defined(P315))
/*
 * Display pitch/volume bar. 8 characters, one space, +/- level
 */
#if 0
PRIVATE unsigned char	pitchbarbuf[12] = "           ";  
#else
PRIVATE unsigned char	pitchbarbuf[15];
#endif
#if defined(S215) 
void OSD_pitch_bar(level,key)
int level, key;
#else
void OSD_pitch_bar(level)
int level;
#endif
{
#if defined(S215) 
    int i,j;
#else
    int i;
#endif
    for (i = 0; i < 15; i++) {
	asm("nop");
	pitchbarbuf[i] = FONT_KEYSCALE;
    }

    pitchbarbuf[15]	 = '\0';
    pitchbarbuf[0]       = FONT_KEYLOW; 
    pitchbarbuf[7]       = FONT_KEYMID;
    pitchbarbuf[14]      = FONT_KEYHIGH;
    pitchbarbuf[level+7] = FONT_KEYCURR;

    OUTOSD(OSD_KARAOKE_REGION, pitchbarbuf, pitchbarbuf, 5);

}

#endif   


#ifdef BILINGUAL_OSD
/*
 * Toggling OSD language
 * For CUST3 : NO_OSD -> Chinese -> English -> NO_OSD
 * For others: Chinese -> English -> Chinese
 */
void OSD_language_change()  
{                                 
    extern int DiscMode;
    int i, k = 1;
    unsigned short displayed_region;

	if (OSD_language == ENGLISH_OSD) {
	    OSD_language = CHINESE_OSD;
	    if (OSD_displayed_regions) {
		displayed_region = OSD_displayed_regions;
	    } else {
		displayed_region = OSD_display_backup;
		OSD_update_regions = OSD_update_backup;
		OSD_scheduled_regions = OSD_schedule_backup;
	    }
	} else {
	    displayed_region = OSD_displayed_regions;
	    OSD_language = ENGLISH_OSD;
#if (!CUST3 && !P315)
	    OUTOSD(4, "ENGLISH", "", 3);
#endif

	} 
	for (i = 0; i < OSD_MAX_REGIONS; i++) {
	    if (displayed_region & k)
		OUTOSD(i+1, english_ptr[i], chinese_ptr[i], 
		       OSD_KEEP_TIMEOUT);
	    k = k << 1;
	}
	
	    OSD_update_info();
}
#endif


⌨️ 快捷键说明

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