2005-04-05 15:53:16 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2004 Ivan Dubrov
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2004-2006 The ScummVM project
|
2005-04-05 15:53:16 +00:00
|
|
|
*
|
|
|
|
* 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
|
2005-04-09 19:19:54 +00:00
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-04-05 15:53:16 +00:00
|
|
|
*
|
2006-02-11 10:11:37 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2005-04-05 15:53:16 +00:00
|
|
|
*
|
|
|
|
*/
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2005-04-05 18:08:02 +00:00
|
|
|
#ifndef GOB_GLOBAL_H
|
|
|
|
#define GOB_GLOBAL_H
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
#include "common/file.h"
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "gob/video.h"
|
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
namespace Gob {
|
|
|
|
|
|
|
|
#define VIDMODE_CGA 0x05
|
2007-03-20 14:51:57 +00:00
|
|
|
#define VIDMODE_EGA 0x0D
|
2005-08-08 20:20:00 +00:00
|
|
|
#define VIDMODE_VGA 0x13
|
2005-04-05 15:07:40 +00:00
|
|
|
#define VIDMODE_HER 7
|
|
|
|
|
|
|
|
#define PROAUDIO_FLAG 0x10
|
|
|
|
#define ADLIB_FLAG 0x08
|
|
|
|
#define BLASTER_FLAG 0x04
|
|
|
|
#define INTERSOUND_FLAG 0x02
|
|
|
|
#define SPEAKER_FLAG 0x01
|
|
|
|
#define MIDI_FLAG 0x4000
|
|
|
|
|
|
|
|
#define NO 0
|
|
|
|
#define YES 1
|
|
|
|
#define UNDEF 2
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
#define F1_KEY 0x3B00
|
|
|
|
#define F2_KEY 0x3C00
|
|
|
|
#define F3_KEY 0x3D00
|
|
|
|
#define F4_KEY 0x3E00
|
|
|
|
#define F5_KEY 0x3F00
|
2005-04-05 15:07:40 +00:00
|
|
|
#define F6_KEY 0x4000
|
2007-03-20 14:51:57 +00:00
|
|
|
#define ESCAPE 0x001B
|
|
|
|
#define ENTER 0x000D
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
/* Video drivers */
|
|
|
|
#define UNK_DRIVER 0
|
|
|
|
#define VGA_DRIVER 1
|
|
|
|
#define EGA_DRIVER 2
|
|
|
|
#define CGA_DRIVER 3
|
|
|
|
#define HER_DRIVER 4
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
class Global {
|
|
|
|
public:
|
2006-01-04 01:48:15 +00:00
|
|
|
char _pressedKeys[128];
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
int16 _presentCGA;
|
|
|
|
int16 _presentEGA;
|
|
|
|
int16 _presentVGA;
|
|
|
|
int16 _presentHER;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
int16 _videoMode;
|
2007-02-12 12:53:28 +00:00
|
|
|
int16 _fakeVideoMode;
|
2007-03-20 14:51:57 +00:00
|
|
|
int16 _oldMode;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
int16 _frameWaitTime;
|
|
|
|
int32 _startFrameTime;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
uint16 _soundFlags;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
uint16 _language;
|
2007-02-12 14:37:27 +00:00
|
|
|
uint16 _languageWanted;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
char _useMouse;
|
|
|
|
int16 _mousePresent;
|
2006-01-04 01:48:15 +00:00
|
|
|
int16 _mouseXShift;
|
|
|
|
int16 _mouseYShift;
|
|
|
|
int16 _mouseMaxCol;
|
|
|
|
int16 _mouseMaxRow;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
char _useJoystick;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
int16 _primaryWidth;
|
|
|
|
int16 _primaryHeight;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
int16 _colorCount;
|
2006-01-04 01:48:15 +00:00
|
|
|
char _redPalette[256];
|
|
|
|
char _greenPalette[256];
|
|
|
|
char _bluePalette[256];
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
int16 _unusedPalette1[18];
|
|
|
|
int16 _unusedPalette2[16];
|
|
|
|
Video::Color _vgaPalette[16];
|
|
|
|
Video::PalDesc _paletteStruct;
|
2007-03-20 14:51:57 +00:00
|
|
|
Video::PalDesc *_pPaletteDesc;
|
|
|
|
|
|
|
|
bool _setAllPalette;
|
|
|
|
bool _dontSetPalette;
|
|
|
|
|
|
|
|
SurfaceDesc::Ptr _primarySurfDesc;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
int16 _debugFlag;
|
|
|
|
int16 _inVM;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
char _inter_resStr[200];
|
|
|
|
int32 _inter_resVal;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-11-27 14:19:30 +00:00
|
|
|
byte *_inter_variablesSizes; // 0: single byte, 1: two bytes, 3: four bytes
|
2006-01-04 01:48:15 +00:00
|
|
|
char *_inter_variables;
|
|
|
|
char *_inter_execPtr;
|
|
|
|
int16 _inter_animDataSize;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
int16 _inter_mouseX;
|
|
|
|
int16 _inter_mouseY;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-01-28 13:19:17 +00:00
|
|
|
// While using the notepad or changing the font, the original executable
|
|
|
|
// temporarily dumps Draw::_backSurface to a file. Since that's not really
|
|
|
|
// a nice thing to do, we work around it.
|
2007-03-20 14:51:57 +00:00
|
|
|
SurfaceDesc::Ptr _savedBack;
|
2007-01-28 13:19:17 +00:00
|
|
|
Video::Color _savedPal[256];
|
|
|
|
int32 _savedBackSize;
|
|
|
|
|
2007-03-29 21:03:32 +00:00
|
|
|
void clearVars(uint32 count) {
|
2007-03-20 14:51:57 +00:00
|
|
|
uint32 size = count * 4;
|
2007-01-06 11:17:20 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
memset(_inter_variables, 0, size);
|
|
|
|
memset(_inter_variablesSizes, 0, size);
|
|
|
|
for (uint32 i = 0; i < size; i += 4)
|
|
|
|
_inter_variablesSizes[i] = 3;
|
2007-01-06 11:17:20 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void writeVarSizeStr(uint32 offset, uint32 len) {
|
2006-11-27 14:19:30 +00:00
|
|
|
uint32 i;
|
|
|
|
uint32 inVar;
|
|
|
|
uint32 varOff;
|
|
|
|
|
|
|
|
inVar = offset % 4;
|
|
|
|
varOff = (offset >> 2) << 2;
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
if (_inter_variablesSizes[varOff + i] == 3)
|
|
|
|
_inter_variablesSizes[varOff + i] = 0;
|
|
|
|
else if ((inVar == (i+1)) && (_inter_variablesSizes[varOff + i] == 1))
|
|
|
|
_inter_variablesSizes[varOff + i] = 0;
|
|
|
|
}
|
|
|
|
memset(_inter_variablesSizes + offset, 0, len);
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void writeVar(uint32 offset, uint32 val) {
|
2006-11-27 14:19:30 +00:00
|
|
|
(*(uint32 *)(_inter_variables + offset)) = val;
|
|
|
|
writeVarSize(offset, 3);
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
void writeVar(uint32 offset, uint16 val) {
|
2006-11-27 14:19:30 +00:00
|
|
|
(*(uint16 *)(_inter_variables + offset)) = val;
|
|
|
|
writeVarSize(offset, 1);
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
void writeVar(uint32 offset, uint8 val) {
|
2006-11-27 14:19:30 +00:00
|
|
|
(*(uint8 *)(_inter_variables + offset)) = val;
|
|
|
|
writeVarSize(offset, 0);
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
void writeVar(uint32 offset, const char *str) {
|
2006-11-27 14:19:30 +00:00
|
|
|
writeVarSizeStr(offset, strlen(str));
|
|
|
|
strcpy(_inter_variables + offset, str);
|
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
Global(GobEngine *vm);
|
2007-02-04 15:45:15 +00:00
|
|
|
~Global();
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
protected:
|
|
|
|
GobEngine *_vm;
|
2006-11-27 14:19:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void writeVarSize(uint32 offset, byte n) {
|
2006-11-27 14:19:30 +00:00
|
|
|
uint32 i;
|
|
|
|
uint32 inVar;
|
|
|
|
uint32 varOff;
|
|
|
|
|
|
|
|
inVar = offset % 4;
|
|
|
|
varOff = (offset >> 2) << 2;
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
if (_inter_variablesSizes[varOff + i] == 3)
|
|
|
|
_inter_variablesSizes[varOff + i] = 0;
|
|
|
|
else if ((inVar == (i+1)) && (_inter_variablesSizes[varOff + i] == 1))
|
|
|
|
_inter_variablesSizes[varOff + i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_inter_variablesSizes[offset] = n;
|
|
|
|
for (; n > 0; n--)
|
|
|
|
_inter_variablesSizes[offset + n] = 0;
|
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
};
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2005-08-08 20:20:00 +00:00
|
|
|
} // End of namespace Gob
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
#endif // GOB_GLOBAL_H
|