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

📄 svcd.c

📁 代码有点长,需细心阅读,仅供影音视听类产品的开发人员参考
💻 C
字号:
/*
** FILE
** svcd.c
**
** DESCRIPTION
** check and return current CD infomation.
** manage low-level navigation structure.
**
*/

#include "config.h"
#include "global.h"
#include "func.h"
#include "dma.h"
#include "cdxa.h"
#include "util.h"
#include "stdlib.h"

#include "cdfs.h"
#include "epp.h"
//#include "cfont.h"//no used
#include "cd.h"

#include "svcd.h"
#include "memmap.h"
#include "osd.h"
#include "fs9660.h"
#include "tx_code.h"

//#define MONE_READ_SECT
//#define MONE_READ_SEG_MSF  //Tony modified 020513
//#define MONE_CD_TYPE

/*
**
** iso9660_str  Tag (at PVD) for CDROM disc
**
** vcd_str  Tag (at INFO) for VCD
** cvd_str  Tag (at INFO) for CVD
** svcd_str Tag (at INFO) for SVCD
*/
static const char iso9660_str[5] = { 'C', 'D', '0', '0', '1' };
static const char vcd_str[8] = { 'V', 'I', 'D', 'E', 'O', '_', 'C', 'D' };
static const char tag_str[2] = { '2', '0' };
static const char cdi_str[4] = { 'C', 'D', '-', 'I' };
static const char cvd_str[8] = { 'H', 'Q', '-', 'V', 'C', 'D', ' ', ' ' };
static const char svcd_str[8] = { 'S', 'U', 'P', 'E', 'R', 'V', 'C', 'D' };
static const char oko_str[6] = { 'P', 'A', '-', 'V', 'C', 'D' };

//static const char oko1_str[8] = { 'P', 'A', '-', 'V', 'C', 'D', ' ', ' ' }; //Dr. OKO
static const char mpeg_str[4] = { 'M', 'P', 'E', 'G' };
static const char vcd30_str[7] = { 'S', '_', 'V', 'C', 'D', '3', '0' };


/*
** FUNCTION
** check_cdtype
** 
** DESCRIPTION
** this is the routine to check cd-type
*/
#define MSF_PVD             0x000210
#define MSF_INFO            0x000400
#define MSF_ENTRY           0x000401
#define MSF_ANCHOR          0x000531


#define SEGMENT_FIRST_FLAG  (1<<5)
#define IS_SEGMENT_FIRST(s) ((s)&SEGMENT_FIRST_FLAG)

/*
 * udf_find_anchor
 *
 * PURPOSE
 *      Find an anchor volume descriptor.
 *
 * PRE-CONDITIONS
 *      lastblock       Last block on media.
 *
 * POST-CONDITIONS
 *      <return>            0 if not found, other value is the LSN of anchor
 */
UINT32 udf_find_anchor(void)
{
    UINT32  anchors;
    UINT16  ident;
    UINT32  location;

    anchors = 256;
    //epp_write("udf_find_anchor\n");

    /* Search for an anchor volume descriptor pointer */

    /*  according to spec, anchor is in either:
     *     block 256
     *     lastblock-256
     *     lastblock                                  */

    //for (i=0; i<sizeof(anchors)/sizeof(UINT32); i++)
    {
        do_cdrom_prep(l2msf(anchors), 2048, 0, 0, SECT_ENTRIES);
        do_cdrom_wait();

        //HexDump(SDRAM_BASE+SECT_ENTRIES*1024,128);

        /*
         ** load first 64-byte of UDF-descriptor-Tag sector
         */
        DMA_load(VADDR_MODE_GLOBAL, SECT_ENTRIES, 0, 0, 64);
        DMA_wait();
#ifdef MONE_READ_DESCRIPTOR
        {
            int     i;

            epp_write("DESCRIPTOR_TAG...\n");
            for(i = 0; i < 64; i++)
            {
                psprintf(linebuf, "%02x,", dma_buf.b[i]);
                epp_write(linebuf);
            }
            epp_write("\n");
        }
#endif
        {
            t_descriptor_tag *p = (t_descriptor_tag *) & dma_buf.b[0];

            /*
             ** compare TAG
             */

            ident = getUINT16_li(&(p->tagIdent));
            location = getUINT32_li(&(p->tagLocation));
            //psprintf(linebuf,"ident:%x loc:%x\n",ident,location);
            //epp_write(linebuf);
            if(ident == TID_ANCHOR_VOL_DESC_PTR)
            {
                if(location == anchors)
                {
                    //epp_write("match UDF\n"); 
                    return anchors;
                }
                else
                {
                    //psprintf(linebuf,"Anchor found at block %d, location mismatch %d.\n",anchors, p->tagLocation);
                    //epp_write(linebuf);
                }
            }

        }
    }
    return 0;
}

#if 0
/*
** To count how many different characters between
** the two strings.
*/
int strdiff(const char *s1, const char *s2, int n)
{
    int     t = 0;

    for(; (n-- > 0) && (*s1 != 0) && (*s2 != 0); s1++, s2++)
        if(*s1 != *s2)
            t++;
    return t;
}
#endif
/*
**
*/
int check_cdtype()
{

    int     i;
#ifdef SAMSUNG_SERVO             //ZHX 090103
    static BYTE retry_v11=0;     
RETRY_V11:                       
#endif
 /*弄盒ぇ

⌨️ 快捷键说明

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