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

📄 play.old

📁 一个两碟控制的VCD的代码,两碟之间的转动及连续播放,已大量生产的CODE.
💻 OLD
📖 第 1 页 / 共 5 页
字号:

    /* 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) && (VCD_11_or_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;
        }
    }
#ifdef FOUR_LINE_OSD /* 4-line has PLAY_update_osd() to bring back OSD */
/*#ifndef FOUR_LINE_OSD  4-line has PLAY_update_osd() to bring back OSD */
    if (DiscMode & DISC_OSD_ON) {
	/* Bring back time & track */
	OSD_time_track(OSD_TIME_REGION_MASK|OSD_TRACK_REGION_MASK, 0);
    }
#endif

    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)] + (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 NGAME
static void play_game(int segment_number)
{
    int           seconds;

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

    NGAME_play_game (play_item_start_time
                     ,game_list_misc_def
                     ,game_list_buffer_size);

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

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

#ifdef DRAM_GAME
    current_key = RETURN_KEY;
#endif
    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 NGAME
static void assign_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 = *((short *)(scratch_buf+8));
    play_list_playing_time = *((short *)(scratch_buf+10));
    play_list_play_item_wait_time = 0xff;
    play_list_auto_pause_wait_time = scratch_buf[13];
    play_list_play_item_number = 1;     /* default play item */
    game_list_local_cpu_type = *((unsigned char *)(scratch_buf + 1));
    game_list_misc_def       = *((short *)(scratch_buf + 10));
    game_list_buffer_size    = *((short *)(scratch_buf +12));
}
#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 (mod_number == 0)                                  /*Terry ZHONG */
       mod_number = 1;
    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));

	    track_list_max++;
	    track_list[i] = track_num;
	} else {
	    track_list[i] = i + 1;
	}
    }

    track_list_max = CDinfo.lasttrack;

/* PV..don't want to do this when pbc on...
    cur_track_index = 0;
    cur_track_number = track_list[0];
*/
}

void show_audio_panel(int show_osd)
{
    unsigned char *msg, *c_msg;
    int region;


#ifdef   KANGHUI
    region = OSD_FUNCTION_STATUS_REGION;
#else
    region = OSD_AUDIO_REGION; /* default */
#endif

    if (audio_mode < VOCAL_LEFT_LEFT) {
	panel_vocal_mode(VOCAL_OFF);
	OSD_clear_region(OSD_VOCAL_REGION);
	vocal_assist_on = 0;
    }
    vcx_audio_channel = audio_mode;
    if (audio_mode == LEFT_LEFT) {
	panel_audio_mode(AUDIO_L_L);
	assign_osd_msg(msg, MSG_left, c_msg, MSG_c_left);
    } else if (vcx_audio_channel == RIGHT_RIGHT) {
	panel_audio_mode(AUDIO_R_R);
	assign_osd_msg(msg, MSG_right, c_msg, MSG_c_right);
    } else if (vcx_audio_channel == LEFT_RIGHT) {
	panel_audio_mode(AUDIO_L_R);
	assign_osd_msg(msg, MSG_stereo, c_msg, MSG_c_stereo);
    }
    else {
	vocal_assist_on = 1;
	vcx_audio_channel = LEFT_RIGHT;
	panel_audio_mode(AUDIO_L_R);
	if (audio_mode == VOCAL_LEFT_LEFT) {
	    panel_vocal_mode(VOCAL_LEFT);
	    assign_osd_msg(msg, MSG_vocal_left, c_msg,
			   MSG_c_vocal_left);
	}
	else if (audio_mode == VOCAL_RIGHT_RIGHT) {
	    panel_vocal_mode(VOCAL_RIGHT);
	    assign_osd_msg(msg, MSG_vocal_right, c_msg,
			   MSG_c_vocal_right);
	}

⌨️ 快捷键说明

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