Esempio n. 1
0
void AGOSEngine::vc48_setPathFinder() {
	uint16 a = (uint16)_variableArrayPtr[12];
	const uint16 *p = _pathFindArray[a - 1];

	uint b = (uint16)_variableArray[13];
	p += b * 2 + 1;
	int c = _variableArray[14];

	int step;
	int y1, y2;
	int16 *vp;

	step = 2;
	if (c < 0) {
		c = -c;
		step = -2;
	}

	vp = &_variableArray[20];

	do {
		y2 = readUint16Wrapper(p);
		p += step;
		y1 = readUint16Wrapper(p) - y2;

		vp[0] = y1 / 2;
		vp[1] = y1 - (y1 / 2);

		vp += 2;
	} while (--c);
}
Esempio n. 2
0
void AGOSEngine_Simon1::os1_getPathPosn() {
	// 178: path find
	uint x = getVarOrWord();
	uint y = getVarOrWord();
	uint var_1 = getVarOrByte();
	uint var_2 = getVarOrByte();

	const uint16 *p;
	uint i, j;
	uint prev_i;
	uint x_diff, y_diff;
	uint best_i = 0, best_j = 0, best_dist = 0xFFFFFFFF;
	uint maxPath = (getGameType() == GType_FF || getGameType() == GType_PP) ? 100 : 20;

	if (getGameType() == GType_FF || getGameType() == GType_PP) {
		x += _scrollX;
		y += _scrollY;
	} else if (getGameType() == GType_SIMON2) {
		x += _scrollX * 8;
	}

	int end = (getGameType() == GType_FF) ? 9999 : 999;
	prev_i = maxPath + 1 - readVariable(12);
	for (i = maxPath; i != 0; --i) {
		p = (const uint16 *)_pathFindArray[maxPath - i];
		if (!p)
			continue;
		for (j = 0; readUint16Wrapper(&p[0]) != end; j++, p += 2) {
			x_diff = ABS((int16)(readUint16Wrapper(&p[0]) - x));
			y_diff = ABS((int16)(readUint16Wrapper(&p[1]) - 12 - y));

			if (x_diff < y_diff) {
				x_diff /= 4;
				y_diff *= 4;
			}
			x_diff += y_diff /= 4;

			if ((x_diff < best_dist) || ((x_diff == best_dist) && (prev_i == i))) {
				best_dist = x_diff;
				best_i = maxPath + 1 - i;
				best_j = j;
			}
		}
	}

	writeVariable(var_1, best_i);
	writeVariable(var_2, best_j);
}
Esempio n. 3
0
void AGOSEngine::vc17_setPathfinderItem() {
	uint16 a = vcReadNextWord();
	_pathFindArray[a - 1] = (const uint16 *)_vcPtr;

	int end = (getGameType() == GType_FF || getGameType() == GType_PP) ? 9999 : 999;
	while (readUint16Wrapper(_vcPtr) != end)
		_vcPtr += 4;
	_vcPtr += 2;
}
Esempio n. 4
0
void AGOSEngine_Feeble::vc48_setPathFinder() {
	uint16 a = (uint16)_variableArrayPtr[12];
	const uint16 *p = _pathFindArray[a - 1];

	VgaSprite *vsp = findCurSprite();
	int16 x, y, ydiff;
	int16 x1, y1, x2, y2;
	uint pos = 0;

	x = vsp->x;
	while (x >= (int16)readUint16Wrapper(p + 2)) {
		p += 2;
		pos++;
	}

	x1 = readUint16Wrapper(p);
	y1 = readUint16Wrapper(p + 1);
	x2 = readUint16Wrapper(p + 2);
	y2 = readUint16Wrapper(p + 3);

	if (x2 != 9999) {
		ydiff = y2 - y1;
		if (ydiff < 0) {
			ydiff = -ydiff;
			x = vsp->x & 7;
			ydiff *= x;
			ydiff /= 8;
			ydiff = -ydiff;
		} else {
			x = vsp->x & 7;
			ydiff *= x;
			ydiff /= 8;
		}
		y1 += ydiff;
	}

	y = vsp->y;
	vsp->y = y1;
	checkScrollY(y1 - y, y1);

	_variableArrayPtr[11] = x1;
	_variableArrayPtr[13] = pos;
}
Esempio n. 5
0
void AGOSEngine::vc79_computePosNum() {
	uint a = (uint16)_variableArrayPtr[12];
	const uint16 *p = _pathFindArray[a - 1];
	uint pos = 0;

	int16 y = _variableArrayPtr[16];
	while (y >= (int16)readUint16Wrapper(p + 1)) {
		p += 2;
		pos++;
	}

	_variableArrayPtr[13] = pos;
}
Esempio n. 6
0
void AGOSEngine::vc78_computeXY() {
	VgaSprite *vsp = findCurSprite();

	uint16 a = (uint16)_variableArrayPtr[12];
	uint16 b = (uint16)_variableArrayPtr[13];

	const uint16 *p = _pathFindArray[a - 1];
	p += b * 2;

	uint16 posx = readUint16Wrapper(p);
	_variableArrayPtr[15] = posx;
	vsp->x = posx;

	uint16 posy = readUint16Wrapper(p + 1);
	_variableArrayPtr[16] = posy;
	vsp->y = posy;

	if (getGameType() == GType_FF) {
		setBitFlag(85, false);
		if (getBitFlag(74)) {
			centerScroll();
		}
	}
}
Esempio n. 7
0
void AGOSEngine::dumpVideoScript(const byte *src, bool singeOpcode) {
	uint16 opcode;
	const char *str, *strn;

	do {
		if (getGameType() == GType_SIMON2 || getGameType() == GType_FF || getGameType() == GType_PP) {
			opcode = *src++;
		} else {
			opcode = READ_BE_UINT16(src);
			src += 2;
		}

		if (opcode >= _numVideoOpcodes) {
			error("dumpVideoScript: Opcode %d out of range (%d)", opcode, _numVideoOpcodes);
		}

		if (getGameType() == GType_FF || getGameType() == GType_PP) {
			strn = str = feeblefiles_videoOpcodeNameTable[opcode];
		} else if (getGameType() == GType_SIMON2) {
			strn = str = simon2_videoOpcodeNameTable[opcode];
		} else if (getGameType() == GType_SIMON1) {
			strn = str = simon1_videoOpcodeNameTable[opcode];
		} else if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) {
			strn = str = ww_videoOpcodeNameTable[opcode];
		} else if (getGameType() == GType_ELVIRA1) {
			strn = str = elvira1_videoOpcodeNameTable[opcode];
		} else {
			strn = str = pn_videoOpcodeNameTable[opcode];
		}

		if (strn == NULL) {
			error("dumpVideoScript: Invalid Opcode %d", opcode);
		}

		while (*strn != '|')
			strn++;
		printf("%.2d: %s ", opcode, strn + 1);

		int end = (getGameType() == GType_FF || getGameType() == GType_PP) ? 9999 : 999;
		for (; *str != '|'; str++) {
			switch (*str) {
			case 'x':
				printf("\n");
				return;
			case 'b':
				printf("%d ", *src++);
				break;
			case 'd':
				printf("%d ", (int16)readUint16Wrapper(src));
				src += 2;
				break;
			case 'v':
				printf("[%d] ", readUint16Wrapper(src));
				src += 2;
				break;
			case 'i':
				printf("%d ", (int16)readUint16Wrapper(src));
				src += 2;
				break;
			case 'j':
				printf("-> ");
				break;
			case 'q':
				while (readUint16Wrapper(src) != end) {
					printf("(%d,%d) ", readUint16Wrapper(src),
									readUint16Wrapper(src + 2));
					src += 4;
				}
				src += 2;
				break;
			default:
				error("dumpVideoScript: Invalid fmt string '%c' in decompile VGA", *str);
			}
		}

		printf("\n");
	} while (!singeOpcode);
}