diff options
author | Paul Gilbert | 2018-11-12 15:45:21 -0800 |
---|---|---|
committer | Paul Gilbert | 2018-12-08 19:05:59 -0800 |
commit | c19d40fa781a414560341a1d357b64875791f17f (patch) | |
tree | 8c4b981694c236e86ebf1ad2b59c44d74a9c5658 /engines/gargoyle/frotz/processor.h | |
parent | ce7113b34a808ef8136114881f9d19ce857d13bc (diff) | |
download | scummvm-rg350-c19d40fa781a414560341a1d357b64875791f17f.tar.gz scummvm-rg350-c19d40fa781a414560341a1d357b64875791f17f.tar.bz2 scummvm-rg350-c19d40fa781a414560341a1d357b64875791f17f.zip |
GLK: FROTZ: Implemented Quetzal class for savegames
Diffstat (limited to 'engines/gargoyle/frotz/processor.h')
-rw-r--r-- | engines/gargoyle/frotz/processor.h | 63 |
1 files changed, 52 insertions, 11 deletions
diff --git a/engines/gargoyle/frotz/processor.h b/engines/gargoyle/frotz/processor.h index 6a28121512..0f7ecc06b4 100644 --- a/engines/gargoyle/frotz/processor.h +++ b/engines/gargoyle/frotz/processor.h @@ -32,25 +32,27 @@ namespace Gargoyle { namespace Frotz { -#define CODE_BYTE(v) v = *pcp++ -#define CODE_WORD(v) v = READ_BE_UINT16(pcp += 2) -#define CODE_IDX_WORD(v,i) v = READ_BE_UINT16(pcp + i) -#define GET_PC(v) v = pcp - zmp -#define SET_PC(v) pcp = zmp + v - #define TEXT_BUFFER_SIZE 200 +#define CODE_BYTE(v) v = codeByte() +#define CODE_WORD(v) v = codeWord() +#define CODE_IDX_WORD(v,i) v = codeWordIdx(i) +#define GET_PC(v) v = getPC() +#define SET_PC(v) setPC(v) + enum string_type { LOW_STRING, ABBREVIATION, HIGH_STRING, EMBEDDED_STRING, VOCABULARY }; class Processor; +class Quetzal; typedef void (Processor::*Opcode)(); /** * Zcode processor */ class Processor : public Errors, public GlkInterface, public virtual Mem { + friend class Quetzal; private: int _finished; zword zargs[8]; @@ -1510,11 +1512,6 @@ protected: void z_store(); /**@}*/ -protected: - /** - * Get the PC. Is implemented by the Processor class, which derives from Errors - */ - virtual zword getPC() const { return pcp - zmp; } public: /** * Constructor @@ -1530,6 +1527,50 @@ public: * Z-code interpreter main loop */ void interpret(); + + /** + * \defgroup Memory access methods + * @{ + */ + + /** + * Square brackets operator + */ + zbyte &operator[](uint addr) { return zmp[addr]; } + + /** + * Read a code byte + */ + zbyte codeByte() { return *pcp++; } + + /** + * Read a code word + */ + zword codeWord() { + zword v = READ_BE_UINT16(pcp); + pcp += 2; + return v; + } + + /** + * Return a code word at a given address + */ + zword codeWordIdx(uint addr) const { + return READ_BE_UINT16(pcp + addr); + } + + /** + * Return the current program execution offset + * @remarks This virtual as a convenient way for the ancestor Err class to access + */ + virtual uint getPC() const override { return pcp - zmp; } + + /** + * Set the program execution offset + */ + void setPC(uint addr) { pcp = zmp + addr; } + + /**@}*/ }; } // End of namespace Frotz |