📄 navcmd.cpp
字号:
/*****************************************************************************
******************************************************************************
** **
** Copyright (c) 2005-2006 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 navcmd.cpp
*
* Implements the routines to parse navigation commands.
* This is a sub-component of the command processor.
*
* $Id: navcmd.cpp,v 1.39 2007/01/05 02:53:49 rbehe Exp $
*/
#include <stdlib.h>
#include <time.h>
#include "vdvd_types.h"
#include "navcmd.h"
#include "cmdproc.h"
#include "cmdproc_types.h"
#include "../mvobjdb.h"
#include "../playctrl/playctrl.h"
#include "dbgprint.h"
/* Debug macros */
#define DBG_NAVCMD DBG_ERROR
#define DBG_ON(x) (DBG_NAVCMD >= x)
/* Local constants */
#define NAVCMD_OPERAND_UNUSED 0
#define NAVCMD_OPERAND_REG 1
#define NAVCMD_OPERAND_IMM 2
#define NAVCMD_OPERAND_INVALID 3
#define NAVCMD_REGISTER_PSR 1
#define NAVCMD_REGISTER_GPR 2
/**
* Local functions
*/
static ULONG NavCmdGetRegisterValue(ULONG ulOperand);
static BYTE NavCmdGetRegisterType(ULONG ulOperand);
static BYTE NavCmdGetDstOperandType(ULONG ulOpcode);
static BYTE NavCmdGetSrcOperandType(ULONG ulOpcode);
/**
* NavCmdGetCommandType -- Get a command's type
*
* @param
* pCommand -- pointer to command to get type for
*
* @retval
* command type.
*
* @remark
* Opcode of command is 32 bits
* b28 - b27 = command group
* b26 - b24 = command sub group
* b19 - b16 = branch option
* b11 - b08 = compare option
* b04 - b00 = set option
*
* See BD-ROM spec for command format.
*/
NAVCMD_TYPE NavCmdGetCommandType(MVOBJ_NAV_COMMAND *pCommand)
{
BYTE bCommandGroup;
BYTE bCommandSubGroup;
BYTE bBranchOption;
BYTE bCompareOption;
BYTE bSetOption;
NAVCMD_TYPE tCmdType = NAVCMD_INVALID;
if (pCommand == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("NavCmdGetCommandType: NULL pointer!\n"));
return (NAVCMD_INVALID);
}
/* Parse the needed fields from the command opcode */
bCommandGroup = (BYTE)( (pCommand->ulOpCode >> 27) & 0x03);
bCommandSubGroup = (BYTE)( (pCommand->ulOpCode >> 24) & 0x07);
bBranchOption = (BYTE)( (pCommand->ulOpCode >> 16) & 0x0F);
bCompareOption = (BYTE)( (pCommand->ulOpCode >> 8) & 0x0F);
bSetOption = (BYTE)(pCommand->ulOpCode & 0x1F);
/*
* Examine fields to determine the command type.
*/
switch (bCommandGroup)
{
case 0: /* branch command group */
switch (bCommandSubGroup)
{
case 0: /* goto subgroup */
switch (bBranchOption)
{
case 0: /* nop */
tCmdType = NAVCMD_NOP;
break;
case 1: /* goto command */
tCmdType = NAVCMD_GOTO;
break;
case 2: /* break command */
tCmdType = NAVCMD_BREAK;
break;
default:
break;
}
break;
case 1: /* jump subgroup */
switch (bBranchOption)
{
case 0: /* jump object command */
tCmdType = NAVCMD_JUMP_OBJECT;
break;
case 1: /* jump title command */
tCmdType = NAVCMD_JUMP_TITLE;
break;
case 2: /* call object command */
tCmdType = NAVCMD_CALL_OBJECT;
break;
case 3: /* call title command */
tCmdType = NAVCMD_CALL_TITLE;
break;
case 4: /* resume command */
tCmdType = NAVCMD_RESUME;
break;
default:
break;
}
break;
case 2: /* play subgroup */
switch (bBranchOption)
{
case 0: /* play playlist command */
tCmdType = NAVCMD_PLAY_PL;
break;
case 1: /* play playlist at playitem command */
tCmdType = NAVCMD_PLAY_PLATPI;
break;
case 2: /* play playlist at playlist mark command */
tCmdType = NAVCMD_PLAY_PLATMK;
break;
case 3: /* terminate playlist command */
tCmdType = NAVCMD_TERMINATE_PL;
break;
case 4: /* link playitem command */
tCmdType = NAVCMD_LINK_PI;
break;
case 5: /* link playlist mark */
tCmdType = NAVCMD_LINK_MK;
break;
default:
break;
}
break;
default:
break;
}
break;
case 1: /* compare command group */
switch (bCompareOption)
{
case 1: /* bitwise compare */
tCmdType = NAVCMD_BC;
break;
case 2: /* equal */
tCmdType = NAVCMD_EQ;
break;
case 3: /* not equal */
tCmdType = NAVCMD_NE;
break;
case 4: /* greater than or equal */
tCmdType = NAVCMD_GE;
break;
case 5: /* greater than */
tCmdType = NAVCMD_GT;
break;
case 6: /* less than or equal */
tCmdType = NAVCMD_LE;
break;
case 7: /* less than */
tCmdType = NAVCMD_LT;
break;
default:
break;
}
break;
case 2: /* set command group */
switch (bCommandSubGroup)
{
case 0: /* set subgroup */
switch (bSetOption)
{
case 1: /* move */
tCmdType = NAVCMD_MOVE;
break;
case 2: /* swap */
tCmdType = NAVCMD_SWAP;
break;
case 3: /* add */
tCmdType = NAVCMD_ADD;
break;
case 4: /* sub */
tCmdType = NAVCMD_SUB;
break;
case 5: /* multiply */
tCmdType = NAVCMD_MULT;
break;
case 6: /* divide */
tCmdType = NAVCMD_DIV;
break;
case 7: /* modulus */
tCmdType = NAVCMD_MOD;
break;
case 8: /* random */
tCmdType = NAVCMD_RND;
break;
case 9: /* and */
tCmdType = NAVCMD_AND;
break;
case 10: /* or */
tCmdType = NAVCMD_OR;
break;
case 11: /* exclusive or */
tCmdType = NAVCMD_XOR;
break;
case 12: /* bit set */
tCmdType = NAVCMD_BIT_SET;
break;
case 13: /* bit clear */
tCmdType = NAVCMD_BIT_CLEAR;
break;
case 14: /* shift left */
tCmdType = NAVCMD_SHIFT_LEFT;
break;
case 15: /* shift right */
tCmdType = NAVCMD_SHIFT_RIGHT;
break;
default:
break;
}
break;
case 1: /* set system subgroup */
switch (bSetOption)
{
case 1: /* set stream */
tCmdType = NAVCMD_SET_STREAM;
break;
case 2: /* set nav timer */
tCmdType = NAVCMD_SET_NV_TIMER;
break;
case 3: /* set button page */
tCmdType = NAVCMD_SET_BUTTON_PAGE;
break;
case 4: /* enable button */
tCmdType = NAVCMD_ENABLE_BUTTON;
break;
case 5: /* disable button */
tCmdType = NAVCMD_DISABLE_BUTTON;
break;
case 6: /* set secondary stream */
tCmdType = NAVCMD_SET_SECONDARY_STREAM;
break;
case 7: /* popup menu off */
tCmdType = NAVCMD_POPUP_MENU_OFF;
break;
case 8: /* still on command */
tCmdType = NAVCMD_STILL_ON;
break;
case 9: /* still off command */
tCmdType = NAVCMD_STILL_OFF;
break;
#ifdef DRM_BDPLUS_SUPPORT
case 16: /* set message BD+ */
tCmdType = NAVCMD_SET_MESSAGE_BDPLUS;
break;
case 17: /* set status BD+ */
tCmdType = NAVCMD_SET_STATUS_BDPLUS;
break;
#endif
default:
break;
}
break;
default:
break;
}
break;
default:
break;
}
return (tCmdType);
}
/**
* NavCmdNop
*
* @param
* hCmdProc -- handle to the command processor private data
* pCommand -- pointer to the command to be executed
* pulStatusParam -- pointer to the parameter associated with the return status
*
* @retval
* CMDPROC_STATUS
*/
CMDPROC_STATUS NavCmdNop(CMDPROC_HANDLE *hCmdProc, MVOBJ_NAV_COMMAND *pCommand, ULONG *pulStatusParam)
{
#if DBG_ON(DBG_VERBOSE)
DbgPrint(("NavCmdNop: ENTER\n"));
#endif
return (CMDPROC_SUCCESS);
}
/**
* NavCmdGoto
*
* @param
* hCmdProc -- handle to the command processor private data
* pCommand -- pointer to the command to be executed
* pulStatusParam -- pointer to the parameter associated with the return status
*
* @retval
* CMDPROC_STATUS
*/
CMDPROC_STATUS NavCmdGoto(CMDPROC_HANDLE *hCmdProc, MVOBJ_NAV_COMMAND *pCommand, ULONG *pulStatusParam)
{
ULONG uiDstType;
ULONG ulCmdID;
#if DBG_ON(DBG_VERBOSE)
DbgPrint(("NavCmdGoto: ENTER\n"));
#endif
/* check for valid handle */
if (hCmdProc == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("NavCmdGoto: Invalid handle!\n"));
return (CMDPROC_NULL_POINTER);
}
/* check for valid command pointer */
if (pCommand == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("NavCmdGoto: Invalid command pointer!\n"));
return (CMDPROC_NULL_POINTER);
}
/* get destination operand type */
uiDstType = NavCmdGetDstOperandType(pCommand->ulOpCode);
/*
* If Destination operand is a register number, get the register value.
* If it is an immediate value, then use that value.
* Otherwise, return an error.
*/
if (uiDstType == NAVCMD_OPERAND_REG)
{
/* Get value from specified register */
ulCmdID = NavCmdGetRegisterValue(pCommand->ulDstOperand);
}
else if (uiDstType == NAVCMD_OPERAND_IMM)
{
/* Set operand value to the immediate value */
ulCmdID = pCommand->ulDstOperand;
}
else
{
DBGPRINT(DBG_ON(DBG_ERROR), ("NavCmdGoto: Invalid operand type!\n"));
return (CMDPROC_FAILURE);
}
/* Set the command id to the specified command to goto */
if (hCmdProc->tState == CMDPROC_STATE_MOVIE_PROCESSING)
{
hCmdProc->MoviePrgm.ulCurrentCmdID = ulCmdID - 1;
}
else
{
hCmdProc->ButtonPrgm.ulCurrentCmdID = ulCmdID - 1;
}
return (CMDPROC_SUCCESS);
}
/**
* NavCmdBreak
*
* @param
* hCmdProc -- handle to the command processor private data
* pCommand -- pointer to the command to be executed
* pulStatusParam -- pointer to the parameter associated with the return status
*
* @retval
* CMDPROC_STATUS
*/
CMDPROC_STATUS NavCmdBreak(CMDPROC_HANDLE *hCmdProc, MVOBJ_NAV_COMMAND *pCommand, ULONG *pulStatusParam)
{
#if DBG_ON(DBG_VERBOSE)
DbgPrint(("NavCmdBreak: ENTER\n"));
#endif
/* check for valid handle */
if (hCmdProc == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("NavCmdBreak: Invalid handle!\n"));
return (CMDPROC_NULL_POINTER);
}
/*
* Terminate the current command program.
*/
if (hCmdProc->tState == CMDPROC_STATE_MOVIE_PROCESSING)
{
/* End of movie command program, so move to terminated state */
hCmdProc->tState = CMDPROC_STATE_TERMINATED;
}
else
{
/* End of button command program, so return to waiting state */
hCmdProc->tState = CMDPROC_STATE_WAITING;
}
/* signal that a transition needs to occur */
hCmdProc->fTransitionPending = TRUE;
return (CMDPROC_SUCCESS);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -