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

📄 gprm.h

📁 Linux下比较早的基于命令行的DVD播放器
💻 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_GPRM_H#define DXR3PLAYER_DVD_VM_GPRM_H//------------------------------------------------------------------------------#include "dvd/vm/Register.h"#include "types.h"#include <cstdlib>#include <cassert>//------------------------------------------------------------------------------namespace dvd { namespace vm {//------------------------------------------------------------------------------/** * General-purpose register */class GPR : public Register{private:    /**     * Indicate if the register is in counter mode.     */    bool isCounter;    /**     * The time the register was set to the value, if in counter mode.     */    millis_t setTime;public:    /**     * Construct the register with a value of 0, and no counter mode.     */    GPR();    /**     * Reset the GPR     */    void reset();    /**     * Put the register into counter mode.     */    void setCounter();    /**     * Put the register into normal mode.     */    void clearCounter();    /**     * Set the value of the register.     */    void setValue(unsigned x);    /**     * Get the value of the register.     */    unsigned getValue() const;    /**     * Save the register to the given file.     *     * @return if the saving has succeeded     */    bool save(FILE* f) const;    /**     * Load the register from the given file.     *     * @return if the loading has succeeded     */    bool load(FILE* f);};//------------------------------------------------------------------------------/** * General-purpose register file */class GPRM{public:    /**     * The number of registers.     */    static const size_t numRegisters = 16;    /**     * The lowest register number valid to designate a GPR.     */    static const size_t minRegisterNumber = 0;    /**     * The highest register number valid to designate a GPR.     */    static const size_t maxRegisterNumber = minRegisterNumber + numRegisters - 1;private:    /**     * The registers.     */    GPR registers[numRegisters];public:    /**     * Reset the registers.     */    void reset();    /**     * Get the register with the given index for modification.     */    GPR& getRegister(size_t index);    /**     * Set the value of the given register.     */    void setValue(size_t index, unsigned value);    /**     * Get the register with the given index for reading.     */    const GPR& getRegister(size_t index) const;    /**     * Get the value of the given register.     */    unsigned getValue(size_t index) const;    /**     * 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);};//------------------------------------------------------------------------------// Inline definitions//------------------------------------------------------------------------------// GPR//------------------------------------------------------------------------------inline GPR::GPR() : isCounter(false), setTime(0){}//------------------------------------------------------------------------------// GPRM//------------------------------------------------------------------------------inline GPR& GPRM::getRegister(size_t index){    assert(index<numRegisters);    return registers[index];}//------------------------------------------------------------------------------inline void GPRM::setValue(size_t index, unsigned value){    getRegister(index).setValue(value);}//------------------------------------------------------------------------------inline unsigned GPRM::getValue(size_t index) const{    return getRegister(index).getValue();}//------------------------------------------------------------------------------inline const GPR& GPRM::getRegister(size_t index) const{    assert(index<numRegisters);    return registers[index];}//------------------------------------------------------------------------------} /* namespace dvd::vm */ } /* namespace dvd *///------------------------------------------------------------------------------#endif // DXR3PLAYER_DVD_VM_GPRM_H// Local variables:// mode: c++// End:

⌨️ 快捷键说明

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