📄 cderr.c
字号:
#include "config.h"
#include "global.h"
#include "avd.h"
#include "sig.h"
#include "cd.h"
#include "func.h"
#include "cdfunc.h"
#include "util.h"
#include "cderr.h"
#include "dsa.h"
UINT32 ChkTrkTmByMSF(UINT32 msf);//Terry, 890915
extern void ircmd_stop(void);
extern int continue_audio(void);
#define SECTOR_EARLY_TIMES 40
#define SECTOR_LATE_TIMES 4
#define MP3_NEW_ERR_HANDLER
//#define MONE_CDERR_LEVEL1
//#define CDERR_RECOVER
//#define OSD_CDERR
BYTE IsMp3BufEmpty(void);
void Mp3_ChkSkipData(void);
void ShowMP3Reading(BYTE offset);
void Mp3Seek(UINT16 f,UINT8 do_goto)
{
UINT32 x;
if(do_goto&&IsMp3BufEmpty())
f+=8;
#ifdef MONE_CDERR_LEVEL1
printf("I buf:%d s:%x e:%x p:%x f:%ld len:%ld r:%d\n",IsMp3BufEmpty(),s_msf,e_msf,p_msf,f,s_len,RetryFlyingDisk);
#endif
s_msf=addmsf(s_msf,f*(1+adv_search_time*5));
x=s_len-f*2048*(1+adv_search_time*5);
if(x>0)
{
goto_active=1;
if(IsMp3BufEmpty())
p_msf=s_msf;
else
p_msf=addmsf(p_msf,f*(1+adv_search_time*5));
s_len=x;
if(do_goto)
do_cd_seek(-4);
Mp3_ChkSkipData();
}else
{
s_len=0;
AVD_SetMediaInterrupt();
}
#ifdef MONE_CDERR_LEVEL1
printf("Out s:%x e:%x p:%x f:%ld len:%ld r:%d\n",s_msf,e_msf,p_msf,f,s_len,RetryFlyingDisk);
#endif
}
void StopSeek(void)
{//terry 11/3
#ifdef MONE_CDERR_LEVEL1
printf("stop seek\n");
#endif
// NowPrint("cd stop seek\n");
cd_seek_error=8;
//cd_func_stop();
AVD_SetMediaTimeout();
regs0->cddsp_control = (RF_CDDSP_RESET|RF_CDDSP_STOP);
bad_msf=s_msf;
}
/*
** FUNCTION
** cderr_handler
**
** DESCRIPTION
** return 1 to retry
** return 0 to giveup
*/
int cderr_handler(int cderr_no)
{
UINT32 t_msf=0;
/*bondy 890913*/
if (IsAVDLinearPlay()) return 0;
if(IsAVDData())
{
cd_seek_error_max=5;//terry 11/3
}else
if(cd_type_loaded==CDROM)
cd_seek_error_max=3;//terry 11/3
else if( (!( psd_state&PSD_SEL_LIST ))&&(!( psd_state&PSD_PLAY_SEG )) )
#ifdef NEW_ERR_HANDER
cd_seek_error_max=1;//terry 11/3
#else
cd_seek_error_max=2;//terry 11/3
#endif
else
cd_seek_error_max=6;//terry 11/3
switch (cderr_no)
{
case CDERR_CRC_ERROR:
#ifdef MONE_CDERR_LEVEL1
printf("CRC error :%d,n:%ld s:%ld\n ",cd_sequencer_error,n_msf,s_msf);
#endif
cd_crc_error++;
/*if(cd_type_loaded!=CDROM)
return 0;
else if(cd_crc_error>3)
{
Mp3Seek(cd_crc_error);
}else*/
//if(cd_crc_error<3)
// return 1;
//else
return 0;
case CDERR_EARLY_SECTOR:
cd_sequencer_error++;
//cd_sequencer_error=cd_sequencer_error+cd_crc_error;
#ifdef MONE_CDERR_LEVEL1
printf("ES:%d,n:%ld s:%ld ,goto:%d\n ",cd_sequencer_error,n_msf,s_msf,goto_active);
// NowPrint("");
#endif
#ifdef OSD_CDERR
psprintf(linebuf,"ES:%d,%ld ",cd_sequencer_error,n_msf);
osd_print_f(linebuf);
#endif
if (cd_sequencer_error<cd_sequencer_max)
return 1;
cd_sequencer_error=0;
if(IsAVDData())
StopSeek();
else
{
if( (!( psd_state&PSD_SEL_LIST ))&&(!( psd_state&PSD_PLAY_SEG )) )
{
#ifndef MP3_NEW_ERR_HANDLER
s_msf=addmsf_ss(s_msf,1+adv_search_time*5);
#else
if(cd_type_loaded==CDROM)
{
Mp3Seek(3,1);
return 1;
}else
s_msf=addmsf_ss(s_msf,1+adv_search_time*5);
#endif
}else
{
s_msf=addmsf(s_msf,1);
s_msf=addmsf_ss(s_msf,adv_search_time*5);
}
goto_active=1;
do_cd_seek(-6);
}
return 1;
case CDERR_LATE_SECTOR:
//break;
#ifdef MONE_CDERR_LEVEL1
printf("LS:%d,n:%ld s:%ld psd_state:%x\n",cd_sequencer_error,n_msf,s_msf,psd_state);
// NowPrint("");
#endif
#ifdef OSD_CDERR
psprintf(linebuf,"LS:%d",cd_sequencer_error);
osd_print_f(linebuf);
#endif
//if( psd_state!=(PSD_SEL_LIST|PSD_PLAY_SEG))
if(!( psd_state&PSD_SEL_LIST ))
if(!( psd_state&PSD_PLAY_SEG ))
{
#ifdef MP3_NEW_ERR_HANDLER
if(!IsAVDData()&&(cd_type_loaded!=CDROM) ) //terry 11/3
#else
if(!IsAVDData()) //terry 11/3
#endif
{
static BYTE count=0;
t_msf=addmsf_ss(s_msf,1);
if(t_msf>n_msf)
{
count++;
if(count<5)
{
#ifdef MONE_CDERR_LEVEL1
printf("LS used:%d,n:%ld s:%ld\n",count,n_msf,s_msf);
// NowPrint("");
#endif
#ifdef MP3_NEW_ERR_HANDLER
if(ChkTrkTmByMSF(n_msf&0x00ffffff))
#else
if((cd_type_loaded==CDROM) || ChkTrkTmByMSF(n_msf&0x00ffffff))
#endif
return 0;
}
}
count=0;
}
}
cd_sequencer_error++;
if (/*IsCDNoGiveup() ||*/ cd_sequencer_error<SECTOR_LATE_TIMES)
{
/*
** seeking that sector again
*/
if (!IsAVDLinearPlay())
{
SET_CDDSP_VX(cbv_x);
SET_CDDSP_VY(cbv_y);
do_cd_seek(-5);
}
return 1;
}
if(IsAVDData())
StopSeek();
else
{
if( (!( psd_state&PSD_SEL_LIST ))&&(!( psd_state&PSD_PLAY_SEG )) )
{
t_msf=addmsf_ss(s_msf,1);
if(cd_type_loaded!=CDROM)
if( !ChkTrkTmByMSF(t_msf&0x00ffffff) )
t_msf=s_msf;
}else
{
t_msf=addmsf(s_msf,1);
}
if(t_msf>=n_msf)
{
// do_cd_seek(-6);
if(cd_type_loaded==CDROM)
{
UINT8 i;
for(i=1;i<=75;i++)
{
if(addmsf(s_msf,i)>=n_msf)
break;
}
#ifdef MONE_CDERR_LEVEL1
printf("LS used,n:%ld s:%ld\n",n_msf,s_msf);
// NowPrint("");
#endif
Mp3Seek(i,0);
}
return 0;
}else
{
cd_sequencer_error=0;
goto_active=1;
SET_CDDSP_VX(cbv_x);
SET_CDDSP_VY(cbv_y);
#ifndef MP3_NEW_ERR_HANDLER
s_msf=addmsf_ss(t_msf,adv_search_time*5);
#else
if(cd_type_loaded==CDROM)
{
Mp3Seek(3,1);
return 1;
}else
s_msf=addmsf_ss(t_msf,adv_search_time*5);
#endif
do_cd_seek(-6);
}
}
return 1;
/*
**
*/
case CDERR_SEEK_TOO_LONG:
#ifdef MONE_CDERR_LEVEL1
s_msf=s_msf&0x00ffffff;
printf("TL:%d %d %d %d %ld\n",IsAVDData(),cd_seek_error,cd_seek_error_max,goto_active,s_msf);
#endif
#ifdef OSD_CDERR
psprintf(linebuf,"TL:%d %d %ld ",cd_seek_error,goto_active,s_msf);
osd_print_f(linebuf);
#endif
cd_seek_error++;
if(IsAVDData()) //terry 11/3
{
timestamp_cd = regs0->rtc_15_0;
if(cd_type_loaded==CDROM)
{
ShowMP3Reading(cd_seek_error);
if(addmsf(bad_msf,5)>s_msf)
cd_seek_error_max=2;
}
if(cd_seek_error<cd_seek_error_max)
{
do_cd_seek(-4);
}else
StopSeek();
return 1;
}
if(cd_type_loaded!=CDROM)
{
if( cd_seek_error%cd_seek_error_max )
{
t_msf=s_msf;
}else
{
int q;
q=cd_seek_error/cd_seek_error_max;
#ifndef NEW_ERR_HANDER
if(q>10)
#else
if(q>5)
#endif
{
#ifdef MONE_CDERR_LEVEL1
printf("TL Long Jump\n");
#endif
if( (!( psd_state&PSD_SEL_LIST ))&&(!( psd_state&PSD_PLAY_SEG )) )
{
#ifdef MONE_CDERR_LEVEL1
printf("not menu\n");
#endif
t_msf = addmsf_ss(s_msf,5);
}else
{
#ifdef MONE_CDERR_LEVEL1
printf("menu\n");
#endif
t_msf = addmsf_ss(s_msf,5);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -