File: globals.h

package info (click to toggle)
scummvm 2.9.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 450,268 kB
  • sloc: cpp: 4,297,604; asm: 28,322; python: 12,901; sh: 11,219; java: 8,477; xml: 7,843; perl: 2,633; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (236 lines) | stat: -rw-r--r-- 6,354 bytes parent folder | download | duplicates (3)
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/* 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 3 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, see <http://www.gnu.org/licenses/>.
 *
 */

/*
 * Based on ScottFree interpreter version 1.14 developed by Swansea
 * University Computer Society without disassembly of any other game
 * drivers, only of game databases as permitted by EEC law (for purposes
 * of compatibility).
 *
 * Licensed under GPLv2
 *
 * https://github.com/angstsmurf/spatterlight/tree/master/terps/scott
 */

#ifndef GLK_SCOTT_GLOBALS_H
#define GLK_SCOTT_GLOBALS_H

#include "common/array.h"
#include "common/str.h"
#include "common/str-array.h"
#include "common/hashmap.h"
#include "glk/glk_types.h"
#include "glk/windows.h"
#include "glk/scott/definitions.h"
#include "glk/scott/types.h"
#include "glk/scott/unp64/unp64.h"

namespace Glk {
namespace Scott {

struct Command;
enum ExtraCommand : int;
struct LineImage;
enum VectorStateType : int;

struct PixelToDraw;
struct Image;

typedef uint8_t RGB[3];
typedef RGB PALETTE[16];

struct Header;
struct Item;
struct Room;
struct Action;

struct SavedState;

class Globals {
public:
	// scott
	Header *_gameHeader;
	Common::Array<Item> _items;
	Common::Array<Room> _rooms;
	Common::StringArray _verbs;
	Common::StringArray _nouns;
	Common::StringArray _messages;
	Common::Array<Action> _actions;
	Common::StringArray _sys;
	Common::StringArray _systemMessages;
	winid_t _graphics = nullptr;
	uint8_t *_entireFile = nullptr;
	size_t _fileLength = 0;
	strid_t _roomDescriptionStream = nullptr;
	int _fileBaselineOffset = 0;
	int _header[24];
	int _lightRefill = 0;
	winid_t _bottomWindow = nullptr, _topWindow = nullptr;
	Command *_currentCommand = nullptr;
	int _justStarted = 1;
	int _shouldRestart = 0;
	int _stopTime = 0;
	strid_t _transcript = nullptr;
	int _counters[16]; ///< Range unknown
	int _currentCounter = 0;
	int _savedRoom = 0;
	int _roomSaved[16];   ///< Range unknown
	uint32 _bitFlags = 0; ///< Might be >32 flags - I haven't seen >32 yet
	int _autoInventory = 0;
	int _animationFlag = 0;
	uint8_t _enemyTable[126];
	const char *_battleMessages[33];
	int _options = 0; ///< Option flags set
	Common::String _titleScreen;
	int _shouldLookInTranscript = 0;

	// sagadraw
	int _drawToBuffer = 0;
	uint8_t _sprite[256][8];
	uint8_t _screenchars[768][8];
	uint8_t _buffer[384][9];
	Common::Array<Image> _images;
	int _pixelSize = 0;
	int _xOffset = 0;
	PALETTE _pal;
	int _whiteColour = 15;
	int _blueColour = 9;
	glui32 _diceColour = 0xFF0000;
	int32_t _errorCount = 0;
	PaletteType _palChosen = NO_PALETTE;
	size_t _hulkCoordinates = 0x26DB;
	size_t _hulkItemImageOffsets = 0x2798;
	size_t _hulkLookImageOffsets = 0x27BC;
	size_t _hulkSpecialImageOffsets = 0x276E;
	size_t _hulkImageOffset = 0x441B;

	// line_drawing
	Common::Array<LineImage> _lineImages;
	VectorStateType _vectorState;
	PixelToDraw **_pixelsToDraw = nullptr;
	int _totalDrawInstructions = 0;
	int _currentDrawInstruction = 0;
	int _vectorImageShown = -1;
	uint8_t *_pictureBitmap = nullptr;
	int _lineColour = 15;
	int _bgColour = 0;
	int _scottGraphicsWidth = 255;
	int _scottGraphicsHeight = 94;

	// connect
	int _gliSlowDraw = 0;

	// parser
	int _lastNoun = 0;
	glui32 *_firstErrorMessage = nullptr;
	glui32 **_unicodeWords = nullptr;
	char **_charWords = nullptr;
	int _wordsInInput = 0;
	Common::StringArray _directions;
	Common::StringArray _englishDirections;
	Common::StringArray _skipList;
	Common::StringArray _englishSkipList;
	Common::StringArray _delimiterList;
	Common::StringArray _englishDelimiterList;
	Common::StringArray _extraCommands;
	Common::StringArray _extraNouns;
	Common::StringArray _englishExtraNouns;
	Common::Array<ExtraCommand> _extraNounsKey;
	Common::Array<ExtraCommand> _extraCommandsKey;
	Common::StringArray _abbreviations;
	Common::StringArray _abbreviationsKey;
	Common::StringArray _spanishDirections;
	Common::StringArray _germanDirections;
	Common::StringArray _germanExtraCommands;
	Common::StringArray _spanishExtraCommands;
	Common::StringArray _germanExtraNouns;
	Common::StringArray _spanishExtraNouns;
	Common::StringArray _germanSkipList;
	Common::StringArray _germanDelimiterList;

	// restore state
	int _justUndid = 0;
	SavedState *_initialState = nullptr;
	SavedState *_ramSave = nullptr;
	SavedState *_lastUndo = nullptr;
	SavedState *_oldestUndo = nullptr;
	int _numberOfUndos = 0;

	const GameInfo *_game;
	GameInfo _fallbackGame;
	// Include game list
	#include "glk/scott/games.h"

	// detect game
	Common::HashMap<Common::String, int> _md5Index;

	// unp64
	UnpStr _unp;
	int _parsePar = 1;
	int _iter = 0;

	// 6502 emu
	int _byted011[2] = {0, 0};
	int _retfire = 0xff;
	int _retspace = 0xff;

	// robin of sherwood]
	uint8_t *_forestImages = nullptr;

	// seas of blood
	winid_t _leftDiceWin = nullptr;
	winid_t _rightDiceWin = nullptr;
	winid_t _battleRight = nullptr;
	uint _backgroundColour = 0;
	uint8_t *_bloodImageData = nullptr;
	glui32 _dicePixelSize = 0;
	glui32 _diceXOffset = 0;
	glui32 _diceYOffset = 0;
	int _shouldDrawObjectImages = 0;

	// savage island
	uint8_t *_saveIslandAppendix1 = nullptr;
	int _saveIslandAppendix1Length = 0;
	uint8_t *_saveIslandAppendix2 = nullptr;
	int _saveIslandAppendix2Length = 0;

	// load TI994A
	int _maxMessages = 0;
	int _maxItemDescr = 0;
	size_t _ti99ImplicitExtent = 0;
	size_t _ti99ExplicitExtent = 0;
	uint8_t *_ti99ImplicitActions = nullptr;
	uint8_t *_ti99ExplicitActions = nullptr;
	uint8_t **_verbActionOffsets = nullptr;

public:
	Globals();
	~Globals();
};

extern Globals *g_globals;

#define _G(FIELD) (g_globals->FIELD)

} // End of namespace Scott
} // End of namespace Glk

#endif