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

📄 vcd_con.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/*****************************************************************************
******************************************************************************
**                                                                          **
**  Copyright (c) 2002 Videon Central, Inc.                                 **
**  All rights reserved.                                                    **
**                                                                          **
**  The computer program contained herein contains proprietary information  **
**  which is the property of Videon Central, Inc.  The program may be used  **
**  and/or copied only with the written permission of Videon Central, Inc.  **
**  or in accordance with the terms and conditions stipulated in the        **
**  agreement/contract under which the programs have been supplied.         **
**                                                                          **
******************************************************************************
*****************************************************************************/

/**
 * @file
 * vcd_con.c
 *
 * VCD Control Routines (Cont.)
 *
 * $Id: vcd_con.cpp,v 1.31 2006/09/28 18:33:44 mspinnenweber Exp $
 */

#include <stdlib.h>
#include "vdvd_types.h"
#include "osapi.h"
#include "usrapi.h"
#include "loader_app.h"
#include "dr_app.h"
#include "pe_app.h"
#include "vcd_app.h"
#include "vcd.h"
#include "utility.h"
#include "dbgprint.h"
#include "../dvd/timer.h"
#ifdef DMALLOC
#include "dmalloc.h"
#endif

namespace vcd {

/* MACROS AND DEFINES */
#define DEBUG_VCDCON DBG_ERROR
#define DBG_ON(x) (DEBUG_VCDCON >= x)
#define VCD_STUB_MSG DBGPRINT(DBG_ON(DBG_TRACE), ("%s, %s, %d: STUBBED\n", __FUNCTION__, __FILE__, __LINE__))



USHORT g_pg_entry[PROGRAM_MAX];     /* program/shuffle track play order array */
UBYTE  g_pg_entry_max;              /* total number of entries in g_pg_entry */
UBYTE  g_pg_play_point;             /* g_pg_entry array index, the currently playing item */

UBYTE  cd_max_tno;                  /* total number of tracks */
UBYTE  cd_max_tno_cdda;             /* total number of non-CDDA tracks */



/*************************************************
    Function Name:  com_bintobcd

    Purpose:    Convert binary numbers to BCD numbers

    Theory:     Converts a binary number to it's BCD eqivalent.

    Arguments:  binary number

    Returns:    BCD eqivalent

*************************************************/
UBYTE com_bintobcd(UBYTE bin)
{
    UBYTE bcd;

    if (bin > 99)
    {
        bcd = 0x0FF;
    }
    else
    {
        bcd = (bin / 10);
        bcd <<= 4;
        bcd |= (bin % 10);
    }

    return (bcd);
}


/*************************************************
    Function Name:  com_bcdtobin

    Purpose:    Convert binary coded decimal to binary.

    Theory:     BCD is a hexadecimal representation of
                a binary number.  VCD and CDDA are based
                on BCD numbers so translation is necessary.

    Arguments:  BCD number

    Returns:    binary number

*************************************************/
UBYTE com_bcdtobin(UBYTE bcd)
{
    return (((bcd >> 4) * 10) + (bcd & 0x0F));
}


/*************************************************
    Function Name:  com_tno_time_get

    Purpose:    Gets the MSF addresses from the TOC

    Theory:     Takes the track number and extracts the
                start and end MSF address from the TOC.

    Arguments:  track number, pointers to start and end arrays

    Returns:    error

*************************************************/
USHORT com_tno_time_get(UBYTE tno, UBYTE *first, UBYTE *end)
{
    UBYTE  index;
    UBYTE  next;
    USHORT i;
    ULONG  time;


    if ((tno >= g_toc_info.first.tim[0]) && (tno <= g_toc_info.last.tim[0]))
    {
        next = com_bcdtobin(tno);
        index = next - 1;

        first[0] = g_toc_info.tno[index].tim[0];
        first[1] = g_toc_info.tno[index].tim[1];
        first[2] = g_toc_info.tno[index].tim[2];

        if (tno == g_toc_info.last.tim[0])
        {
            end[0] = g_toc_info.out.tim[0]; /* Lead Out */
            end[1] = g_toc_info.out.tim[1];
            end[2] = g_toc_info.out.tim[2];
        }
        else
        {
            end[0] = g_toc_info.tno[next].tim[0]; /* Next Track */
            end[1] = g_toc_info.tno[next].tim[1];
            end[2] = g_toc_info.tno[next].tim[2];
        }

        /* The end address set above is actually the start address for the
         * next track so we need to adjust it by 1 frame plus a 150 sector pause */
        time = com_tno_time_bcdtobin(end);
        time -= 151;
        com_tno_time_bintobcd(time, end);
        return (OS_OK);
    }
    else
    {
        for (i = 0; i < 3; ++i)
        {
            first[i] = 0x00;
            end[i]   = 0x00;
        }

        return (0xffff);
    }
}

/*************************************************
    Function Name:  com_tno_time_bcdtobin

    Purpose:    Convert BCD time to binary time for
                track number processing.

    Theory:     Converts the Minute/Second/Frame
                format to a binary number for processing.

    Arguments:  byte pointer to a BCD number

    Returns:    binary time eqivalent

*************************************************/
ULONG com_tno_time_bcdtobin(UBYTE * bcdtim)
{
    ULONG time;

    time = ((ULONG) com_bcdtobin(bcdtim[0]) * 60 * 75);    /* min set   */
    time += ((ULONG) com_bcdtobin(bcdtim[1]) * 75);        /* sec set   */
    time += (ULONG) com_bcdtobin(bcdtim[2]);               /* frame set */
    return (time);
}

/*************************************************
    Function Name:  com_tno_tim_bintobcd

    Purpose:    Converts binary numbers to BCD eqivalents

    Theory:     Takes a binary number and converst it
                to a BCD number and puts into a byte array.

    Arguments:  binary number, pointer to the BCD number

    Returns:    nothing

*************************************************/
void com_tno_time_bintobcd(ULONG bintim, UBYTE* bcdtim)
{
    ULONG time;

    time = bintim;

    bcdtim[0] = com_bintobcd((UBYTE) (time / (60 * 75)));  /* min set */
    time = time % (60 * 75);

    bcdtim[1] = com_bintobcd((UBYTE) (time / 75));         /* sec set */
    time = time % 75;

    bcdtim[2] = com_bintobcd((UBYTE) time);                /* frame set */
}


/**********************************************/
void reset_play_point(void)
{
    /*  comment out for Sanyo program scheme, come back to it later */
#if 0
    UBYTE count = 0;

    while (g_track != g_pg_entry[g_pg_play_point])
    {
        g_pg_play_point--;

        if( g_pg_play_point >= g_pg_entry_max )
        {
            g_pg_play_point = g_pg_entry_max - 1;

            count++;

            if( count == 2 )
            {
                break;
            }
        }
    }
#endif

} /* end reset_play_point() */


/*************************************************
    Function Name:  cd_start_tno_get

    Purpose:        Get starting track number.

    Theory:         In track play, get the starting track number.

    Arguments:      play or stop?

    Returns:        track number

*************************************************/
UBYTE cd_start_tno_get(NAV_COMMAND key)
{
    UBYTE tno = 0, max_tno = 0;
    UBYTE i = 0;

    switch (g_random_mode)
    {
    case PMODE_NORMAL:
        DBGPRINT(DBG_ON(DBG_TRACE), ("cd_start_tno_get: PMODE_NORMAL\n"));

        if (key == KEY_PLAY)
        {
            tno = com_bcdtobin(g_toc_info.tno[1].tno);
        }
        else if (key == KEY_NEXT_PG)
        {
            tno = com_bcdtobin(g_toc_info.tno[1].tno);

        }
        else
        {
            /* previous */
            tno = cd_max_tno;
        }
        break;

    case PMODE_RANDOM:
        DBGPRINT(DBG_ON(DBG_TRACE), ("cd_start_tno_get: PMODE_RANDOM\n"));
        /* RANDOM  */
        max_tno = cd_max_tno;

        /* Video-CD */
        --max_tno;

        if (max_tno > PROGRAM_MAX)
        {
            max_tno = PROGRAM_MAX;
        }
        com_shuffle_get(max_tno, &g_pg_entry[0]);
        g_pg_play_point = 0;
        g_pg_entry_max = max_tno;

        /* Video-CD */
        for (i = 0; i < g_pg_entry_max; ++i)
        {
            g_pg_entry[i] += 1;
        }

        tno = (UBYTE) g_pg_entry[g_pg_play_point];
        break;

    default:
        DBGPRINT(DBG_ON(DBG_TRACE), ("cd_start_tno_get: UNKNOWN!!!!!\n"));
        break;
    }

    DBGPRINT(DBG_ON(DBG_TRACE), ("cd_start_tno_get: track number = %d\n", tno));

    return (tno);
}

/*************************************************
    Function Name:  cd_next_tno_get

    Purpose:        Get the next track number.

    Theory:         Get the track number of the next
                    desired track.

    Arguments:      none

    Returns:        track number

*************************************************/
UBYTE cd_next_tno_get(void)
{
    UBYTE tno = 0, max_tno = 0, min_tno = 0, skip = 0;

    skip = 0;

    if (g_track == 0x0FF)
    {
        return (0x0FF);
    }

    /* PLAY MODE Check */
    switch (g_random_mode)
    {
    case PMODE_NORMAL:

        tno = g_track;

        switch (g_repeat_mode)
        {
        case REPEAT_TT:       /* REPEAT 1 */
            break;

        case REPEAT_ALL:      /* REPEAT ALL */
            min_tno = com_bcdtobin(g_toc_info.tno[1].tno);
            max_tno = cd_max_tno;

            if (tno >= max_tno)
            {
                tno = min_tno;
            }
            else
            {
                ++tno;
            }
            break;

        case REPEAT_OFF:      /* REPEAT OFF */
            max_tno = cd_max_tno;
            if (tno >= max_tno)
            {
                tno = 0x0FF;    /* STOP */
                return (tno);
            }
            else
            {
                ++tno;
            }
            break;
        }
        break;

    case PMODE_RANDOM:
        switch (g_repeat_mode)
        {
        case REPEAT_TT:       /* REPEAT 1 */
            tno = (UBYTE) g_pg_entry[g_pg_play_point];
            break;

        case REPEAT_ALL:      /* REPEAT ALL */
            g_pg_play_point++;
            if ((g_pg_play_point) >= g_pg_entry_max)
            {
                tno = (UBYTE) g_pg_entry[0];
                g_pg_play_point = 0;
            }
            else
            {
                tno = (UBYTE) g_pg_entry[g_pg_play_point];
            }
            break;

        case REPEAT_OFF:      /* REPEAT OFF */
            g_pg_play_point++;
            if ((g_pg_play_point) >= g_pg_entry_max)
            {
                tno = 0x0FF;    /* STOP */
                return (tno);
            }
            else
            {
                tno = (UBYTE) g_pg_entry[g_pg_play_point];
            }
            break;
        }
        break;

    default:
        break;
    }

    return (tno);
}

/*************************************************
    Function Name:  cd_prev_tno_get

    Purpose:        Get the previous track number.

    Theory:         Get the track number of the previously
                    played track.

    Arguments:      previous track or current track again?

    Returns:        track number

*************************************************/
UBYTE cd_prev_tno_get(UBYTE prev)
{
  UBYTE tno = 0, max_tno = 0, min_tno = 0;

  if (g_track == 0x0FF)
    return (0x0FF);

  switch (g_random_mode)
  {   /* PLAY MODE Check */
    case PMODE_NORMAL:        /* NORMAL MODE */
      tno = g_track;

      switch (g_repeat_mode)
      {
        case REPEAT_TT:       /* REPEAT 1 */
          tno = g_track;
          break;

        case REPEAT_ALL:      /* REPEAT ALL */

⌨️ 快捷键说明

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