2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2006-05-23 23:43:52 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* 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.
|
2006-05-23 23:43:52 +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
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "agi/agi.h"
|
|
|
|
|
|
|
|
namespace Agi {
|
|
|
|
|
2007-09-03 09:39:15 +00:00
|
|
|
int AgiBase::getflag(int n) {
|
2007-01-16 12:40:51 +00:00
|
|
|
uint8 *set = (uint8 *)&_game.flags;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
set += n >> 3;
|
|
|
|
return (*set & (1 << (n & 0x07))) != 0;
|
|
|
|
}
|
|
|
|
|
2007-09-03 09:39:15 +00:00
|
|
|
void AgiBase::setflag(int n, int v) {
|
2007-01-16 12:40:51 +00:00
|
|
|
uint8 *set = (uint8 *)&_game.flags;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
set += n >> 3;
|
|
|
|
if (v)
|
2009-06-06 17:39:13 +00:00
|
|
|
*set |= 1 << (n & 0x07); // set bit
|
2006-05-23 23:43:52 +00:00
|
|
|
else
|
2009-06-06 17:39:13 +00:00
|
|
|
*set &= ~(1 << (n & 0x07)); // clear bit
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2007-09-03 09:39:15 +00:00
|
|
|
void AgiBase::flipflag(int n) {
|
2007-01-16 12:40:51 +00:00
|
|
|
uint8 *set = (uint8 *)&_game.flags;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
set += n >> 3;
|
2009-06-06 17:39:13 +00:00
|
|
|
*set ^= 1 << (n & 0x07); // flip bit
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void AgiEngine::setvar(int var, int val) {
|
2007-01-16 12:40:51 +00:00
|
|
|
_game.vars[var] = val;
|
2009-05-18 21:37:13 +00:00
|
|
|
|
|
|
|
if (var == vVolume) {
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, val * 17);
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, val * 17);
|
|
|
|
}
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
int AgiEngine::getvar(int var) {
|
2007-01-16 12:40:51 +00:00
|
|
|
return _game.vars[var];
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void AgiEngine::decrypt(uint8 *mem, int len) {
|
2006-05-31 10:53:04 +00:00
|
|
|
const uint8 *key;
|
2006-05-23 23:43:52 +00:00
|
|
|
int i;
|
|
|
|
|
2007-02-13 15:27:36 +00:00
|
|
|
key = (getFeatures() & GF_AGDS) ? (const uint8 *)CRYPT_KEY_AGDS
|
2007-01-07 18:02:54 +00:00
|
|
|
: (const uint8 *)CRYPT_KEY_SIERRA;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
*(mem + i) ^= *(key + (i % 11));
|
|
|
|
}
|
|
|
|
|
2007-01-07 18:02:54 +00:00
|
|
|
} // End of namespace Agi
|