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

📄 play.cc

📁 一个两碟控制的VCD的代码,两碟之间的转动及连续播放,已大量生产的CODE.
💻 CC
📖 第 1 页 / 共 5 页
字号:
    /* 2..99 -> play track */
    if ((playitem_number > 1) && (playitem_number < 100)) {
        play_track(playitem_number - 1); /* convert to 1 base */

        cur_track_number = playitem_number - 1; /* for display purpose */
    } else if ((playitem_number > 99) && (playitem_number < 600)) {
        play_entry(playitem_number - 99); /* 100..599 -> play entry */
    } else if ((playitem_number > 999) && (playitem_number < 2980)) {
        play_segment(playitem_number - 999); /* 1000..2979 -> play segment */
    } else {
        /* wrong item number. We go to the PLAY_WAIT_TIME_STATE and
	   hopefully, we will get good play item next time after
	   time expired or user inputs.*/
	play_state = PLAY_WAIT_TIME_STATE;
    }
}

/*------------------------------------------------------------------------
  Function:

  Parameters:

  Description: This function checks if we need to adjust the
               play_item_end_time.
------------------------------------------------------------------------*/
void check_playing_time()
{
    int mmssff;

    /* if we are playing item from play list, we need to check the */
    /* playing time.                                               */
    if ((cur_list_state ==  PLAY_LIST_STATE) &&
        (play_list_playing_time > 0)) {
        mmssff = logical2physical(5*(play_list_playing_time));
        play_item_end_time =
            adjCDtime(play_item_start_time, mmssff, 1);
    }
}

/*------------------------------------------------------------------------
  Function: play_track
  Parameters:
      track_number: The track number to be played. The track number is
          1 base. For VideoCD, the mpeg track number starts at 2 is
          converted to 1 base. Fox example: If we want to play track 2
          on video CD, the track_number should be 1.
  Description:
      It plays an MPEG audio/video track.
------------------------------------------------------------------------*/
static void play_track(int track_number)
{
    int mmssff;

    /* reset bad audio frame counter to zero at the beginning */
       bad_track_len = 0;

    /* reset picture_type to normal */
    picture_type = 0xe0;
    /* update panel */
    panel_play_track(track_number);

    /* 15-08-96 Alger */
    getTrackTime(track_number, &CurrentTrackTime);
    dsa_reset();

    /* get track info */
    get_track_info(track_number, &play_item_begin_time,
                   &play_item_real_end_time,
                   &play_item_type);
    play_item_start_time = play_item_begin_time;
    play_item_end_time = play_item_real_end_time;


    /* find out whether the track contains entries */
     if ((CDinfo.type == CD_VCD) && (!PBC_on) &&
	 (PLAY_vcd_type & (VCD_TYPE_11|VCD_TYPE_20)) &&
         (play_item_type == DATA_TRACK)) {
         track_entry_number = get_track_entries(track_number,
                                                &track_entry_beg,
                                                &track_entry_end);

         track_current_entry = track_entry_beg;

         if (!intro_mode && track_entry_number > 1) {
             play_state = PLAY_ENTRY_LIST_STATE;
             return;
         }
    }

    PRINTF(("track %d, start time %x, end time %x\n", track_number,
       play_item_start_time, play_item_end_time));

    /* if we are playing item from play list, we need to check the */
    /* playing time.                                               */
    check_playing_time();

    /* set the play_end time to INTRO_TIME_MMSSFF */
    if (intro_mode) {
        mmssff = adjCDtime(play_item_start_time, INTRO_TIME_MMSSFF, 1);
        if (play_item_end_time >= mmssff) {
	    second_endCDtime = mmssff;
        }
    }

    play_item_mode = PLAY_INFO_STOP_MODE;

    /* go to play */
    play_state = PLAY_NORMAL_STATE;
    return;
}

/*------------------------------------------------------------------------
  Function: play_entry
  Parameters:
      entry_number: The entry number that this function will play.
  Description:
      Play an entry in VIDEO CD.
------------------------------------------------------------------------*/
static void play_entry(int entry_number)
{
    unsigned char track_number;

    /* get entry info */
    get_entry_info(entry_number, &track_number,
                   &play_item_start_time,  /* entry start time */
                   &play_item_real_end_time);

    /* update panel & OSD */
    cur_track_number = track_number - 1;
    panel_play_track(cur_track_number);

    /* get track info, since we play entry until track end */
    get_track_info(track_number - 1, /* logical track starts at 1 */
		   &play_item_begin_time,  /* starting time of track */
                   &play_item_real_end_time,
                   &play_item_type);
    play_item_end_time = play_item_real_end_time;

    PRINTF(("entry %d, start time %x, end time %x\n", entry_number,
       play_item_start_time, play_item_end_time));

    /* if we are playing item from play list, we need to check the */
    /* playing time.                                               */
    check_playing_time();

    play_item_mode = PLAY_INFO_STOP_MODE;
    play_item_type = DATA_TRACK;

    /* go to play */
    PRINTF(("Play Entry %d\n", entry_number));
    play_state = PLAY_NORMAL_STATE;

    return;
}

/*------------------------------------------------------------------------
  Function:play_entry_in_track

  Parameters:

  Description:
------------------------------------------------------------------------*/
static void play_entry_in_track(int entry_number)
{
    int mmssff;
    int dummy2;
    unsigned char dummy1;

    PANEL_PLAY_INDEX((entry_number - track_entry_beg + 1));

    /* get the next entry time for updating lcd in the futurte */
    if (!get_entry_info(entry_number + 1, &dummy1, &next_entry_time,
                   &dummy2)) {
        next_entry_time = x00999999;    /* no next entry */
    }

    /* since the beg_time will be modified to entry beg_time by
       play_entry function, we have to store it. */

    mmssff = play_item_begin_time;

    /* play entry */
    play_entry(entry_number);
    play_item_begin_time = mmssff;
}

/*------------------------------------------------------------------------
  Function: play_segment
  Parameters:
      segment_number
  Description:
------------------------------------------------------------------------*/
static void play_segment(int segment_number)
{
    unsigned char content;
    int           len;  /* # of segment */
    int           seconds;
    int		video_type;

    /* get segment content and play length */
    get_segment_info(segment_number, &content, &len);

    /* compute the start and end time */
    if (first_seg_ad == 0)      /* in case we do not have value. */
        first_seg_ad = 0x0500;

    seconds = bcd2hex[((first_seg_ad >> 16) & 0xff)] * 60; /* min -> sec */
    seconds += bcd2hex[(first_seg_ad >> 8) & 0xff] + (segment_number -1) * 2;
    play_item_begin_time =
        logical2physical(seconds * 75); /* Sec->Frm */
    play_item_start_time = play_item_begin_time;
    play_item_end_time =
        logical2physical((seconds + len * 2) * 75);
    play_item_real_end_time = play_item_end_time;
    play_item_type = DATA_TRACK;

    /* if we are playing item from play list, we need to check the */
    /* playing time.                                               */
    check_playing_time();

    play_item_mode = PLAY_INFO_STOP_MODE;
    PRINTF(("seg %d, start 0x%x, end 0x%x\n",
            segment_number,
            play_item_start_time,
            play_item_end_time));

    /* check play type */
    video_type = content & 0xC;        /* bit 2..3 */
    play_still_retry = 3;		/* Retry still 3 times if error	*/
    play_state = PLAY_STILL_STATE;	/* Assume it is still		*/

    if (video_type == 4) {
        seg_sel = 1;
        PRINTF(("E1\n"));
    } else
    if (video_type == 8) {
        seg_sel = 2;
        PRINTF(("E2\n"));
    } else {
    /* if the zoom level != 1, reset it */
#ifdef ZOOM
	if (zoom_level) {
	    zoom_reset();
	}
#endif
        seg_sel = 0;
	play_still_retry = 0;
        play_state = PLAY_NORMAL_STATE;
        PRINTF((" Motion\n"));
    }

    picture_type = 0xe0 | seg_sel;

    panel_play_track(0);
    cur_track_number = 0; /* Set for OSD */

    return;
}


#ifdef MDC_GAME
static void play_mdc_game(int segment_number)
{
    int           seconds;
#ifndef NEW_OSD
    OSD_clear_region(6);
    OUTOSD(1,"PLEASE WAITING ...","PLEASE WAITING ...",1);
#endif

#ifdef FU_HUASHENG
    VFD_icon(VFDICON_game_on);
#endif

    /* compute the start time */
    if (first_seg_ad == 0)      /* in case we do not have value. */
        first_seg_ad = 0x0500;  /* assume set to 00:05:00 */

    seconds = bcd2hex[((first_seg_ad >> 16) & 0xff)] * 60; /* min -> sec */
    seconds += bcd2hex[(first_seg_ad >> 8)] + (segment_number -1000) * 2;
    play_item_begin_time =
        logical2physical(seconds * 75); /* Sec->Frm */
    play_item_start_time = play_item_begin_time;

    MDC_play_game(play_item_start_time,mdc_game_list_buffer_size);

    PRINTF(("seg %d, st art 0x%x\n",
            segment_number,
            play_item_start_time));

    panel_play_track(0);
    cur_track_number = 0; /* Set for OSD */
    play_state = PLAY_WAIT_GAME_STATE;
    return;
}
#endif



/*------------------------------------------------------------------------
  Function:assign_selection_list
  Parameters:
      scratch: Is a pointer to the selection list data.
  Description:
      Assign selection data to a selection_list structure.
------------------------------------------------------------------------*/
static void assign_selection_list(unsigned char *scratch_buf)
{
    selection_list_number_of_selections = scratch_buf[2];
    selection_list_base_of_selection_number = scratch_buf[3];
    list_previous_list_offset = *((short *)(scratch_buf+6));
    list_next_list_offset = *((short *)(scratch_buf+8));
    selection_list_default_list_offset = *((short *)(scratch_buf+12));
    list_return_list_offset = *((short *)(scratch_buf+10));
    selection_list_time_out_list_offset = *((short *)(scratch_buf+14));
    selection_list_wait_time_for_timeout = scratch_buf[16];
    selection_list_loop_count_and_jump_timing = scratch_buf[17];
    selection_list_play_item_number = *((short *)(scratch_buf+18));

    selection_list_loop_count =
        (selection_list_loop_count_and_jump_timing & 0x7f); /* bit 0-6 */

    if (selection_list_play_item_number <= MAX_TRACK_NUMBER) {
        /* HACK: We ignore the jump time for track, since track might
           take a long time and user will think that the player is
           dead since the player is not accepting any new key. */
        selection_list_jump_time  = 0;
    } else {
        selection_list_jump_time =
            selection_list_loop_count_and_jump_timing & 0x80;
    }
}

/*------------------------------------------------------------------------
  Function:assign_play_list
  Parameters:
      scratch: Is a pointer to a play list data.
  Description:
      Assign selection data to a play_list structure.
------------------------------------------------------------------------*/
static void assign_play_list(unsigned char *scratch_buf)
{
    play_list_number_of_items = scratch_buf[1];
    list_previous_list_offset = *((short *)(scratch_buf+4));
    list_next_list_offset = *((short *)(scratch_buf+6));
    list_return_list_offset = *((short *)(scratch_buf+8));
    play_list_playing_time = *((short *)(scratch_buf+10));
    play_list_play_item_wait_time = scratch_buf[12];
    play_list_auto_pause_wait_time = scratch_buf[13];
    play_list_play_item_number = 1;     /* default play item */
}


#ifdef MDC_GAME
static void assign_mdc_game_list(unsigned char *scratch_buf)
{
    play_list_number_of_items = 1;
    list_previous_list_offset = *((short *)(scratch_buf+4));
    list_next_list_offset = *((short *)(scratch_buf+6));
    list_return_list_offset = list_next_list_offset;
    play_list_playing_time = 0xff;
    play_list_play_item_wait_time = 0xff;
    play_list_auto_pause_wait_time = 0xff;
    play_list_play_item_number = 1;     /* default play item */

    mdc_game_list_buffer_size = * ((short *)(scratch_buf + 10));
}
#endif

/*--------------------------------------------------------------------
   Parameters:
   begin_time   is the time in 1/64 unit when timer is set.
   expire_time  is the wait time in VIDEO CD represetation.

   Return value:
       Return 1 when time expired. Otherwise return 0.
----------------------------------------------------------------------*/
static int is_time_expired(unsigned int begin_time, short expire_time)
{
    int expire_seconds;
    int expire_time_period;     /* in 1/64 second unit */
    int time_pass;

    /* no wait */
    if (expire_time == 0)
        return (1);

    /* infinite */
    if (expire_time == 0xff)
        return (0);

    expire_seconds =
        (expire_time <= 60) ? expire_time : (expire_time - 60)*10 + 60;
    expire_time_period = expire_seconds * ONE_SECOND;

    time_pass = glbTimer - begin_time;
    if (time_pass < 0) time_pass -= 1;

    if (time_pass >= expire_time_period) {
        return (1);
    }
    return (0);
}

/*------------------------------------------------------------------------
  Function: get_random_number

  Description:
     This function returns a random value between 1 and mode_number
     (included) .

  NOTE: This function only works for mode_number <= 256
------------------------------------------------------------------------*/
#define MASK    0x57
unsigned int SeedSeed = 0xbadface;
int get_random_number(unsigned char mod_number)
{
    int number;

    if (SeedSeed & x80000000)
        SeedSeed = ((SeedSeed ^ MASK) << 1) | 1;
    else
        SeedSeed <<= 1;

    number = SeedSeed >> 24;

    while (number >= mod_number)
        number -= mod_number;

    number++;   /* get number from 1 to mod_number */

    return (number);
}

static void fill_track_list()
{
    int track_num;
    int i;

    track_list_max = 0; /* do not remove, since find_track_number
			   needs it. */

    for (i  = 0; i < CDinfo.lasttrack; i++) {
	if (shuffle_on) {
	    do {
		track_num = get_random_number(CDinfo.lasttrack);
	    } while (find_track_number(track_num));

⌨️ 快捷键说明

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