📄 iso_read.c
字号:
#include "global.h"
#include "func.h"
#include "util.h"
#include "cd.h"
#include "fs9660.h"
#include "cdfs.h"
#include "cdfunc.h"
#include "osd.h"
#include "memmap.h"
#include "regmap.h"
#include "user_init.h"
#include "stdlib.h"
#include "vfd.h"
#if defined(SUPPORT_ID3_V10)||defined(SUPPORT_UDF)
#include "graph.h"
#endif
#define MSF_PVD 0x00000210 /*.. */
//#define MONE_READ_DIR
//#define MONE_READ_FILES
//#define MONE_FLOW_CTRL
//#define DEBUG_MP3
//#define MONE_ID3
#ifdef SUPPORT_UDF
#define X0 64
//#define X1 300
//#define Y0 18 // Y1-Y0=22
//#define Y1 40
#define Y4 78 //Y5-Y4=146
#define _MSF2l(mm,ss,ff) (((mm)*60+(ss))*75+(ff)-150)
#define CDRW_Sector_mapping(x) (((x/32) * 7) + x)
#define UdfVat ((UINT32 *)UDF_VAT_OFFSET) // 20020222 Matt Wang added
static UINT32 UdfVatIdxMax; // 20020222 Matt Wang added
BYTE PartitionFlag=0;
#endif // SUPPORT_UDF
/********************************************************************/
/* Global variable declaration */
/********************************************************************/
//static BYTE buf[64]; //move to global.h
UINT32 drv_loc;
UINT32 drv_size;
#ifdef SUPPORT_ID3
static BYTE buffer[64];
#endif
extern BYTE ReadPercent;
/*
** FUNCTION
**
** DESCRIPTION
**
*/
void read_iso9660_init()
{
int Res = -1;
#ifdef SUPPORT_UDF
int RetryCnt; // 20020220 Matt Wang added
UINT32 MsfNow; // 20020307 Matt Wang added//2002/4/9
#endif
#ifdef MONE_FLOW_CTRL
epp_write_slow("read_iso9660_init\n");
#endif
Gmem.gmp3.iso9660_file_cnt = 0;
Gmem.gmp3.iso9660_dir_cnt = 0;
Gmem.gmp3.mp3_dir_cnt = 0;
Gmem.gmp3.old_iso9660_file_cnt = 0;
Gmem.gmp3.refresh_dir_page = 1;
Gmem.gmp3.refresh_file_page = 1;
Gmem.gmp3.gifsSlide = 0;
Gmem.gmp3.gifsStatic = 0;
Gmem.gmp3.in_mp3_root = 0;
Gmem.gmp3.dir_page_old = 0;
Gmem.gmp3.file_page_old = 0;
// search whether NSR Descriptor exists for UDF, 20020220 Matt Wang added
#ifdef SUPPORT_UDF
UdfExistFlg= 0;
MsfNow= l2msf(16+1);////2002/4/9
#endif
#ifdef READ_MUTI_SESSION
if(SessionNs)
{
if((Res = ReadSessionData(1)) >= 0)
do_cdrom_read_one(buf, addmsf(gettrkmsf(cd_trk_lo), 0x10), 128, 64);
}
#endif /* */
#ifdef SUPPORT_GAME
do_cdrom_read_one(buf, MSF_PVD, 40, 32); //rbhung 2002.12.27 get fs9660 NES_DISC name
if(strncmp(&(buf[9]), "V2", 2) == 0)
{
bDiscType1 |= NES_DISC_GUN;
#ifdef SUPPORT_OLD_NES_DISC
//give a fake data
bDiscType = NES_DISC;
drv_size = 0xffff;
#endif
}
else
bDiscType1=0;
#endif
//psprintf(linebuf,"MSF_PVD=%6x, MsfNow=%6x\n\r",MSF_PVD,MsfNow);
//epp_write_wait(linebuf);
if(Res < 0)
do_cdrom_read_one(buf, MSF_PVD, 128, 64);
#ifdef SUPPORT_UDF
for( RetryCnt= 10; RetryCnt!=0; RetryCnt-- ) {
//psprintf(linebuf,"RetryCnt=%d\n\r",RetryCnt);
//epp_write_wait(linebuf);
do_cdrom_read_one(buf, MsfNow, 0, 16);//2002/4/9
if( iso_search_str(buf+1, "NSR02", 5) ) {
UdfExistFlg= 1;
#ifdef SUPPORT_VFDDBG
epp_write_wait("UDF disc found!\n\r"); // 20020222 Matt Wang debug
#endif // SUPPORT_VFDDBG
}
MsfNow= addmsf(MsfNow, 1);//2002/4/9
}
#endif // SUPPORT_UDF
#ifdef DEBUG_MP3
{
int i;
for(i = 0; i < 64;)
{
psprintf(linebuf, "%02x ", buf[i]);
epp_write_slow(linebuf);
i++;
if((i & 0x0f) == 0)
epp_write_slow("\n");
}
}
#endif
#ifdef SUPPORT_UDF
if( !UdfExistFlg )
#endif
{
//epp_write_wait("enter_!udfexistflg\n\r");
Gmem.gmp3.extent_dir = l2msf(endian_swap_32(getUINT32(buf + (148 - 128))));
}
#ifdef MONE_FLOW_CTRL
psprintf(linebuf, "Y:%06x\n", Gmem.gmp3.extent_dir);
epp_write_slow(linebuf);
epp_write_slow("read_iso9660_OUT\n");
#endif
}
/*
** FUNCTION
**
** DESCRIPTION
**
*/
int read_iso9660_dir(void)
{
UINT32 ptablen = 0; //Jeff 20010805 BYTE->UINT16
int pos = 0;
UINT32 loc;
UINT32 loc_msf;
ISO_PATH_TABLE *p = (ISO_PATH_TABLE *) buf;
#ifdef MONE_FLOW_CTRL
epp_write_slow("read_iso9660_dir\n");
#endif
//ShowOsdMsg("dir in",1);
//?do_cdrom_force_read (buf, extent_dir, pos, 64);
do_cdrom_read(buf, Gmem.gmp3.extent_dir, pos, 64);
do
{
#if 0
{
int i;
for(i = 0; i < 64;)
{
//psprintf (linebuf, "%02x", buf[i]);
//epp_write (linebuf);
i++;
//if ((i & 0x0f) == 0)
//epp_write ("\n");
}
}
#endif
if((Gmem.gmp3.iso9660_dir_cnt >= ISO_DIR_MAX) ||
(Gmem.gmp3.iso9660_file_cnt >= ISO_FILE_MAX))
//if (Gmem.gmp3.iso9660_dir_cnt >= ISO_DIR_MAX)
{ //add max-dir limition Jeff 20010907
break;
}
ptablen = p->len_of_dirid;
if((ptablen == 0) || (pos > 2048))
{
break;
}
pos = pos + 8 + ptablen + (ptablen & 1);
loc = endian_swap_32(getUINT32(p->location_of_ext));
loc_msf = l2msf(loc);
//? psprintf(linebuf,"loc ..%06x\n",loc);
//? epp_write(linebuf);
/*
* if ((ptablen == 1)&&(!strcmp(p->dirname,'.')))
* {
* p->dirname[0] = 'R';
* p->dirname[1] = 'O';
* p->dirname[2] = 'O';
* p->dirname[3] = 'T';
* p->dirname[4] = 0 ;
* p->len_of_dirid = 4;
* }
*/
iso9660_dir[Gmem.gmp3.iso9660_dir_cnt].loc = loc_msf;
iso9660_dir[Gmem.gmp3.iso9660_dir_cnt].dir = 0;
iso9660_assign_name(p->dirname,
iso9660_dir[Gmem.gmp3.iso9660_dir_cnt].name,
Gmem.gmp3.iso9660_dir_cnt, p->len_of_dirid, 0);
#if !defined(FILE_SYS_DEBUG)
psprintf(linebuf, "loc %x\n", loc);
epp_write_slow(linebuf);
#endif /* */
do_cdrom_read(buf, Gmem.gmp3.extent_dir, pos, 64);
#if !defined(FILE_SYS_DEBUG)
{
int i;
epp_write("[");
for(i = 0; i < ptablen; i++)
{
linebuf[0] = p->dirname[i];
linebuf[1] = '\0';
epp_write(linebuf);
}
epp_write("]\n");
}
#endif /* */
if(Gmem.gmp3.iso9660_dir_cnt > 0 &&
Gmem.gmp3.iso9660_dir_cnt < (ItemNum + 1))
{
psprintf(linebuf, "%02d:%s", Gmem.gmp3.iso9660_dir_cnt,
iso9660_dir[Gmem.gmp3.iso9660_dir_cnt].name);
check_name(linebuf, 0);
}
#ifdef MONE_READ_PATHTAB
psprintf(linebuf, "PATH TAB %02d:%s\n", Gmem.gmp3.iso9660_dir_cnt,
iso9660_dir[Gmem.gmp3.iso9660_dir_cnt].name);
vfd_buffer(linebuf);
#endif /* */
Gmem.gmp3.iso9660_dir_cnt++;
} while(1);
/* return total directory number + root directory */
#ifdef MONE_FLOW_CTRL
epp_write_slow("read_iso9660_dir_out\n");
#endif
return (Gmem.gmp3.iso9660_dir_cnt > 0 ? 1 : 0);
}
/*
** FUNCTION
**
** DESCRIPTION
**
*/
int read_iso9660_files()
{
int i;
int res; //kenny 891103
#ifdef MONE_FLOW_CTRL
epp_write("read_iso9660_files\n");
#endif
for(i = 0; i < Gmem.gmp3.iso9660_dir_cnt; i++) /* start from searching ROOT */
{
ReadPercent = (i * 100) / Gmem.gmp3.iso9660_dir_cnt;
//?flush_cache (); /*jjding 0220 */
Gmem.gmp3.old_iso9660_file_cnt = Gmem.gmp3.iso9660_file_cnt;
#ifdef MONE_READ_DIR
psprintf(linebuf, "READDIR:%d loc:%ld name:%s=====\n", i,
iso9660_dir[i].loc, iso9660_dir[i].name);
epp_write_wait(linebuf);
#endif /* */
res = rec_dir_file(iso9660_dir[i].loc, i); //kenny 891103
#ifdef SUPPORT_DISCMAN //for 716, MP3/JPEG 盒
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -