Ejemplo n.º 1
0
void ScummEngine::putClass(int obj, int cls, bool set) {
	assertRange(0, obj, _numGlobalObjects - 1, "object");
	cls &= 0x7F;
	assertRange(1, cls, 32, "class");

	if (_game.features & GF_SMALL_HEADER) {
		// Translate the new (V5) object classes to the old classes
		// (for those which differ).
		switch (cls) {
		case kObjectClassUntouchable:
			cls = 24;
			break;
		case kObjectClassPlayer:
			cls = 23;
			break;
		case kObjectClassXFlip:
			cls = 19;
			break;
		case kObjectClassYFlip:
			cls = 18;
			break;
		}
	}

	if (set)
		_classData[obj] |= (1 << (cls - 1));
	else
		_classData[obj] &= ~(1 << (cls - 1));

	if (_game.version <= 4 && obj >= 1 && obj < _numActors) {
		_actors[obj]->classChanged(cls, set);
	}
}
Ejemplo n.º 2
0
int ScummEngine_v90he::getHEPaletteSimilarColor(int palSlot, int red, int green, int start, int end) {
	assertRange(1, palSlot, _numPalettes, "palette");
	assertRange(0, start, 255, "start palette slot");
	assertRange(0, end, 255, "pend alette slot");

	uint8 *pal = _hePalettes + palSlot * _hePaletteSlot + start * 3;

	int bestsum = 0x7FFFFFFF;
	int bestitem = start;

	for (int i = start; i <= end; i++) {
		int dr = red - pal[0];
		int dg = green - pal[1];
		int sum = dr * dr + dg * dg * 2;
		if (sum == 0) {
			return i;
		}
		if (sum < bestsum) {
			bestsum = sum;
			bestitem = i;
		}
		pal += 3;
	}
	return bestitem;
}
Ejemplo n.º 3
0
bool ScummEngine::getClass(int obj, int cls) const {
	assertRange(0, obj, _numGlobalObjects - 1, "object");
	cls &= 0x7F;
	assertRange(1, cls, 32, "class");

	if (_game.features & GF_SMALL_HEADER) {
		// Translate the new (V5) object classes to the old classes
		// (for those which differ).
		switch (cls) {
		case kObjectClassUntouchable:
			cls = 24;
			break;
		case kObjectClassPlayer:
			cls = 23;
			break;
		case kObjectClassXFlip:
			cls = 19;
			break;
		case kObjectClassYFlip:
			cls = 18;
			break;
		}
	}

	return (_classData[obj] & (1 << (cls - 1))) != 0;
}
Ejemplo n.º 4
0
Archivo: patch.c Proyecto: freund3/USGS
void go_herbivore(int x, int y){

	patches[x][y].herbivore_phyto_prey_limitation = patches[x][y].phyto \
		/ (Ai_herbivore_phyto - Gi_herbivore_phyto);
	patches[x][y].herbivore_phyto_prey_limitation = \
	    assertRange(patches[x][y].herbivore_phyto_prey_limitation, 0, 1);

    patches[x][y].herbivore_peri_prey_limitation = patches[x][y].peri \
        / (Ai_herbivore_phyto - Gi_herbivore_phyto);
    patches[x][y].herbivore_peri_prey_limitation = \
        assertRange( patches[x][y].herbivore_peri_prey_limitation, 0, 1);

    patches[x][y].herbivore_waterdecomp_prey_limitation = \
        patches[x][y].waterdecomp / \
        (Ai_herbivore_phyto - Gi_herbivore_phyto);
    patches[x][y].herbivore_waterdecomp_prey_limitation = \
        assertRange(patches[x][y].herbivore_waterdecomp_prey_limitation, 0, 1);

    patches[x][y].herbivore_space_limitation = 1 - \
        ((patches[x][y].herbivore - Aj_herbivore) / \
         (Gj_herbivore - Aj_herbivore));
    patches[x][y].herbivore_space_limitation = \
        assertRange(patches[x][y].herbivore_space_limitation, 0, 1);

    patches[x][y].herbivore_pred_phyto = pref_herbivore_phyto * \
        max_herbivore * patches[x][y].herbivore * 
        patches[x][y].herbivore_space_limitation *
        patches[x][y].herbivore_phyto_prey_limitation;

    patches[x][y].herbivore_ingest_phyto = \
        patches[x][y].herbivore_pred_phyto * (1 - herbivore_egestion);

    patches[x][y].herbivore_pred_peri = \
        pref_herbivore_peri * max_herbivore * patches[x][y].herbivore \
        * patches[x][y].herbivore_space_limitation \
        * patches[x][y].herbivore_peri_prey_limitation;

    patches[x][y].herbivore_ingest_peri = \
        patches[x][y].herbivore_pred_peri * (1 - herbivore_egestion);

    patches[x][y].herbivore_pred_waterdecomp = \
        pref_herbivore_waterdecomp * max_herbivore * \
        patches[x][y].herbivore * \
        patches[x][y].herbivore_space_limitation * \
        patches[x][y].herbivore_waterdecomp_prey_limitation;

    patches[x][y].herbivore_ingest_waterdecomp = \
        patches[x][y].herbivore_pred_waterdecomp * \
        (1 - herbivore_egestion);

    patches[x][y].herbivore_respiration = r_herbivore * \
        patches[x][y].herbivore;

    patches[x][y].herbivore_excretion = e_herbivore * \
        patches[x][y].herbivore;

    patches[x][y].herbivore_senescence = s_herbivore * \
        patches[x][y].herbivore;
}
Ejemplo n.º 5
0
int ScummEngine_v8::readVar(uint var) {
	debugC(DEBUG_VARS, "readvar(%d)", var);

	if (!(var & 0xF0000000)) {
		assertRange(0, var, _numVariables - 1, "variable");
		return _scummVars[var];
	}

	if (var & 0x80000000) {
		var &= 0x7FFFFFFF;
		assertRange(0, var, _numBitVariables - 1, "bit variable (reading)");
		return (_bitVars[var >> 3] & (1 << (var & 7))) ? 1 : 0;
	}
Ejemplo n.º 6
0
void CharsetRendererClassic::printChar(int chr, bool ignoreCharsetMask) {
	int width, height, origWidth, origHeight;
	int offsX, offsY;
	VirtScreen *vs;
	const byte *charPtr;
	bool is2byte = (chr >= 256 && _vm->_useCJKMode);

	assertRange(1, _curId, _vm->_numCharsets - 1, "charset");

	if ((vs = _vm->findVirtScreen(_top)) == NULL && (vs = _vm->findVirtScreen(_top + getFontHeight())) == NULL)
		return;

	if (chr == '@')
		return;

	translateColor();

	_vm->_charsetColorMap[1] = _color;

#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
	processTownsCharsetColors(_bytesPerPixel);
	bool noSjis = false;

	if (_vm->_game.platform == Common::kPlatformFMTowns && _vm->_useCJKMode) {
		if ((chr & 0x00ff) == 0x00fd) {
			chr >>= 8;
			noSjis = true;
		}
	}
Ejemplo n.º 7
0
 //! ---|> NormalAttributeAccessor
 Geometry::Vec3 getNormal(uint32_t index)const override {
     assertRange(index);
     const int8_t * v = _ptr<const int8_t>(index);
     return Geometry::Vec3(Geometry::Convert::fromSignedTo<float>(v[0]),
                           Geometry::Convert::fromSignedTo<float>(v[1]),
                           Geometry::Convert::fromSignedTo<float>(v[2]));
 }
Ejemplo n.º 8
0
 //! ---|> NormalAttributeAccessor
 void setNormal(uint32_t index, const Geometry::Vec3 & n) override {
     assertRange(index);
     int8_t * v = _ptr<int8_t>(index);
     v[0] = Geometry::Convert::toSigned<int8_t>(n.x());
     v[1] = Geometry::Convert::toSigned<int8_t>(n.y());
     v[2] = Geometry::Convert::toSigned<int8_t>(n.z());
 }
Ejemplo n.º 9
0
int ScummEngine_v2::readVar(uint var) {
	if (var >= 14 && var <= 16)
		var = _scummVars[var];

	assertRange(0, var, _numVariables - 1, "variable (reading)");
	debugC(DEBUG_VARS, "readvar(%d) = %d", var, _scummVars[var]);
	return _scummVars[var];
}
Ejemplo n.º 10
0
void PickAtomRange::setRange(
	const MoleculeBase &molecule,
	size_t _StartAtomIndex,
	size_t _EndAtomIndex
	)
{
	m_StartAtomIndex=_StartAtomIndex;
	m_NAtoms=_EndAtomIndex - m_StartAtomIndex + 1;
	assertRange(molecule);
}
Ejemplo n.º 11
0
Archivo: patch.c Proyecto: freund3/USGS
void go_waterdecomp(int x, int y){

    patches[x][y].waterdecomp_doc_prey_limitation = patches[x][y].DOC \
        / (Ai_waterdecomp_DOC - Gi_waterdecomp_DOC);
    patches[x][y].waterdecomp_doc_prey_limitation = \
        assertRange(patches[x][y].waterdecomp_doc_prey_limitation, 0, 1);

    patches[x][y].waterdecomp_poc_prey_limitation = patches[x][y].POC \
        / (Ai_waterdecomp_POC - Gi_waterdecomp_POC);
    patches[x][y].waterdecomp_poc_prey_limitation = \
        assertRange(patches[x][y].waterdecomp_poc_prey_limitation, 0, 1);

    patches[x][y].waterdecomp_space_limitation = 1 - \
        ((patches[x][y].waterdecomp - Aj_waterdecomp) / \
         (Gj_waterdecomp - Aj_waterdecomp));
    patches[x][y].waterdecomp_space_limitation = \
        assertRange(patches[x][y].waterdecomp_space_limitation, 0, 1);

    patches[x][y].waterdecomp_pred_doc = (pref_waterdecomp_DOC \
        * max_waterdecomp * patches[x][y].waterdecomp * \
        patches[x][y].waterdecomp_space_limitation * \
        patches[x][y].waterdecomp_doc_prey_limitation);

    patches[x][y].waterdecomp_ingest_doc = \
        patches[x][y].waterdecomp_pred_doc;

    patches[x][y].waterdecomp_pred_doc = pref_waterdecomp_POC \
        * max_waterdecomp * patches[x][y].waterdecomp \
        * patches[x][y].waterdecomp_space_limitation \
        *  patches[x][y].waterdecomp_poc_prey_limitation;

    patches[x][y].waterdecomp_ingest_poc = \
        patches[x][y].waterdecomp_pred_poc;

    patches[x][y].waterdecomp_respiration = r_waterdecomp * \
        patches[x][y].waterdecomp;

    patches[x][y].waterdecomp_excretion = e_waterdecomp * \
        patches[x][y].waterdecomp;

    patches[x][y].waterdecomp_senescence = s_waterdecomp * \
        patches[x][y].waterdecomp;
}
Ejemplo n.º 12
0
void ScummEngine_v2::writeVar(uint var, int value) {
	assertRange(0, var, _numVariables - 1, "variable (writing)");
	debugC(DEBUG_VARS, "writeVar(%d) = %d", var, value);

	if (VAR_CUTSCENEEXIT_KEY != 0xFF && var == VAR_CUTSCENEEXIT_KEY) {
		// Remap the cutscene exit key in earlier games
		if (value == 4 || value == 13 || value == 64)
			value = 27;
	}

	_scummVars[var] = value;
}
Ejemplo n.º 13
0
uint8 *ScummEngine::getHEPaletteSlot(uint16 palSlot) {
    assertRange(0, palSlot, _numPalettes, "palette");

    if (_game.heversion >= 99) {
        if (palSlot)
            return _hePalettes + palSlot * _hePaletteSlot + 768;
        else
            return _hePalettes + _hePaletteSlot + 768;
    }

    return NULL;
}
Ejemplo n.º 14
0
void SoundHE::setSoundVar(int sound, int var, int val) {
	assertRange(0, var, 25, "sound variable");

	int chan = -1;
	for (int i = 0; i < ARRAYSIZE(_heChannel); i ++) {
		if (_heChannel[i].sound == sound)
			chan = i;
	}

	if (chan != -1) {
		debug(5, "setSoundVar: sound %d var %d val %d", sound, var, val);
		_heChannel[chan].soundVars[var] = val;
	}
}
Ejemplo n.º 15
0
int ScummEngine::getState(int obj) {
	assertRange(0, obj, _numGlobalObjects - 1, "object");

	if (!_copyProtection) {
		// I knew LucasArts sold cracked copies of the original Maniac Mansion,
		// at least as part of Day of the Tentacle. Apparently they also sold
		// cracked versions of the enhanced version. At least in Germany.
		//
		// This will keep the security door open at all times. I can only
		// assume that 182 and 193 each correspond to one particular side of
		// it. Fortunately this does not prevent frustrated players from
		// blowing up the mansion, should they feel the urge to.

		if (_game.id == GID_MANIAC && _game.version != 0 && (obj == 182 || obj == 193))
			_objectStateTable[obj] |= kObjectState_08;
	}

	return _objectStateTable[obj];
}
Ejemplo n.º 16
0
void CharsetRendererV3::setCurID(int32 id) {
	if (id == -1)
		return;

	assertRange(0, id, _vm->_numCharsets - 1, "charset");

	_curId = id;

	_fontPtr = _vm->getResourceAddress(rtCharset, id);
	if (_fontPtr == 0)
		error("CharsetRendererCommon::setCurID: charset %d not found", id);

	_bytesPerPixel = 1;
	_numChars = _fontPtr[4];
	_fontHeight = _fontPtr[5];

	_fontPtr += 6;
	_widthTable = _fontPtr;
	_fontPtr += _numChars;
}
Ejemplo n.º 17
0
void ScummEngine_v4::loadCharset(int no) {
	uint32 size;
	memset(_charsetData, 0, sizeof(_charsetData));

	assertRange(0, no, 4, "charset");
	closeRoom();

	Common::File file;
	char buf[20];

	sprintf(buf, "%03d.LFL", 900 + no);
	file.open(buf);

	if (file.isOpen() == false) {
		error("loadCharset(%d): Missing file charset: %s", no, buf);
	}

	size = file.readUint32LE() + 11;
	file.read(_res->createResource(rtCharset, no, size), size);
}
Ejemplo n.º 18
0
int SoundHE::getSoundVar(int sound, int var) {
	if (_vm->_game.heversion >= 90 && var == 26) {
		return isSoundCodeUsed(sound);
	}

	assertRange(0, var, 25, "sound variable");

	int chan = -1;
	for (int i = 0; i < ARRAYSIZE(_heChannel); i ++) {
		if (_heChannel[i].sound == sound)
			chan = i;
	}

	if (chan != -1 && _mixer->isSoundHandleActive(_heSoundChannels[chan])) {
		debug(5, "getSoundVar: sound %d var %d result %d", sound, var, _heChannel[chan].soundVars[var]);
		return _heChannel[chan].soundVars[var];
	} else {
		return 0;
	}
}
Ejemplo n.º 19
0
void CharsetRendererCommon::setCurID(int32 id) {
	if (id == -1)
		return;

	assertRange(0, id, _vm->_numCharsets - 1, "charset");

	_curId = id;

	_fontPtr = _vm->getResourceAddress(rtCharset, id);
	if (_fontPtr == 0)
		error("CharsetRendererCommon::setCurID: charset %d not found", id);

	if (_vm->_game.version == 4)
		_fontPtr += 17;
	else
		_fontPtr += 29;

	_bytesPerPixel = _fontPtr[0];
	_fontHeight = _fontPtr[1];
	_numChars = READ_LE_UINT16(_fontPtr + 2);
}
Ejemplo n.º 20
0
 //! ---|> ColorAttributeAccessor
 void setColor(uint32_t index, const Util::Color4f & c) override {
     assertRange(index);
     float * v = _ptr<float>(index);
     v[0] = c.getR() , v[1] = c.getG() , v[2] = c.getB() , v[3] = c.getA();
 }
Ejemplo n.º 21
0
 //! ---|> ColorAttributeAccessor
 Util::Color4ub getColor4ub(uint32_t index)const override {
     assertRange(index);
     const float * v = _ptr<const float>(index);
     return Util::Color4ub(Util::Color4f(v[0], v[1], v[2], v[3]));
 }
Ejemplo n.º 22
0
 //! ---|> ColorAttributeAccessor
 void setColor(uint32_t index, const Util::Color4ub & cub) override {
     const Util::Color4f c(cub);
     assertRange(index);
     float * v = _ptr<float>(index);
     v[0] = c.getR() , v[1] = c.getG() , v[2] = c.getB();
 }
Ejemplo n.º 23
0
 //! ---|> NormalAttributeAccessor
 void setNormal(uint32_t index, const Geometry::Vec3 & n) override {
     assertRange(index);
     float * v = _ptr<float>(index);
     v[0] = n.x() , v[1] = n.y() , v[2] = n.z();
 }
Ejemplo n.º 24
0
 //! ---|> NormalAttributeAccessor
 Geometry::Vec3 getNormal(uint32_t index)const override {
     assertRange(index);
     const float * v = _ptr<const float>(index);
     return Geometry::Vec3(v[0], v[1], v[2]);
 }
Ejemplo n.º 25
0
 //! ---|> ColorAttributeAccessor
 void setColor(uint32_t index, const Util::Color4f & cf) override {
     const Util::Color4ub c(cf);
     assertRange(index);
     uint8_t * v = _ptr<uint8_t>(index);
     v[0] = c.getR() , v[1] = c.getG() , v[2] = c.getB() , v[3] = c.getA();
 }
Ejemplo n.º 26
0
 //! ---|> ColorAttributeAccessor
 Util::Color4f getColor4f(uint32_t index)const override {
     assertRange(index);
     const uint8_t * v = _ptr<const uint8_t>(index);
     return Util::Color4ub(v[0], v[1], v[2], v[3]);
 }
Ejemplo n.º 27
0
void ScummEngine_v60he::o60_roomOps() {
	int a, b, c, d, e;

	byte subOp = fetchScriptByte();

	switch (subOp) {
	case 172:		// SO_ROOM_SCROLL
		b = pop();
		a = pop();
		if (a < (_screenWidth / 2))
			a = (_screenWidth / 2);
		if (b < (_screenWidth / 2))
			b = (_screenWidth / 2);
		if (a > _roomWidth - (_screenWidth / 2))
			a = _roomWidth - (_screenWidth / 2);
		if (b > _roomWidth - (_screenWidth / 2))
			b = _roomWidth - (_screenWidth / 2);
		VAR(VAR_CAMERA_MIN_X) = a;
		VAR(VAR_CAMERA_MAX_X) = b;
		break;

	case 174:		// SO_ROOM_SCREEN
		b = pop();
		a = pop();
		if (_game.heversion >= 71)
			initScreens(a, _screenHeight);
		else
			initScreens(a, b);
		break;

	case 175:		// SO_ROOM_PALETTE
		d = pop();
		c = pop();
		b = pop();
		a = pop();
		setPalColor(d, a, b, c);
		break;

	case 176:		// SO_ROOM_SHAKE_ON
		setShake(1);
		break;

	case 177:		// SO_ROOM_SHAKE_OFF
		setShake(0);
		break;

	case 179:		// SO_ROOM_INTENSITY
		c = pop();
		b = pop();
		a = pop();
		darkenPalette(a, a, a, b, c);
		break;

	case 180:		// SO_ROOM_SAVEGAME
		_saveTemporaryState = true;
		_saveLoadSlot = pop();
		_saveLoadFlag = pop();
		break;

	case 181:		// SO_ROOM_FADE
		a = pop();
		if (_game.heversion >= 70) {
			// Defaults to 1 but doesn't use fade effects
		} else if (a) {
			_switchRoomEffect = (byte)(a & 0xFF);
			_switchRoomEffect2 = (byte)(a >> 8);
		} else {
			fadeIn(_newEffect);
		}
		break;

	case 182:		// SO_RGB_ROOM_INTENSITY
		e = pop();
		d = pop();
		c = pop();
		b = pop();
		a = pop();
		darkenPalette(a, b, c, d, e);
		break;

	case 183:		// SO_ROOM_SHADOW
		e = pop();
		d = pop();
		c = pop();
		b = pop();
		a = pop();
		if (_game.heversion == 60)
			setShadowPalette(a, b, c, d, e, 0, 256);
		break;

	case 186:		// SO_ROOM_TRANSFORM
		d = pop();
		c = pop();
		b = pop();
		a = pop();
		palManipulateInit(a, b, c, d);
		break;

	case 187:		// SO_CYCLE_SPEED
		b = pop();
		a = pop();
		assertRange(1, a, 16, "o60_roomOps: 187: color cycle");
		_colorCycle[a - 1].delay = (b != 0) ? 0x4000 / (b * 0x4C) : 0;
		break;

	case 213:		// SO_ROOM_NEW_PALETTE
		a = pop();
		setCurrentPalette(a);
		break;
	case 220:
		a = pop();
		b = pop();
		copyPalColor(a, b);
		break;
	case 221:
		byte buffer[100];
		int len, r;

		convertMessageToString(_scriptPointer, buffer, sizeof(buffer));
		len = resStrLen(_scriptPointer);
		_scriptPointer += len + 1;

		r = convertFilePath(buffer, sizeof(buffer));
		memcpy(_saveLoadFileName, buffer + r, sizeof(buffer) - r);
		debug(1, "o60_roomOps: case 221: filename %s", _saveLoadFileName);

		_saveLoadFlag = pop();
		_saveLoadSlot = 255;
		_saveTemporaryState = true;
		break;
	case 234:		// HE 7.1
		b = pop();
		a = pop();
		swapObjects(a, b);
		break;
	case 236:		// HE 7.1
		b = pop();
		a = pop();
		setRoomPalette(a, b);
		break;
	default:
		error("o60_roomOps: default case %d", subOp);
	}
Ejemplo n.º 28
0
int ScummEngine::getObjectRoom(int obj) const {
	assertRange(0, obj, _numGlobalObjects - 1, "object");
	return _objectRoomTable[obj];
}
Ejemplo n.º 29
0
void ScummEngine::putState(int obj, int state) {
	assertRange(0, obj, _numGlobalObjects - 1, "object");
	assertRange(0, state, 0xFF, "state");
	_objectStateTable[obj] = state;
}
Ejemplo n.º 30
0
void ScummEngine::putOwner(int obj, int owner) {
	assertRange(0, obj, _numGlobalObjects - 1, "object");
	assertRange(0, owner, 0xFF, "owner");
	_objectOwnerTable[obj] = owner;
}