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

📄 fsosd.c

📁 一个两碟控制的VCD的代码,两碟之间的转动及连续播放,已大量生产的CODE.
💻 C
📖 第 1 页 / 共 3 页
字号:
	}
    }
#endif /* not BF43 */

    osd_region_ptr = &(OSD_regions[region - 1]);
    
    /* 
     * "new_count" holds the physical number of character spaces used.
     * "msg_count" holds the logical number of characters used.
     *
     * For example, in messages that use exclusively "English" fonts,
     *	new_count == msg_count. Whereas, in messages that use only
     * "Chinese" fonts, new_count == 2*msg_count.
     */
    new_count = msg_count = 0;

#ifdef CUST4
    if (duration == OSD_BLINKING) {
	while (msg[msg_count] != '\0' && new_count < OSD_BLINK_SIZE) {
	    if (msg[msg_count] >= FONT_CSTART) {
		OSD_new[new_count] =
		OSD_blink_msg[new_count++] = msg[msg_count];
	    }

	    OSD_new[new_count] =
            OSD_blink_msg[new_count++] = msg[msg_count++];
	}
    } else 
#endif
    {
	while (msg[msg_count] != '\0' && new_count < OSD_MAX_CHAR) {
	    if (msg[msg_count] >= FONT_CSTART) {
		OSD_new[new_count++] = msg[msg_count];
	    }
 
	    OSD_new[new_count++] = msg[msg_count++];
	}
    }

/*    OSD_new[new_count] = '\0';
    EPRINTF(("osd_new: %s\n", OSD_new));
*/

    /* NOTE: "end" holds the region's last character index position + 1, 
     * so that handling of message size is simpler,i.e. "size = end-start".
     */
    /* curr_end now holds size of current message */ 
    curr_end = (int)(osd_region_ptr->end - osd_region_ptr->start); 

    /* 
     * Set end so that old msg is cleaned up...
     * We have a combination of conditions to account for when
     * resetting the end of the message to be displayed:
     *      1. Has the region been cleared ?
     *      2. If the region has not been cleared, is the new message
     *         shorter than the current message? If so, we will use
     *         the current message's "end". This serves to clean up 
     *         the currently displayed message.
     *      3. For all other cases we use the new message's "end",
     *         determined by the new message's length.
     */
    if ((new_count < curr_end) && (OSD_displayed_regions & region_mask)) {
        for ( ; new_count < curr_end; new_count++) {
	    asm("nop");
#ifdef CUST4
	    if (duration == OSD_BLINKING) 
		OSD_blink_msg[new_count] = ' ';
#endif
            OSD_new[new_count] = ' ';
	}
    }
    else {    
	/* NOTE: "end" holds the region's last character index position + 1, 
	* so that handling of message size is simpler,i.e. "size = end-start".
	*/
        osd_region_ptr->end = osd_region_ptr->start + (char)new_count;
      
#ifndef CUST4 /* Everything is sized correctly */
	/* 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;
#endif /*CUST4*/
    }            

    /*
     * 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.
     */
#ifdef CUST4
    if (duration == OSD_BLINKING) {
	    OSD_schedule_time[region-1] = glbTimer + HALF_SECOND;
	    OSD_blink_time = 0; 
	    OSD_blink_region = region;
            OSD_scheduled_regions |= region_mask;  /* set bit */
    } else 
#endif
    {
	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 */
	    }
	}
    
#ifdef CUST4
	/* In case region was previously blinking */
	if (region == OSD_blink_region) 
	    OSD_blink_region = OSD_blink_time = 0; 
#endif
    }

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

#ifdef CUST4
    /* suppress time display */
    if (region == OSD_TIME_REGION) {
	OSD_msg_override = 1;
	OSD_suppressed_regions |= OSD_TIME_REGION_MASK;
    }
#endif

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

#ifdef CUST4
/*
 * OSD_blinkit():
 * Simulate a blinking message by alternating between clearing and 
 * displaying of the message. The blinking message and corresponding 
 * region is assumed to have been initialized with a call to 
 * OSD_output(..,..,OSD_BLINKING).
 */
void OSD_blinkit(int message_is_on)
{
    int	i, osd_copy_flag;
    unsigned short region_mask = ptrLshift[OSD_blink_region-1];

   if (message_is_on) { /* clear message for ~300msec */
        for (i = 0; i < OSD_BLINK_SIZE; i++)
        {
	    asm("nop");
            OSD_new[i] = ' ';
        }
	OSD_blink_time = glbTimer + 18; /* roughly 300msec */

 	osd_copy_flag = 0;
    } else { /* put message back on for half second */
	OSD_schedule_time[OSD_blink_region-1] = glbTimer + HALF_SECOND;		
	OSD_scheduled_regions |= region_mask;
	OSD_blink_time = 0;

	/* Set displayed and update flags */
	OSD_displayed_regions |= region_mask;
 	osd_copy_flag = OSD_BLINKING;
    }
    
    OSD_update_regions |= region_mask;  /* set for copy to dram */
    OSD_copy_data(osd_copy_flag); /* blinking message */
}
#endif

/*
 * 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;

#ifdef PLAY20

   if ((screen_display) && (play_state != PLAY_MENU_STATE)
     && (play_state != PLAY_PROGRAM_STATE))
      {
	if ((servo_info & 0xffff) != (OSD_last_servo_info & 0xffff)) {
	    tmp = (OSD_time_minute << 8) | (OSD_time_second);
       
             OSD_new_time[5] = ' ';
             OSD_new_time[4] = (tmp & 0xf) + '0';
             OSD_new_time[3] = ((tmp >> 4) & 0xf) + '0';
             OSD_new_time[2] = ':';
             OSD_new_time[1] = ((tmp >> 8) & 0xf) + '0';
             OSD_new_time[0] = ((tmp >> 12) & 0xf) + '0';
             OSD_last_servo_info &= 0xffff;
             OSD_last_servo_info |= (servo_info & 0xffff);
             OSD_update_regions |= OSD_TIME_REGION_MASK;
	}
    }

   if ((screen_display) && (play_state != PLAY_MENU_STATE)
     && (play_state != PLAY_PROGRAM_STATE))
     {
	tmp = hex2bcd[cur_track_number];

       if(!cd_stop)  {
#ifdef BILINGUAL_OSD
	    if (OSD_language == CHINESE_OSD) {
		OSD_new_track[0] = CN_QU3;
		OSD_new_track[1] = ' ';
		OSD_new_track[2] = FONT_MU;
		OSD_new_track[3] = ' ';
		OSD_new_track[4] = ' ';
		OSD_new_track[5] = ' ';
              } else {
		OSD_new_track[0] = 'T';
		OSD_new_track[1] = 'R';
		OSD_new_track[2] = 'A';
		OSD_new_track[3] = 'C';
		OSD_new_track[4] = 'K';
		OSD_new_track[5] = ' ';

	    }
#else
	    OSD_new_track[0] = 'T';
	    OSD_new_track[1] = 'R';
	    OSD_new_track[2] = 'A';
	    OSD_new_track[3] = 'C';
	    OSD_new_track[4] = 'K';
	    OSD_new_track[5] = ' ';
	     
#endif
	    OSD_new_track[7] = (tmp & 0xf) + '0';
	    OSD_new_track[6] = ((tmp >> 4) & 0xf) + '0';

	} else {
#ifdef BILINGUAL_OSD
           if (OSD_language == CHINESE_OSD) {
		OSD_new_track[0] = FONT_ZHONG1;
		OSD_new_track[1] =' ';
		OSD_new_track[2] = CN_QU3;
		OSD_new_track[3] =' ';
		OSD_new_track[4] =' ';
		OSD_new_track[5] = ' ';

	    } else {
		OSD_new_track[0] = 'T';
		OSD_new_track[1] = 'O';
		OSD_new_track[2] = 'T';
		OSD_new_track[3] = 'A';
		OSD_new_track[4] = 'L';
		OSD_new_track[5] = ' ';

	    }
#else
           OSD_new_track[0] = 'T';
           OSD_new_track[1] = 'O';
           OSD_new_track[2] = 'T';
	    OSD_new_track[3] = 'A';
	    OSD_new_track[4] = 'L';
	    OSD_new_track[5] = ' ';

#endif
            OSD_new_track[7] = (bcd_num_of_track & 0xf) + '0';
            OSD_new_track[6] = ((bcd_num_of_track >> 4) & 0xf)+'0';
   	}
      OSD_update_regions |= OSD_TRACK_REGION_MASK;

    } 
#endif /* PLAY20 */

    OSD_copy_data(0);
}

#ifndef PLAYONLY

#ifdef FOUR_LINE_OSD
/*
 * OSD_update_track():
 * This routine updates track osd msg buffer. Track number is displayed
 * by PLAY_update_osd().
 *
 * NOTE:
 * This function is used when we intend on sharing track OSD region,i.e
 * OSD_TRACK_REGION = OSD_TRACK_REGION_MASK = 0. In this case,
 * OSD_update_info() won't display track OSD.
 */
void OSD_update_track(void)
{
    int bcd_cur_track;

    bcd_cur_track = hex2bcd[cur_track_number];
    OSD_new_track[3] = '/';
    OSD_new_track[2] = (bcd_cur_track & 0xf) + '0';
    OSD_new_track[1] = ((bcd_cur_track >> 4) & 0xf) + '0';
    OSD_new_track[0] = ' ';
    OSD_new_track[5] = (bcd_num_of_track & 0xf) + '0';
    OSD_new_track[4] = ((bcd_num_of_track >> 4) & 0xf)+'0';
}
#endif /* FOUR_LINE_OSD */

/*
 *  OSD_time_track():
 *  This function turns on the flags for displaying OSD time and/or track.
 *
 *  Inputs:
 *      time_track_mask - Mask specifying whether to set time and/or track
 *                        regions for display. (see example below)
 *          Example: 
 *              1. OSD_TIME_REGION_MASK|OSD_TRACK_REGION_MASK: show both time & track
 *              2. OSD_TIME_REGION_MASK:    show time only
 *              3. OSD_TRACK_REGION_MASK:   show track only
 *      duration -  Specifies the length of time(in seconds) to display
 *                  the time and track information. If '0' is specified then 
 *                  the time will be displayed indefinitely until explicitly 
 *                  cleared.
 */
void
OSD_time_track(unsigned short time_track_mask, int duration)
{
    OSD_displayed_regions |= time_track_mask;

#ifdef CUST4
    OSD_msg_override = 0;
    OSD_suppressed_regions &=  ~OSD_TIME_REGION_MASK;
#endif

    if (duration
#ifdef BILINGUAL_OSD
	&& (duration != OSD_KEEP_TIMEOUT)
#endif
	) {
	if (time_track_mask & OSD_TIME_REGION_MASK)
	    OSD_schedule_time[OSD_TIME_REGION-1] = glbTimer + 
						   ((int)ONE_SECOND * duration);
	if (time_track_mask & OSD_TRACK_REGION_MASK)
	    OSD_schedule_time[OSD_TRACK_REGION-1] = glbTimer + 
						   ((int)ONE_SECOND * duration);

        OSD_scheduled_regions |= time_track_mask;  /* set schedule bits*/
    }
    else /* Display indefinitely */
    {
        OSD_scheduled_regions &= ~(time_track_mask);  /* clear schedule bits */
    }
    
#if 0

⌨️ 快捷键说明

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