Example #1
0
bool Game::compareObjectTransformYPos(int object, bool fetchCmp, int cmpY) {
	debug(DBG_GAME, "Game::compareObjectTransformYPos(%d)", object);
	SceneObject *so = derefSceneObject(object);
	const int h = derefSceneObjectFrame(so->frameNum)->hdr.h;

	int16_t a0 = _objectScript.fetchNextWord();
	int16_t a2 = _objectScript.fetchNextWord();
	int16_t a4 = _objectScript.fetchNextWord();
	int16_t a6 = _objectScript.fetchNextWord();
	int16_t a8 = _objectScript.fetchNextWord();
	int16_t aA = _objectScript.fetchNextWord();
	if (fetchCmp) {
		cmpY = _objectScript.fetchNextWord();
	}

	int16_t ymin = a0 * h / a2 + a4;
	int16_t ymax = a6 * h / a8 + aA;
	if (so->flip == 1) {
		ymin = h - ymin;
		ymax = h - ymax;
	}
	if (ymax < ymin) {
		SWAP(ymax, ymin);
	}
	return so->state != 0 && so->y + ymin <= cmpY && so->y + ymax >= cmpY;
}
Example #2
0
bool Game::compareObjectTransformXPos(int object, bool fetchCmp, int cmpX) {
	debug(DBG_GAME, "Game::compareObjectTransformXPos(%d)", object);
	SceneObject *so = derefSceneObject(object);
	const int w = derefSceneObjectFrame(so->frameNum)->hdr.w;

	int16_t a0 = _objectScript.fetchNextWord();
	int16_t a2 = _objectScript.fetchNextWord();
	int16_t a4 = _objectScript.fetchNextWord();
	int16_t a6 = _objectScript.fetchNextWord();
	int16_t a8 = _objectScript.fetchNextWord();
	int16_t aA = _objectScript.fetchNextWord();
	if (fetchCmp) {
		cmpX = _objectScript.fetchNextWord();
	}

	int16_t xmin = a0 * w / a2 + a4;
	int16_t xmax = a6 * w / a8 + aA;
	if (so->flip == 2) {
		xmin = w - xmin;
		xmax = w - xmax;
	}
	if (xmax < xmin) {
		SWAP(xmax, xmin);
	}
	return so->state != 0 && so->x + xmin <= cmpX && so->x + xmax >= cmpX;
}
Example #3
0
int16_t Game::getObjectTransformYPos(int object) {
	debug(DBG_GAME, "Game::getObjectTransformYPos(%d)", object);
	SceneObject *so = derefSceneObject(object);
	const int h = derefSceneObjectFrame(so->frameNumPrev)->hdr.h;

	int16_t a0 = _objectScript.fetchNextWord();
	int16_t a2 = _objectScript.fetchNextWord();
	int16_t a4 = _objectScript.fetchNextWord();

	int16_t dy = a0 * h / a2 + a4;
	if (so->flipPrev == 1) {
		dy = h - dy - 1;
	}
	return so->yPrev + dy;
}
Example #4
0
int16_t Game::getObjectTransformXPos(int object) {
	debug(DBG_GAME, "Game::getObjectTransformXPos(%d)", object);
	SceneObject *so = derefSceneObject(object);
	const int w = derefSceneObjectFrame(so->frameNumPrev)->hdr.w;

	int16_t a0 = _objectScript.fetchNextWord();
	int16_t a2 = _objectScript.fetchNextWord();
	int16_t a4 = _objectScript.fetchNextWord();

	int16_t dx = a0 * w / a2 + a4;
	if (so->flipPrev == 2) {
		dx = w - dx - 1;
	}
	return so->xPrev + dx;
}
Example #5
0
void Game::oop_initializeObject() {
	debug(DBG_OPCODES, "Game::oop_initializeObject");
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index != -1) {
		SceneObject *so = derefSceneObject(index);
		int16 op = _objectScript.fetchNextWord();
		if (op == 0) {
			if (so->state != 0) {
				so->x = so->xPrev;
				so->y = so->yPrev;
				so->frameNum = so->frameNumPrev;
				if (so->state == 2) {
					SceneObjectFrame *sof = derefSceneObjectFrame(so->frameNum);
					copyBufferToBuffer(so->x, _bitmapBuffer1.h + 1 - so->y - sof->hdr.h, sof->hdr.w, sof->hdr.h, &_bitmapBuffer3, &_bitmapBuffer1);
				}
				so->state = -1;
			}
		} else if (op == 1) {
			int16 mode = so->mode;
			so->mode = 1;
			reinitializeObject(index);
			so->mode = mode;
			if (so->state == 2) {
				so->state = 1;
			}
		} else if (op == 2) {
			if (so->state == 1) {
				so->x = so->xPrev;
				so->y = so->yPrev;
				so->frameNum = so->frameNumPrev;
				so->state = 2;
			} else {
				int16 mode = so->mode;
				so->mode = 3;
				reinitializeObject(index);
				so->mode = mode;
			}
		}
	} else {
		_objectScript.dataOffset += 2;
	}
}
Example #6
0
void Game::setupObjectPos(int object, int object2, int useObject2, int useData, int type1, int type2) {
	debug(DBG_GAME, "Game::setupObjectPos(%d)", object);
	SceneObject *so = derefSceneObject(object);
	SceneObjectFrame *sof = derefSceneObjectFrame(so->frameNumPrev);
	int16_t a0, a2, a4;
	int16_t dy = 0, dx = 0, xmin = 0, xmax, ymin = 0, ymax, _ax;
	if (so->statePrev != 0) {
		if (type1 == 2) {
			a0 = _objectScript.fetchNextWord();
			a2 = _objectScript.fetchNextWord();
			a4 = _objectScript.fetchNextWord();
			xmin = a0 * sof->hdr.w / a2 + a4;
			a0 = _objectScript.fetchNextWord();
			a2 = _objectScript.fetchNextWord();
			a4 = _objectScript.fetchNextWord();
			xmax = a0 * sof->hdr.w / a2 + a4;
			if (xmax < xmin) {
				SWAP(xmin, xmax);
			}
			dx = xmax - xmin;
		}
		if (type2 == 2) {
			a0 = _objectScript.fetchNextWord();
			a2 = _objectScript.fetchNextWord();
			a4 = _objectScript.fetchNextWord();
			ymin = a0 * sof->hdr.h / a2 + a4;
			a0 = _objectScript.fetchNextWord();
			a2 = _objectScript.fetchNextWord();
			a4 = _objectScript.fetchNextWord();
			ymax = a0 * sof->hdr.h / a2 + a4;
			if (ymax < ymin) {
				SWAP(ymin, ymax);
			}
			dy = ymax - ymin;
		}

		if (useObject2 == 0) {
			_ax = _animationsTable[_sceneObjectMotionsTable[so->motionNum1].animNum].firstMotionIndex;
		} else {
			_ax = _sceneObjectsTable[object2].motionInit;
		}
		so->motionNum2 = _ax + _objectScript.fetchNextWord() - 1;
		if (useData == 0) {
			so->frameNum = _sceneObjectMotionsTable[so->motionNum2].firstFrameIndex;
		} else {
			so->frameNum = _sceneObjectMotionsTable[so->motionNum2].firstFrameIndex + _objectScript.fetchNextWord() - 1;
		}

		int16_t _si = _sceneObjectFramesTable[so->frameNum].hdr.xPos - sof->hdr.xPos;
		if (type1 == 2) {
			 _si = ((xmin - dx + 1) / dx) * dx + _si % dx;
			if (_si < xmin) {
				_si += dx;
			}
		} else if (type1 == 3) {
			a0 = _objectScript.fetchNextWord();
			_objectScript.fetchNextWord();
			_si = a0 - sof->hdr.xPos;
		}

		int16_t _di = _sceneObjectFramesTable[so->frameNum].hdr.yPos - sof->hdr.yPos;
		if (type2 == 2) {
			_di = ((ymin - dy + 1) / dy) * dy + _di % dy;
			if (_di < ymin) {
				_di += dy;
			}
		} else if (type2 == 3) {
			_objectScript.fetchNextWord();
			a2 = _objectScript.fetchNextWord();
			_di = a2 - sof->hdr.yPos;
		}

		if (so->flipPrev == 2) {
			_ax = so->xPrev - _si;
			_ax += _sceneObjectFramesTable[so->frameNumPrev].hdr.w;
			_ax -= _sceneObjectFramesTable[so->frameNum].hdr.w;
		} else {
			_ax = so->xPrev + _si;
		}
		so->x = _ax;
		so->y = so->yPrev + _di;
	}
}