1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef GLK_ADVSYS_GAME
#define GLK_ADVSYS_GAME
#include "common/array.h"
#include "common/stream.h"
namespace Glk {
namespace AdvSys {
/**
* Data decryption
*/
class Decrypter {
public:
/**
* Decrypt a data block
*/
static void decrypt(byte* data, size_t size);
};
/**
* AdvSys game header
*/
class Header : public Decrypter {
public:
bool _valid; ///< Signals whether header is valid
size_t _size; ///< Size in bytes
uint _headerVersion; ///< Header structure version
Common::String _name; ///< Adventure name
uint _version; ///< Adventure version
uint _wordTable; ///< Word table offset
uint _wordTypeTable; ///< Word type table offset
uint _objectTable; ///< Object table offset
uint _actionTable; ///< Action table offset
uint _variableTable; ///< Variable table offset
uint _dataSpace; ///< Data space offset
uint _codeSpace; ///< Code space offset
uint _dataBlock; ///< First data block offset
uint _messageBlock; ///< First message block offset
uint _initCode; ///< Initialization code offset
uint _updateCode; ///< Update code offset
uint _before; ///< Code offset before verb handler
uint _after; ///< Code offset after verb handler
uint _errorHandler; ///< Error handler code offset
uint _saveArea; ///< Save area offset
uint _saveSize; ///< Save area size
public:
/**
* Constructor
*/
Header() : _valid(false), _size(0), _headerVersion(0), _version(0), _wordTable(0),
_wordTypeTable(0), _objectTable(0), _actionTable(0), _variableTable(0),
_dataSpace(0), _codeSpace(0), _dataBlock(0), _messageBlock(0), _initCode(0),
_updateCode(0), _before(0), _after(0), _errorHandler(0), _saveArea(0), _saveSize(0) {
}
/**
* Constructor
*/
Header(Common::ReadStream &s) {
load(s);
}
/**
* Load the header
*/
bool load(Common::ReadStream &s);
};
/**
* Game abstraction class
*/
class Game : public Header {
private:
uint _saveOffset;
public:
Common::Array<byte> _data;
public:
/**
* Constructor
*/
Game() : Header(), _saveOffset(0) {}
/**
* Load data for the game
*/
bool load(Common::SeekableReadStream &s);
};
} // End of namespace AdvSys
} // End of namespace Glk
#endif
|