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

📄 vcd_con.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    int                  i;

    DBGPRINT(DBG_ON(DBG_TRACE), ("ENTER %s\n", __FUNCTION__));

    snprintf(filename, 50, "/mnt/cdrom/%s/lot.%s", vcd_dir, vcd_ext);

    if (LoaderFileOpen(tLoader, filename, &LotFile) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("load_vcd_lot: Failed file open!\n"));
        LotFile = 0;
        error = 0xff;
        goto errout;
    }

    if (LoaderFileRead(tLoader, LotFile, (PVOID)g_lot_addr, 2048*32, NULL) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("load_vcd_lot: Failed file read!\n"));
        error = 0xff;
        goto errout;
    }

    /* swap bytes */
    for (i=0; i<g_info_vcd.max_list_id; i++)
    {
        g_lot_addr[i] = (USHORT)MAKE_WORD( &(((UBYTE*)g_lot_addr)[i*2]));
#if DBG_ON(DBG_VERBOSE)
        DBGPRINT(DBG_ON(DBG_VERBOSE), ("lot[%i]: 0x%4x\n", i, g_lot_addr[i]));
        OS_TaskYield();
#endif
    }


errout:

    if (LotFile != 0)
    {
        LoaderFileClose(tLoader, LotFile);
    }

    return (error);
}


/*************************************************
    Function Name:  load_vcd_psd

    Purpose:    Get the desired PSD block

    Arguments:  psd block number

    Returns:    nothing

*************************************************/
UBYTE load_vcd_psd(const char* vcd_dir, const char* vcd_ext)
{
    UBYTE                error          = 0;
    LOADER_FILE_HANDLE   PsdFile        = 0;
    char                 filename[50];

    DBGPRINT(DBG_ON(DBG_TRACE), ("CALLED %s\n", __FUNCTION__));

    snprintf(filename, 50, "/mnt/cdrom/%s/psd.%s", vcd_dir, vcd_ext);

    if (LoaderFileOpen(tLoader, filename, &PsdFile) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("load_vcd_psd: Failed file open!\n"));
        PsdFile = 0;
        error = 0xff;
        goto errout;
    }

    if (LoaderFileRead(tLoader, PsdFile, (PVOID)g_psd_addr, g_info_vcd.psd_size, NULL) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("load_vcd_psd: Failed file read!\n"));
        error = 0xff;
        goto errout;
    }

#if DBG_ON(DBG_VERBOSE)
    for (int j=0; j<g_info_vcd.psd_size; j++)
    {
        printf("PSD %i = 0x%.2X\n", j, g_psd_addr[j]);
        OS_TaskYield();
    }
#endif

errout:

    if (PsdFile != 0)
    {
        LoaderFileClose(tLoader, PsdFile);
    }

    return (error);
}





/**************************************


    UNUSED FUNCTIONS BELOW THIS POINT


**************************************/





/*************************************************
    Function Name:  check_cdrom_cdda

    Purpose:    See if CD-ROM discs have CDDA tracks.

    Theory:     When we get a CD-ROM that is not a VCD, we need to see if there are any CDDA
                tracks on it.  This looks through the TOC for CDDA entries.

    Arguments:  none

    Returns:    1 if CDDA track found, 0 otherwise

*************************************************/
UBYTE check_cdrom_cdda(void)
{
    UBYTE tno, i, flag;

    tno = com_bcdtobin(g_toc_info.last.tim[0]);

    flag = 0;

    for (i = tno; i > 1; i--)
    {
        if ((g_toc_info.tno[i - 1].cont & TOC_CONTROL_FIELD_DATA_TRACK) == 0)
        {
            return(0);
        }
    }

    return(1);
}


/*************************************************
    Function Name:  set_track_params

    Purpose:    Set the proper video paramters based
                on the VCD track map.

    Theory:     The VCD track map will descibe the
                video format of each track.  With
                the parameter, the proper aspect
                values are calculated based on logical
                disc type.

    Arguments:  picture_size, 1=PAL 0=NTSC

    Returns:    nothing

*************************************************/
void set_track_params(UBYTE picture_size)
{

    //if (PEiConfigureSetAspectRatio(tPE, ASPECT_RATIO_16X9) != PE_SUCCESS)
    //{
    //    DbgPrint(("PEiConfigureSetAspectRatio() -- FAILED\n"));
    //}


    VCD_STUB_MSG;
}


/*************************************************
    Function Name:  check_karifo

    Purpose:    See if a disc is a karaoke disc.

    Theory:     Old CD-I discs that predate VCD 1.1
                can still be played but only if they
                have the KARINFO.BIH file.  If this
                file is present but no VCD files
                are present we treat it as a VCD 1.1.

    Arguments:  none

    Returns:    error

*************************************************/
UBYTE check_karifo(void)
{
    ULONG ulStartLBA;
    ULONG ulEndLBA;
    UBYTE error;
    char  kar[11];

    s_msf[0] = (0x00);
    s_msf[1] = (0x03);
    s_msf[2] = (0x00);

    e_msf[0] = (0x00);
    e_msf[1] = (0x03);
    e_msf[2] = (0x00);

    ulStartLBA = MSF_TO_LBA(s_msf[0], s_msf[1], s_msf[2]);
    ulEndLBA   = MSF_TO_LBA(e_msf[0], e_msf[1], e_msf[2]);

    UBYTE *sbuf;
    ULONG lbuf[LBUFSIZE];

    sbuf = (UBYTE*)lbuf;

    if (LoaderCDRead(tLoader, ulStartLBA, (ulEndLBA - ulStartLBA), LOADER_CD_SECTOR_MODE2_FORM1, LOADER_CDDS_USER, sbuf, LBUFSIZE) == LOADER_SUCCESS)
    {
        UBYTE i;

        for (i=0; i<11; i++)
        {
            kar[i] = sbuf[i+12];
        }

        if ( (strncmp(kar, "KARINFO.BIH", 11)) != 0 )
        {
            error = 0xff;
        }
        else
        {
            error = 0;
        }
    }
    else
    {
        error = 0xff;
    }

    return (error);
}



void set_map_value(UBYTE tno, UBYTE val)
{
    UBYTE mb_div, mb_mod, map_byte;

    if ((tno > 1)&&(tno<100))
    {
        mb_div = (tno - 2) / 8;
        mb_mod = (tno - 2) % 8;
        map_byte = g_info_vcd.map_size[mb_div];

        if (val)
        {
            map_byte |= (1 << mb_mod);
        }
        else
        {
            map_byte &= !(1 << mb_mod);
        }
        g_info_vcd.map_size[mb_div] = map_byte;
    }
}


UBYTE get_track_time(UBYTE track_bin, ULONG * time_start, ULONG * time_end)
{
    UBYTE track_bcd;
    UBYTE time_start_bcd[3], time_end_bcd[3];

    track_bcd = com_bintobcd(track_bin);

    if (track_bin > get_max_number_track())
    {
        return (FALSE);
    }
    else
    {
        com_tno_time_get(track_bcd, &time_start_bcd[0], &time_end_bcd[0]);

        *time_start = com_bcdtobin(time_start_bcd[0]) * 60 + com_bcdtobin(time_start_bcd[1]);
        *time_end = com_bcdtobin(time_end_bcd[0]) * 60 + com_bcdtobin(time_end_bcd[1]);

        return (TRUE);
    }
}


/*
 * vcd_current_track()
 *
 *  PARAMETERS:  none
 *
 *  DESCRIPTION: --- Checks the physical head
 *                   location vs. the TOC to
 *                   find out what track is currently
 *                   playing.
 *
 *  RETURNS:    Current track number.
 *
 */
UBYTE vcd_current_track(void)
{
    ULONG stime,etime,ctime;
    UBYTE new_track, s[3], e[3];

    for (new_track = 1; new_track < (cd_max_tno + 1); new_track++)
    {
         com_tno_time_get(com_bintobcd(new_track), &s[0], &e[0]);
         stime = com_tno_time_bcdtobin(&s[0]);
         etime = com_tno_time_bcdtobin(&e[0]);
         ctime = com_tno_time_bcdtobin(&pbc_play_time[1]);

         if ((ctime>=stime)&&(ctime<=etime))
         {
            return(new_track);
         }
    }

    return(0);
}


/*
 * get_disk_playing_time()
 *
 *  PARAMETERS:  None
 *
 *  DESCRIPTION:  Get the total disc playing time in seconds for VCD
 *
 *  RETURNS: The total disk playing time in seconds for VCD
 *
 */
ULONG get_disk_playing_time(void)
{
    return ((com_bcdtobin(pbc_play_time[1]) * 60) + com_bcdtobin(pbc_play_time[2]));
}

/*
 * get_title_time()
 *
 *  PARAMETERS:  None
 *
 *  DESCRIPTION: Get the title time for VCD
 *
 *  RETURNS: The title time for VCD
 *
 */
ULONG get_title_time(void)
{
    return (g_time[0] * 60 + g_time[1]);
}

/*
 * get_max_number_track()
 *
 *  PARAMETERS: None
 *
 *  DESCRIPTION:  Get the maximum number of tracks in the current VCD disc.
 *
 *  RETURNS: The maximum number of tracks in the VCD disc
 *
 */
UBYTE get_max_number_track(void)
{
    UBYTE max;

    max = cd_max_tno - 1;

    return (max);
}



/*
 * get_track_num()
 *
 *  PARAMETERS:  None
 *
 *  DESCRIPTION: Get the current VCD track number
 *
 *  RETURNS:   The current VCD track number
 *
 */
UBYTE get_track_num(void)
{
    return (g_track);
}


/*************************************************
    Function Name:  check_g_track_end

    Purpose:    Check end location of track.

    Theory:     Some discs have a lead in area for each
                track that is reported as being in the
                previous track by the TOC, but the
                header reports the new track number.
                This filters out any wacky leadin
                changes and sets it based on the TOC
                value.

    Arguments:  none

    Returns:    current track

*************************************************/
UBYTE check_g_track_end(void)
{
    UBYTE start[3], end[3];

    DBGPRINT(DBG_ON(DBG_TRACE), ("check_g_track_end: Check end location of track\n"));

    com_tno_time_get(com_bintobcd(g_track), &start[0], &end[0]);

    if ( (combine_msf(&end[0]) > combine_msf(&e_msf[0])) && (g_track != cd_max_tno) )
    {
        g_track--;
    }

    return (g_track);
}




/*
 * get_vcd_max_time()
 *
 *  FILENAME:  inter_fc.c
 *
 *  PARAMETERS:  None
 *
 *  DESCRIPTION: Get the maximum time of the vcd disk in seconds
 *
 *  RETURNS: The maximum time of the vcd disk in seconds
 *
 */
ULONG get_vcd_max_time(void)
{
    ULONG min, sec;

    min = com_bcdtobin( (UBYTE)((g_max_time >> 16) & 0xff) ) * 60;
    sec = com_bcdtobin( (UBYTE)((g_max_time >> 8) & 0xff) );

    if (VERSION_FLG > 1)
    {
        return ((min+sec) / 2 );
    }
    else
    {
        return (min + sec);
    }
}




} /* end namespace */

⌨️ 快捷键说明

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