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

📄 dvd_cmd.c

📁 这是DVD中伺服部分的核心代码
💻 C
📖 第 1 页 / 共 5 页
字号:
#endif

    return (retval);
}

/**
 **  Name:           jump_ss (user function Menu_Call (Menu ID) )
 **
 **  Arguments:      None
 **
 **  Returns:        pgc_play status
 **
 **  Functionality:
 *    1) Stop the current presentation.
 *    2) Stop the count down of Navigation Timer and maintain the Navigation Timer value.
 *       Stop the count up of GPRMs in Counter mode and maintain the value.
 */
USHORT jump_ss(UBYTE domain_id, UBYTE menu_id, UBYTE vts_ttn, UBYTE vtsn, USHORT vmgm_pgcn)
{
    USHORT retval = NAV_PRE_CMD, i;
    ULONG  out_msg[4];

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

#if REPEAT_MODE != REPEAT_MODE_1
    if ( (repeat_mode == REPEAT_A_B) && A_B_count )
    {
        /* clear the repeat_mode */
        repeat_mode = REPEAT_OFF;
        A_B_count = 0;
        out_msg[0] = VDVD_STATUS_PROHIBITED;
        out_msg[1] = 0;
        if (UsrEventHandler(out_msg) != USR_SUCCESS)
        {
            DbgPrint(("\nUsrEventHandler FAILURE, %s, %d\n\n", __FILE__, __LINE__));
        }
    }
#else
    if (repeat_mode != REPEAT_OFF)
    {
        repeat_mode = REPEAT_OFF;
        A_B_count = repeat_count = 0;
        UsrSendRepeatEvent(VDVD_INFO_REPEAT_OFF);
    }
#endif

    switch (domain_id)
    {
    case FP_DOM:
        /* start execution of the first play PGC */
#if DBG_ON(DBG_TRACE)
        DbgPrint(("jump_ss: FP_DOM\n"));
#endif
        pgc_domain = FP_PGC;
        parse_pgci(&next_pgcn);
        break;

    case VMGM_DOM:
        /* start execution of the entry PGC (or entry PGC block) of the title menu in VMGM_DOM */
#if DBG_ON(DBG_TRACE)
        DbgPrint(("jump_ss: VMGM_DOM\n"));
#endif
        next_pgn = 1;
        next_pgcn = 1;

        if (dvd_title_menu(&next_pgcn) != SUCCESS)
        {
            retval = NAV_STOP;
            break;
        }

        next_cell = pgc_pgmap[0];
        break;

    case VTSM_DOM:
        /* start execution of the entry PGC (or entry PGC block) of the menu in the
         * VTSM_DOM which is specified by the menu ID and the VTSN */

#if DBG_ON(DBG_TRACE)
        DbgPrint(("jump_ss: VTSM_DOM, next_pgcn=%x\n", (int)next_pgcn));
#endif

        if (dvd_vts_menu(menu_id, vtsn, vts_ttn, &next_pgcn) != SUCCESS)
        {
            retval = NAV_STOP;
            break;
        }
        set_sprm(SPRM_VTS_TTN_TT_DOM, vts_ttn);

        for (i = 0; i < tt_srpti.tt_srp_n; i++)
        {
            if ((tt_srp[i].vts_ttn == vts_ttn) &&
                (tt_srp[i].vtsn == vtsn))
            {
                set_sprm(SPRM_TTN_TT_DOM, (USHORT) (i + 1));
                break;
            }
        }

        next_pgn = 1;
        next_cell = pgc_pgmap[0];
        break;

    case VMGM_DOM_PGCN:
        /* describes the VMGM_PGCN, and Menu ID if VMGM_DOM */
#if DBG_ON(DBG_TRACE)
        DbgPrint(("jump_ss: VMGM_DOM_PGCN\n"));
#endif
        pgc_domain = VMGM_PGC;
        time_info->title_valid = time_info->chapter_valid = FALSE;

        next_pgcn = vmgm_pgcn;

        if (parse_pgci(&next_pgcn))
		{
			retval = NAV_STOP;
		}

        next_pgn = 1;
        next_cell = pgc_pgmap[next_pgn - 1];
        break;

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

    return (retval);
}
/**
 **  Name:           call_ss (user function Menu_Call (Menu ID) )
 **
 **  Arguments:      None
 **
 **  Returns:        pgc_play status
 **
 **  Functionality:
 *    1) Stop the presentation in the current Title.
 *    2) Save the following information as RSM Information.
 *    3) Stop the count down of Navigation Timer and maintain the Navigation Timer value.
 *       Stop the count up of GPRMs in Counter mode and maintain the value.
 *    4) If domain_id is '00b':
 *          Start execution of the First Play PGC.
 *       else if domain_id is '01b'
 *          Start execution of the Entry PGC of the Title Menu in the VMGM_DOM.
 *       else if domain_id is '10b'
 *          Start execution of the Entry PGC of the Menu in the VTSM_DOM which
 *          is specified by the Menu ID.
 *       else if domain_id is '11b'
 *          Start execution of the PGC in the VMGM_DOM which is specified by
 *          the VMGM_PGC.
 */

USHORT call_ss(UBYTE domain_id, UBYTE menu_id, UBYTE cn_rsm, USHORT vmgm_pgcn)
{
    USHORT retval;
    ULONG  out_msg[4];

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

    /*
     * This is the instruction to start presentation of the PGC which is
     * specified by the Domain ID, and to store the RSM Information.
     */

#if REPEAT_MODE != REPEAT_MODE_1
    if ( (repeat_mode == REPEAT_A_B) && A_B_count)
    {
        /* clear the repeat_mode */
        repeat_mode = REPEAT_OFF;
        A_B_count = 0;
        out_msg[0] = VDVD_STATUS_PROHIBITED;
        out_msg[1] = 0;
        if (UsrEventHandler(out_msg) != USR_SUCCESS)
        {
            DbgPrint(("\nUsrEventHandler FAILURE, %s, %d\n\n", __FILE__, __LINE__));
        }
    }
#else
    if (repeat_mode != REPEAT_OFF)
    {
        repeat_mode = REPEAT_OFF;
        A_B_count = repeat_count = 0;
        UsrSendRepeatEvent(VDVD_INFO_REPEAT_OFF);
    }
#endif
    retval = NAV_PRE_CMD;

    /* Starting VOBS address of current VTS */
    rsm_info.next_vts_sa = next_vts_sa;

    /* Starting sector of current cell to be presented */
    rsm_info.nv_pck_lbn = valid_lbn_for_rsm; /*nvpck[CURRENT].dsi_gi.nv_pck_lbn;*/

    rsm_info.pgc_domain = (UBYTE)(pgc_domain);
#if 1 /* Changed to fix resume error in Dante's Peak */
    rsm_info.cell_num = cn_rsm;
#else
    rsm_info.cell_num = next_cell;
#endif
    rsm_info.vtsn = next_vtsn;
    if (nav_state == FULL_STOPPED)
    {
        rsm_info.valid = 0;
    }
    else if (pgc_mode == PGC_NXT_LNK)   /* in post command */
    {
        rsm_info.valid = 3;
    }
    else if (pgc_mode == PGC_PT_INIT)   /* in pre command */
    {
        rsm_info.valid = 2;
    }
    else
    {
        rsm_info.valid = 1;
    }

    rsm_info.sprm4 = get_sprm(SPRM_TTN_TT_DOM);
    rsm_info.sprm5 = get_sprm(SPRM_VTS_TTN_TT_DOM);
    rsm_info.sprm6 = get_sprm(SPRM_TT_PGCN_TT_DOM);

#if 1 /* Changed to fix resume error in Danta's Peek */
    if( rsm_info.valid == 3 )
    {
        rsm_info.sprm7 = rsm_info.cell_num;
    }
    else
    {
        rsm_info.sprm7 = get_sprm(SPRM_PTTN_ONE_SEQ_PGC);
    }
#else
    rsm_info.sprm7 = get_sprm(SPRM_PTTN_ONE_SEQ_PGC);
#endif
    rsm_info.sprm8 = get_sprm(SPRM_HL_BTNN);

    switch (domain_id)
    {
    case FP_DOM:
        /* FP_DOM */
#if DBG_ON(DBG_TRACE)
        DbgPrint(("call_ss - FP_DOM\n"));
#endif
        pgc_domain = FP_PGC;
        parse_pgci(&next_pgcn);
        break;

    case VMGM_DOM:
        /* VMGM_DOM with Menu ID */
#if DBG_ON(DBG_TRACE)
        DbgPrint(("call_ss - VMGM_DOM\n"));
#endif
        next_pgcn = 1;
        if (dvd_title_menu(&next_pgcn) != SUCCESS)
        {
            retval = NAV_STOP;
        }
        next_pgn = 1;
        next_cell = pgc_pgmap[next_pgn - 1];
        break;

    case VTSM_DOM:
        /* VTSM_DOM with Menu ID */
#if DBG_ON(DBG_TRACE)
        DbgPrint(("call_ss - VTSM_DOM\n"));
#endif
        if (dvd_vts_menu(menu_id, 0, 0, &next_pgcn) != SUCCESS)
        {
            retval = NAV_STOP;
        }
        next_pgn = 1;
        next_cell = pgc_pgmap[0];
        break;

    case VMGM_DOM_PGCN:
        /* VMGM_DOM with PGCN */
#if DBG_ON(DBG_TRACE)
        DbgPrint(("call_ss - VMGM_DOM_PGCN\n"));
#endif
        pgc_domain = VMGM_PGC;
        time_info->title_valid = time_info->chapter_valid = FALSE;
        next_pgcn = vmgm_pgcn;

        /* Cancel resume for end of title call_ss to the VMGM domain */
        /* rsm_info.valid = 0; */ /* donot clear it to fix bug #443. Li 5/6 */
        if (parse_pgci(&next_pgcn))
        {
            retval = NAV_STOP;
        }
        next_pgn = 1;
        next_cell = pgc_pgmap[next_pgn - 1];
        break;

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

#if DBG_ON(DBG_TRACE)
    DbgPrint(("call_ss: DONE\n"));
#endif

    return (retval);
}


/**
 *  Name:           IsValidCommand
 *
 *  Description:    Determine if button contains a valid command
 *
 *  Arguments:      button
 *
 *  Returns:        true if button is valid, false if not
 *
 *  Functionality:  Add cases as other bad buttons are found.  We're not checking every possibility here
 *                  since bad buttons are rare and we don't want to introduce any new bugs to the code.
 *                  The current implementation fixes title 20 (track 19) of the DTS TEST STREAMS FOR DVD
 *                  PLAYERS - DVD Ver. 2.2 test disk.
 *
 */
BOOLEAN IsValidCommand(BYTE *button)
{
    UBYTE cmd_id1, branch;

    cmd_id1 = button[0] >> 5;
    branch  = button[1] & 0xF;

    if ( (cmd_id1 == 1) && (branch == 0) )
    {
        return(FALSE);
    }

    return(TRUE);
}

/**
 *  Name:           IsBranchCommand
 *
 *  Description:    Determine if the button command will start new playback
 *
 *  Arguments:      button
 *
 *  Returns:        true if it will cause new playback, false otherwise
 *
 *  Functionality:  Checks the button command and determines if the command will
 *                  initiate new playback.  This is an old piece of code -- moved
 *                  here because it was duplicated in multiple locations in the code.
 *
 */
BOOLEAN IsBranchCommand(BYTE *button)
{
    UBYTE cmd_id1, branch, link_cmd, link_option, link_operand;


    cmd_id1 = button[0] >> 5;
    branch  = button[1] & 0xF;
    if ( !( ( (cmd_id1 == 0) || (cmd_id1 == 2) || (cmd_id1 == 3) ) && (branch == 0) ) )
    {
        link_cmd     = button[0] & 0xf0;
        link_option  = button[1] & 0x0f;
        link_operand = button[7];

        /* If the command is not one of the following                  */
        /*   - link or compare link, but link option is a LinkNoLink   */
        /*   - Set Compare LinkSIns, but link option is a LinkNoLink   */
        /*   - Compare & Set-LinkSIns, but link option is a LinkNoLink */
        /*   - Compare-Set & LinkSIns, but link option is a LinkNoLink */
        /* execute the if statement                                    */

        if (!(( (link_cmd         == 0x20) && (link_operand == 0x00) && (link_option == 0x01)) ||
              (((link_cmd & 0xe0) == 0x40) && (link_operand == 0x00) && (link_option == 0x01)) ||
              (((link_cmd & 0xe0) == 0x60) && (link_operand == 0x00) && (link_option == 0x01)) ||
              ( (link_cmd         >  0x70) && (link_operand == 0x00)                       )    ))
        {
            return(IsValidCommand(button));
        }
    }
    return(FALSE);
}


/**
 *  Name:           dvd_cmd
 *
 *  Description:    decode the command (8 bytes)
 *
 *  Arguments:      buf - pointer to an eight byte buffer
 *
 *  Returns:        NAV_NOP, NAV_STOP or NAV_BRANCH
 *
 *   Functionality:
 *    Navigation Commands may be used in the following four areas:
 *    1) Button Command (BTN_CMD) in PCI
 *    2) Cell Command (C_CMD) in PGCI
 *    3) Pre-Command (PRE_CMD) in PGCI
 *    4) POST-Command (POST_CMD) in PGCI
 *
 *    Navigation Commands are formatted into eight bytes and can specify
 *    either one, two or three Instructions.
 *
 *    Command     |                    meaning
 *----------------+-----------------------------------------------------------
 *    GoTo        |  Change the execution order of the Navigation Commands
 *----------------+-----------------------------------------------------------
 *    Link        |  Start the specified presentation within the Domain
 *                |   (inludes setting of HL_BTNN)
 *----------------+-----------------------------------------------------------
 *    Jump        |  Start the specified presentation within another Domain
 *----------------+-----------------------------------------------------------
 *    Compare GoTo|  If the result of the Compare is true, then GoTo
 *----------------+-----------------------------------------------------------
 *    Compare Link|  If the result of the Compare is true, then Link
 *----------------+-----------------------------------------------------------
 *    Compare Jump|  If the result of the Compare is true, then Jump
 *----------------+-----------------------------------------------------------
 *    SetSystem   |  Set Navigation Parameters
 *----------------+-----------------------------------------------------------
 *    Set         |  Calculate GPRM value
 *----------------+-----------------------------------------------------------

⌨️ 快捷键说明

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