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

📄 cdctl.c

📁 ESS3890+SL原代码(1*16内存)
💻 C
📖 第 1 页 / 共 2 页
字号:
#endif /* FLASH_UPDATE */	    do {		if (forceDSAabort) return(-2);#ifdef ECHO		MIC_service();#endif	    } while (XPORT_active && (glbTimer < next_time));	    xfer_done = 1;	    TDM_found_begCDtime = 0;	}    } while (!xfer_done);    /* Victor: Because TDM will set end_of_play when CD_end is reached.		We will need to reset end_of_play here.	It should be safe because when we are getting PSD means we are not 	playing any playitem.	*/    end_of_play = 0;    return(1);}/* * Start playing from a given sector. There is no ending location! * Starting sector is specified in CD time format (i.e. MMSSFF where * each of MM/SS/FF is a BCD) * * This routine will always instruct the CD to go 10d frames earlier. * * Inputs: *	begin:		Starting CD sector time (in MMFFSS) *	vstream:	Video stream type (E0/E1/E2) *	size:		nonzero - Size of a CD sector (in bytes) *			0       - finish "step_by_step"..no init. * * Return: *	1:		successful *	0:		failure */int playSectors(begin, vstream, size)unsigned int begin, vstream;int size;{    int return_val;    if (size) {	XPORT_active = 0;	play_sector_state = PLAY_SECTOR_INIT;    }    do {	SERVO_service(1);	if (forceDSAabort==1) return(0);	return_val = playSectors_step_by_step(begin, vstream, size, 1);	if ((return_val == 2) || (return_val == 3)) {	    return (1);	}	if (return_val == 0) {	/* failed */	    return(fuzzyPlaySector(begin, size));	}	if (XPORT_active)	/* when begCDtime == currCDtime */	    return (1);    } while (1);}/***************************************************************************** Step by step playSectors.   size:		nonzero - Size of a CD sector (in bytes) 			0       - finish "step_by_step"..no init. Returns 0 on failure. Returns 1 if don't know. Returns 2 if completed. Returns 3 if fuzzy. *****************************************************************************/int playSectors_step_by_step(begin, vstream, size, fuzzy_allowed)unsigned int begin, vstream;int size, fuzzy_allowed;{    static int dsatime;    static int go_failed;    static int find_trials;    static int saveCDtime;    static unsigned int previous_time;    static int skip_after_reissued;    int status, adjdsa_time;    if (XPORT_active) 	return(1);    switch (play_sector_state) {	case PLAY_SECTOR_INIT:            XPORT_active = 0;            TDM_isCDDA = 0;	    end_of_still = 0;	    /* 	     * This routine will go through actual loading of XPORT ucode	     * and CAM only if the current code doesn't match the bit	     * stream type.	     */	    XPORT_load_ucode(vcx_bitstream_type);#if defined(ABNORMAL_VCD) || defined(ANTI_SHOCK)            if (PLAY_set_2x_speed) {		SERVO_set_speed(SET_CD_DATA_2X);                adjdsa_time = 0x10;            } else#endif	    {    		SERVO_set_speed(SET_CD_DATA_1X);#ifdef MP3		adjdsa_time = 4+20*STREAM_type;   /*0x4 fo VCD, 0x18 for MP3 disc*/#else		adjdsa_time = 4;#endif	    }	        	    vcx_user_video_stream = vstream;	    reset_dsa_go();            begCDtime	= begin;            go_failed   = 0;	    find_trials = 0;            dsatime     = adjCDtime(begCDtime, adjdsa_time, -1);	    /*forceDSAabort  = 0;            status = dsa_go_step_by_step(dsatime);	    	    */	    play_sector_state = PLAY_SECTOR_DSA_GO;	    return(1);	case PLAY_SECTOR_DSA_GO:	loop_again:	    status = dsa_go_step_by_step(dsatime);            if (!status) {		/*if (forceDSAabort) return(0);*/	/* derek */	    	if ((go_failed >= 4) || forceDSAabort) {		    DEBUGINC(1, dbgPlaySector);		    play_sector_state = PLAY_SECTOR_INIT;		    return(0);	/* Really dead */	    	} else {		    /* retry time adjustments: 5, 20, 80, 320 (seconds) */		    adjdsa_time = 			logical2physical(375*ptrLshift[go_failed<<1]);		    adjdsa_time = adjCDtime(begCDtime, adjdsa_time, 1);		    if (adjdsa_time < endCDtime) {			begCDtime = adjdsa_time;			dsatime = adjCDtime(begCDtime, 0x10, -1);			reset_dsa_go();		    }		    go_failed++;	    	}            } else if (status==2) {                play_sector_state = PLAY_SECTOR_DSA_FIND_INIT;            }            return(1);	case PLAY_SECTOR_DSA_FIND_INIT:	    XPORT_play20video(XPORT_OFFSET_PLAY_SECTOR, vstream);	    TDM_turn_on();	    if (fuzzy_allowed) {		if (find_trials >= 2) {		    DEBUGINC(1, dbgPlaySector);		    XPORT_play20video(XPORT_OFFSET_FUZZY_PLAY, vstream);   		    TDM_turn_on();		    XPORT_active = 1;		    vcx_pause = 0;		    return(3);	        }	    }	    find_trials++;	    previous_time = glbTimer;	    play_sector_state = PLAY_SECTOR_DSA_FIND;			case PLAY_SECTOR_DSA_FIND:	    check_user_input();            if (XPORT_active == 0) {		/* from MPEG4 VCD project */		if (currCDtime == 0) {		    (volatile)mvd[tdmdata];		    if (glbTimer - previous_time > 4) {			/* XPORT should be up within 1/25 second */			goto go_again;		    }		}		if (currCDtime > begCDtime) {		    goto go_again;		} 		return (1);		go_again:		/* Kill TDM ..so XPORT_active won't be set. */		mvd[tdmctl0] = 0x400;		mvd[tdmrcvslots0] = 0;		XPORT_active = 0;					go_failed = 0;		play_sector_state = PLAY_SECTOR_DSA_GO;                return(1);            } 	    /* Bingo! */	    play_sector_state = PLAY_SECTOR_INIT;	    vcx_pause = 0;	    return(2);	default: return(0);    }}/* * This routine is used to do fuzzy search. * Input: * 	time:	In CD sector format (i.e. MMSSFF where each of MM/SS/FF *		is a BCD value) *	size:	nonzero - Size of a CD sector (in bytes) *		0       - finish "step_by_step"..no init. * * Return: *	1:	successful *	0:	failure */int fuzzyPlaySector(time, size)int time, size;{    int retry = 2;    /* Only change DSA mode if the current mode is not CDROM		*/    TDM_isCDDA   = 0;	/* Data is scrambled (as opposed to CDDA)	*/    forceDSAabort  = 0;    XPORT_load_ucode(MPEG1_PS);#if defined(ABNORMAL_VCD) || defined(ANTI_SHOCK)    if (PLAY_set_2x_speed)	SERVO_set_speed(SET_CD_DATA_2X);    else#endif    SERVO_set_speed(SET_CD_DATA_1X);    do {	if (dsa_go(time)) 	    break;    } while (--retry);    /* Regardless of dsa_go is OK or not. */    XPORT_play20video(XPORT_OFFSET_FUZZY_PLAY, 0xe0);      TDM_turn_on();    if (retry) {	/* start decoding */	vcx_pause = 0;	return(1);    } else {	return(0);    }}/* * Play CDDA data from "begin" time to "end" time where both "begin" and * "end" are in absolute CD time format. * * Return: *	1:	successful *	0:	failure */#define TDM_ON_AT_TRACK_BEGIN 0 /* this delays TDM turn on until track start */int playCDDA(int track_start_time, int begin, int end){    int retry = 3;    extern RAMCODE RamCode;    /* Kill TDM so when we restart, left/right will not swap	*/    mvd[tdmctl0] = 0x400;    mvd[tdmrcvslots0] = 0;    system_audio_partial_reset(0);#ifdef FRACTINT    if (!FRACT_process_on) {	FRACT_store = FRACTINT_START1;	FRACT_process_on = 1;    }#endif    /* Only change DSA mode if the current mode is not AUDIO		*/    TDM_isCDDA = 1;	/* This is CDDA data (unscrambled PCM data)	*/    forceDSAabort  = 0;    vcx_playvideo_only = 0;	    XPORT_load_ucode(MPEG1_PS);	/* Only MPEG1_PS has CDDA ucode		*/#ifdef CD7II    SERVO_set_speed(SET_CD_AUDIO);#endif    CDDA_play_time = adjCDtime(end, track_start_time, -1);    CDDA_track_start_time = track_start_time;    do {	if (dsa_go(begin)) break;    } while (--retry); #if TDM_ON_AT_TRACK_BEGIN    if (retry) {	retry = glbTimer+ONE_SECOND; /* use "retry" as timeout */		do {	    SERVO_service(1);	    	    if (SERVO_cdtime >= track_start_time) break;	} while (retry>glbTimer);    }#endif TDM_ON_AT_TRACK_BEGIN    /*     * Regardless of dsa_go result, just turn on XPORT and TDM. Otherwise,     * if high-level doesn't retry, we'll be stuck.     */    XPORT_restart_at(XPORT_OFFSET_PLAY_CDDA, 1);    TDM_turn_on();    return(retry);}int dsa_mode(mode)int mode;{    DISP_naicigam();    currDSAmode = mode;    return (1);}/* * This function simulates real dsa_release function by set the CDDA_play_time * to a big number, so the end_of_play will not be set until a track change. * * Return: *	1:	successful */int dsa_release(unsigned int track_start, unsigned int track_end){    CDDA_play_time = adjCDtime(track_end, track_start, -1);    return (1);}void fill_screen(int color){    DISP_Info *dip;    int width;    int height;    dip = DISP_info + DISP_frame;#if defined(MP3) || defined(WMA_DEC)    /* For MP3/WMA use I-frame for display, since MP3/WMA shares B&P */    if (STREAM_type) vcx_user_video_stream = 0xe1;#endif    if ((vcx_user_video_stream == 0xe2) || (vcx_user_video_stream == 0x1e2)) {	DISP_frame = E2;        width = 704;        height = DISP_scn_height * 2;    } else {        DISP_frame = I;        width = 352;	height = 288; /* Set as PAL source */    }    vcx_VertSz = height;    DISP_change_resolution(width, height);    DISP_paint_screen(color, 0, DISP_frame);    DISP_count = 0;}

⌨️ 快捷键说明

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