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

📄 dvd_cmd.c

📁 这是DVD中伺服部分的核心代码
💻 C
📖 第 1 页 / 共 5 页
字号:
 *    Compare     |  If the result of the Compare is true, then SetSystem
 *    SetSystem   |
 *----------------+-----------------------------------------------------------
 *    Compare Set |  If the result of the Compare is true, then Set
 *----------------+-----------------------------------------------------------
 *    SetSystem   |  SetSystem and then Link
 *    Link        |
 *----------------+-----------------------------------------------------------
 *    Set Link    |  Set and then Link
 *----------------+-----------------------------------------------------------
 *    Set Compare |  Set and if the result of Compare is true, then LinkSIns
 *    LinkSIns    |
 *----------------+-----------------------------------------------------------
 *    Compare &   |  If the result of the Compare is true, then Set and
 *    Set-LinkSIns|  LinkSIns
 *----------------+-----------------------------------------------------------
 *    Compare-Set |  If the result of the Compare is true, then Set, and
 *    & LinkSIns  |  LinkSIns ignoring Compare result.
 *----------------------------------------------------------------------------
 *
 */
USHORT dvd_cmd(UBYTE * buf, UBYTE what_cmd)
{
    USHORT  i;
    UBYTE   cmd_id1;         /* Command ID-1 (b63-b61) */
    UBYTE   cmd_id2;         /* Command ID-2 or I-flag for Set (b60) */
    UBYTE   set;             /* Set field/SetSystem field (b59-b56) */
    BOOLEAN cmp_i_flg;       /* I-flag for compare (b55) */
    UBYTE   compare;         /* compare field (b54-b52) */
    UBYTE   branch;          /* branch field (b51-b48) */
    UBYTE   operand[6];      /* variable definition (b47-b0) */
    BOOLEAN compare_results = 0;
    UBYTE   cmp_arg_1 = 0;   /* cmp_cmd arguments */
    USHORT  cmp_arg_2 = 0;
    UBYTE   set_arg_1 = 0;   /* set_cmd arguments */
    USHORT  set_arg_2 = 0;
    USHORT  nav_results;
    USHORT  param_changed;

#define set_i_flg cmd_id2
#define scg branch;          /* GPRMn for 1st arg of Set & Compare Instructions */
#define sdg branch;          /* GPRMn for 1st argument of Set Instruction */

#if DBG_ON(DBG_TRACE)
    DbgPrint(("dvd_cmd()\n"));
#endif

    nav_results = NAV_CONTINUE;

    /* The command may be made up of 1, 2 or 3 instructions. */
    /* First we'll look at Cmd ID-1 */
    cmd_id1 = buf[0] >> 5;
    cmd_id2 = (buf[0] >> 4) & 0x01;
    set = buf[0] & 0xF;
    cmp_i_flg = buf[1] >> 7;
    compare = (buf[1] >> 4) & 0x07;
    branch = buf[1] & 0xF;

    for (i = 0; i < 6; i++)
    {
        operand[i] = buf[2 + i];
    }


    if ((set != 0) && (cmd_id1 > 2))    /* check if set before acting on cmd */
    {
        switch (cmd_id1)
        {
        case 3:       /* Set, Compare Set or Set Link */
            set_arg_1 = operand[1] & 0x0F;
            set_arg_2 = ((USHORT) operand[2] << 8) | operand[3];
            break;

        case 4:       /* Set-Compare-LinkSIns */
            set_arg_1 = scg;
            set_arg_2 = ((USHORT) operand[0] << 8) | operand[1];
            break;

        case 5:       /* Compare & Set-LinkSIns */
        case 6:       /* Compare-Set & LinkSIns */
            set_arg_1 = sdg;
            if (set_i_flg)
            {
                set_arg_2 = ((USHORT) operand[0] << 8) | operand[1];
            }
            else
            {
                set_arg_2 = operand[0];
            }
            break;

        default:
            DbgPrint(("UNKNOWN cmd_id1=%d, %s, %d\n", cmd_id1, __FILE__, __LINE__));
            break;
        }
    }

    /*
     * the Set Compare LinkSIns is the only Command which includes a Compare,
     * but does not do the Compare as the first command
     */
    if (cmd_id1 == 4)
    {
#if DBG_ON(DBG_TRACE)
        DbgPrint(("dvd_cmd() - call set_cmd()\n"));
#endif
        set_cmd(set_i_flg, set, set_arg_1, set_arg_2);
    }

    if (compare != 0)   /* check if compare before acting on command */
    {
        switch (cmd_id1)
        {
        case 0:       /* Compare GoTo */
            cmp_arg_1 = operand[1];
            cmp_arg_2 = ((USHORT) operand[2] << 8) | operand[3];
            break;

        case 1:       /* Compare Link or Compare Jump */
            if (cmd_id2 == 0)   /* if compare link */
            {
                cmp_arg_1 = operand[1];
                cmp_arg_2 = ((USHORT) operand[2] << 8) | operand[3];
            }
            else
            {
                cmp_arg_1 = operand[4];
                cmp_arg_2 = operand[5];
            }
            break;

        case 2:       /* Compare SetSystem */
            cmp_arg_1 = operand[4];
            cmp_arg_2 = operand[5];
            break;

        case 3:       /* Compare Set */
            cmp_arg_1 = operand[0];
            cmp_arg_2 = ((USHORT) operand[4] << 8) | operand[5];
            break;

        case 4:       /* (Set) Compare LinkSIns */
            cmp_arg_1 = scg;
            cmp_arg_2 = ((USHORT) operand[2] << 8) | operand[3];
            break;

        case 5:       /* Compare & Set-LinkSIns */
        case 6:       /* Compare-Set & LinkSIns */
            if (set_i_flg)
            {
                cmp_arg_1 = operand[2];
                cmp_arg_2 = operand[3];
            }
            else
            {
                cmp_arg_1 = operand[1];
                cmp_arg_2 = ((USHORT) operand[2] << 8) | operand[3];
            }
            break;

        default:
            DbgPrint(("UNKNOWN cmd_id1=%d, %s, %d\n", cmd_id1, __FILE__, __LINE__));
            break;
        }

#if DBG_ON(DBG_TRACE)
        DbgPrint(("dvd_cmd() - call compare_cmd()\n"));
#endif

        compare_results = compare_cmd(cmp_i_flg, compare, cmp_arg_1, cmp_arg_2);
    }

    if ((compare == 0) || (compare_results))
    {
        switch (cmd_id1)
        {
        case 0:       /* Nop, GoTo or Compare GoTo */
            if (!branch)
            {
                break;  /* Nop */
            }
            else
            {
#if DBG_ON(DBG_TRACE)
                DbgPrint(("dvd_cmd() - call goto_cmd()\n"));
#endif
                nav_results = goto_cmd(branch, &operand[0]);
            }
            break;

        case 1:       /* Link, Compare Link, Jump or Compare Jump */
            if (cmd_id2 == 0)
            {
#if DBG_ON(DBG_TRACE)
                DbgPrint(("dvd_cmd() - call link_cmd()\n"));
#endif
                nav_results = link_cmd(branch, &operand[0]);
            }
            else
            {
#if DBG_ON(DBG_TRACE)
                DbgPrint(("dvd_cmd() - call jump_cmd()\n"));
#endif
                nav_results = jump_cmd(branch, &operand[0]);
            }
            break;

        case 2:       /* SetSystem, Compare SetSystem or SetSystem Link */
#if DBG_ON(DBG_TRACE)
            DbgPrint(("dvd_cmd() - call set_system_cmd()\n"));
#endif
            param_changed = set_system_cmd(set_i_flg, set, &operand[0]);

            if ( (pgc_domain == TT_PGC) && (what_cmd == BUTTON_CMD) )
            {
                if (0x01 == (param_changed & 0x01))
                {
                    update_audio_stream(sprm[SPRM_ASTN_TT_DOM], 0);
                }

                if (0x04 == (param_changed & 0x04))
                {
                    if ( (nav_state == PAUSED) || (nav_state == CELL_STILL) )
                    {
                        EnableNavCmdTimer();
                        PEiStreamCtrlResume(tPE);
                        nav_state = NORMAL_PLAYING;
                    }
                    angle_change = 2;
                    goto_angle   = (UBYTE)(sprm[SPRM_AGLN_TT_DOM]);
                }
            }

            if (branch == 0)
            {
            }
            else
            {
                nav_results = link_cmd(branch, &operand[0]);
            }
            break;

        case 3:       /* Set, Compare Set or Set Link */
            set_cmd(set_i_flg, set, set_arg_1, set_arg_2);
            if (branch == 0)
            {
                break;  /* Set */
            }
            else
            {
                nav_results = link_cmd(branch, &operand[0]);
            }
            break;

        case 4:       /* already did the set before the compare */
            nav_results = link_cmd(LINK_SINS, &operand[0]);     /* Set Compare LinkSIns */
            break;

        case 5:
            set_cmd(set_i_flg, set, set_arg_1, set_arg_2);
            nav_results = link_cmd(LINK_SINS, &operand[0]);
            break;

        case 6:       /* Compare-Set & LinkSIns */
            /* do the Link below, ignoring the Compare result */
            set_cmd(set_i_flg, set, set_arg_1, set_arg_2);
            break;

        default:
            DbgPrint(("UNKNOWN cmd_id1=%d, %s, %d\n", cmd_id1, __FILE__, __LINE__));
            break;
        }
    }

    /*
     * if Compare-Set & LinkSIns, the Link is performed regardless of the result of the Compare
     */
    if (cmd_id1 == 6)
    {
        nav_results = link_cmd(LINK_SINS, &operand[0]);
    }

    return (nav_results);
}

/**
 *  Name:           set_system_cmd
 *
 *  Description:    act on the SetSystem Command (Type 2)
 *
 *  Arguments:      set_i_flag - Immediate flag for Set argument
 *                  set_sys_opt - set system option
 *                  operand - pointer to a four byte operand buffer
 *
 *  Returns:        nothing
 *
 *  Functionality:
 *    These instructions are used to set the value of various System
 *    Parameters and to set the value and operation mode of General
 *    Parameters.
 */
USHORT set_system_cmd(UBYTE set_i_flg, UBYTE set_sys_opt, UBYTE * operand)
{
    USHORT param_changed;

#if DBG_ON(DBG_TRACE)
    DbgPrint(("set_system_cmd: ENTER\n"));
#endif

    param_changed = 0;

    switch (set_sys_opt)
    {
    case SET_STN:
        {
            /*
             * This instruction sets values for any or all of the ASTN, the
             * SPSTN and the AGLN to be presented in the TT_DOM according to
             * the settings of the A-flag, SP-flag and the AGL-flag,
             * respectively.
             */
            UBYTE a_flg;
            UBYTE astn; /* audio stream number */
            UBYTE sp_flg;
            UBYTE spstn;        /* sub-picture stream number */
            UBYTE agl_flg;
            UBYTE agln; /* angle number */
            UBYTE gprmn;        /* general parameter number */

#if DBG_ON(DBG_TRACE)
            DbgPrint(("set_system_cmd() - case SET_STN\n"));
#endif

            a_flg = operand[1] >> 7;
            sp_flg = operand[2] >> 7;
            agl_flg = operand[3] >> 7;
            if (set_i_flg)      /* set immediate values if flag set */
            {
                if (a_flg)
                {
                    /* set SPRM(1) = ASTN */
                    astn = operand[1] & 0x0F;
                    if (astn != sprm[SPRM_ASTN_TT_DOM])
                    {
                        set_sprm(SPRM_ASTN_TT_DOM, (USHORT) astn);
                        param_changed |= 0x01;
                    }
                }
                if (sp_flg)
                {
                    /* set SPRM(2) = SPSTN */
                    spstn = operand[2] & 0x7F;
                    if (spstn != sprm[SPRM_SPSTN_TT_DOM])
                    {
                        set_sprm(SPRM_SPSTN_TT_DOM, (USHORT) spstn);
#ifdef SANYO
                        dvd_system_params.subtitle_display = (spstn & 0x40) >> 6;
#endif

                        param_changed |= 0x02;
                    }
                }
                if (agl_flg)
                {
                    /* set SPRM(3) = AGLN */
                    agln = operand[3] & 0x0F;
                    if (agln != sprm[SPRM_AGLN_TT_DOM])
                    {
                        set_sprm(SPRM_AGLN_TT_DOM, (USHORT) agln);
                        param_changed |= 0x04;
                    }
                }
            }
            else
            {
                if (a_flg)
                {
                    /* set SPRM(1) = GPRM(gprmn) */
                    gprmn = (UBYTE)(get_gprm( (UBYTE) (operand[1] & 0x0F) ));
                    if (gprmn != sprm[SPRM_ASTN_TT_DOM])
                    {
                        set_sprm(SPRM_ASTN_TT_DOM, gprmn);
                        param_changed |= 0x01;
                    }
                }
                if (sp_flg)
                {
                    /* set SPRM(2) = GPRM(gprmn) */
                    gprmn = (UBYTE)(get_gprm( (UBYTE) (operand[2] & 0x0F) ));
                    if (gprmn != sprm[SPRM_SPSTN_TT_DOM])
                    {
                        set_sprm(SPRM_SPSTN_TT_DOM, gprmn);
#ifdef SANYO
                        dvd_system_params.subtitle_display = (gprmn & 0x40) >> 6;
#endif
                        param_changed |= 0x02;
                    }
                }
                if (agl_flg)
                {
                    /* set SPRM(3) = GPRM(gprmn) */
                    gprmn = (UBYTE)(get_gprm((UBYTE) (operand[3] & 0x0F) ));
                    if (gprmn != sprm[SPRM_AGLN_TT_DOM])
                    {
                        set_sprm(SPRM_AGLN_TT_DOM, gprmn);
                        param_changed |= 0x04;
                    }
                }
            }
        }
        break;

    case SET_NVTMR:
        {
            /*
             * This instruction sets the values for the NV_TMR and the
             * TT_PGCN which is to be presented the NV_TMR expires .  The
             * timer expires when the value of the NV_TMR, decremented by one
             * for every elapsed second, is changed from one.
             */
            USHORT nv_tmr;
            USHORT tt_pgcn;
            UBYTE  gprmn;

⌨️ 快捷键说明

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