📄 sprm.h
字号:
//// Copyright (c) 2002 by Istv醤 V醨adi//// This file is part of dxr3Player, a DVD player written specifically // for the DXR3 (aka Hollywood+) decoder card.// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA#ifndef DXR3PLAYER_DVD_VM_SPRM_H#define DXR3PLAYER_DVD_VM_SPRM_H//------------------------------------------------------------------------------#include "Register.h"#include "util/Util.h"#include <cstdlib>#include <cassert>//------------------------------------------------------------------------------namespace dvd {class DVD;}//------------------------------------------------------------------------------namespace dvd { namespace vm {//------------------------------------------------------------------------------class Position;//------------------------------------------------------------------------------/** * System parameter register. */class SPR : public Register{public: /** * Set a language value into the register from a 2-letter code. */ void setLanguage(const char* language);};//------------------------------------------------------------------------------/** * System parameter register file. */class SPRM{public: /** * Register constants */ typedef enum registerName_t { preferredMenuLanguage = 0, audioStreamNumber = 1, ASTN = 1, subPictureStreamNumber = 2, SPSTN = 2, angleNumber = 3, AGLN = 3, volumeTitleNumber = 4, TTN = 4, vtsTitleNumber = 5, VTS_TTN = 5, pgcNumber = 6, TT_PGCN = 6, pttNumber = 7, PTTN = 7, highlightedButtonNumber = 8, HL_BTNN = 8, navigationTimer = 9, NVTMR = 9, pgcForNavTimer = 10, NV_PGCN = 10, audioMixingMode = 11, AMXMD = 11, parentalManagementCountryCode = 12, CC_PTL = 12, parentalLevel = 13, PLT = 13, videoPreferenceAndMode = 14, audioCapabilities = 15, preferredAudioLanguage = 16, preferredAudioLanguageExtension = 17, preferredSubPictureLanguage = 18, preferredSubPictureLanguageExtension = 19, regionCodeMask = 20, reserved1 = 21, reserved2 = 22, reserved3 = 23, NONE = 255 }; public: /** * The number of registers. */ static const size_t numRegisters = 24; /** * The lowest register number valid to designate a SPR. */ static const size_t minRegisterNumber = 128; /** * The highest register number valid to designate a SPR. */ static const size_t maxRegisterNumber = minRegisterNumber + numRegisters - 1;private: /** * The registers. */ SPR registers[numRegisters];public: /** * Construct the system parameter register file with the following * default values: * <ul> * <li>SPR0: "en"</li> * <li>SPR1 (ASTN): 15 (none)</li> * <li>SPR2 (SPSTN): 62 (none)</li> * <li>SPR3 (AGLN): 1 </li> * <li>SPR4 (TTN): 1 </li> * <li>SPR5 (VTS_TTN): 1 </li> * <li>SPR6 (TT_PGCN): 0 </li> * <li>SPR7 (PTTN): 1 </li> * <li>SPR8 (HL_BTNN): 1024 (meaning 1) </li> * <li>SPR9 (NVTMR): 0 </li> * <li>SPR10 (NV_PGCN): 0 </li> * <li>SPR11 (AMXMD): 0 </li> * <li>SPR12 (CC_PLT): "US" </li> * <li>SPR13 (PLT): 15 (none) </li> * <li>SPR14: 256 (4:3, pan&scan) </li> * <li>SPR15: 0 </li> * <li>SPR16: 0xffff </li> * <li>SPR17: 0</li> * <li>SPR18: 0xffff</li> * <li>SPR19: 0</li> * <li>SPR20: 0xffff</li> * <li>SPR21: 0</li> * <li>SPR22: 0</li> * <li>SPR23: 0</li> * </ul> */ SPRM(); /** * Reset the register file to defaults. */ void reset(); /** * Get the register for modification with the given number. */ SPR& getRegister(size_t index); /** * Get the register for modification with the given register name. */ SPR& getRegister(registerName_t name); /** * Get the register for reading with the given number. */ const SPR& getRegister(size_t index) const; /** * Get the register for reading with the given register name. */ const SPR& getRegister(registerName_t name) const; /** * Set the value of the register with the given index. */ void setValue(size_t index, unsigned value); /** * Set the value of the register with the given name. */ void setValue(registerName_t name, unsigned value); /** * Get the value of the register with the given index. */ unsigned getValue(size_t index) const; /** * Get the value of the register with the given name. */ unsigned getValue(registerName_t name) const; /** * Get the value of the ASTN register. */ unsigned getASTN() const; /** * Set the value of the ASTN register. */ void setASTN(unsigned value); /** * Get the value of the SPSTN register. */ unsigned getSPSTN() const; /** * Get the highlighted button number. */ unsigned getHighlightedButtonNumber() const; /** * Set the highlighted button number. */ void setHighlightedButtonNumber(unsigned buttonNo); /** * Update the essential registers. */ void updateEssential(const SPRM& from); /** * Update the non-essential registers. * FIXME: call it copy */ void updateNonEssential(const SPRM& from); /** * Save the register file to the given file. * * @return if the saving has succeeded */ bool save(FILE* f) const; /** * Load the register file from the given file. * * @return if the loading has succeeded */ bool load(FILE* f);private: /** * Copy the registers in the given register name array. The last * element must be NONE. */ void copyRegisters(const SPRM& from, const registerName_t* registers);};//------------------------------------------------------------------------------// Inline definitions//------------------------------------------------------------------------------// SPR//------------------------------------------------------------------------------inline void SPR::setLanguage(const char* language){ setValue(Util::getLanguageCode(language));}//------------------------------------------------------------------------------// SPRM//------------------------------------------------------------------------------inline SPR& SPRM::getRegister(size_t index){ assert(index<numRegisters); return registers[index];}//------------------------------------------------------------------------------inline SPR& SPRM::getRegister(registerName_t name){ return getRegister( (size_t)name );}//------------------------------------------------------------------------------inline const SPR& SPRM::getRegister(size_t index) const{ assert(index<numRegisters); return registers[index];}//------------------------------------------------------------------------------inline const SPR& SPRM::getRegister(registerName_t name) const{ return getRegister( (size_t)name );}//------------------------------------------------------------------------------inline void SPRM::setValue(size_t index, unsigned value){ getRegister(index).setValue(value);}//------------------------------------------------------------------------------inline void SPRM::setValue(registerName_t name, unsigned value){ getRegister(name).setValue(value);}//------------------------------------------------------------------------------inline unsigned SPRM::getValue(size_t index) const{ return getRegister(index).getValue();}//------------------------------------------------------------------------------inline unsigned SPRM::getValue(registerName_t name) const{ return getRegister(name).getValue();}//------------------------------------------------------------------------------inline unsigned SPRM::getASTN() const{ return getValue(ASTN);}//------------------------------------------------------------------------------inline void SPRM::setASTN(unsigned value){ return setValue(ASTN, value);}//------------------------------------------------------------------------------inline unsigned SPRM::getSPSTN() const{ return getValue(SPSTN);}//------------------------------------------------------------------------------inline unsigned SPRM::getHighlightedButtonNumber() const{ return getValue(HL_BTNN)>>10;}//------------------------------------------------------------------------------inline void SPRM::setHighlightedButtonNumber(unsigned buttonNo){ setValue(HL_BTNN, buttonNo<<10);}//------------------------------------------------------------------------------} /* namespace dvd::vm */ } /* namespace dvd *///------------------------------------------------------------------------------#endif // DXR3PLAYER_DVD_VM_SPRM_H// Local variables:// mode: c++// End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -