Example #1
0
bool Resources::loadArchives(const ADGameDescription *gd) {
	Common::File *dat_file = new Common::File();
	Common::String filename = "teenagent.dat";
	if (!dat_file->open(filename.c_str())) {
		delete dat_file;
		Common::String errorMessage = Common::String::format(_("Unable to locate the '%s' engine data file."), filename.c_str());
		warning("%s", errorMessage.c_str());
		GUIErrorMessage(errorMessage);
		return false;
	}

	// teenagent.dat used to be compressed with zlib compression. The usage of
	// zlib here is no longer needed, and it's maintained only for backwards
	// compatibility.
	Common::SeekableReadStream *dat = Common::wrapCompressedReadStream(dat_file);

#if !defined(USE_ZLIB)
	uint16 header = dat->readUint16BE();
	bool isCompressed = (header == 0x1F8B ||
				     ((header & 0x0F00) == 0x0800 &&
				      header % 31 == 0));
	dat->seek(-2, SEEK_CUR);

	if (isCompressed) {
		// teenagent.dat is compressed, but zlib hasn't been compiled in
		delete dat;
		Common::String errorMessage = _("The teenagent.dat file is compressed and zlib hasn't been included in this executable. Please decompress it");
		warning("%s", errorMessage.c_str());
		GUIErrorMessage(errorMessage);
		return false;
	}
#endif

	dat->skip(CSEG_SIZE);
	dseg.read(dat, DSEG_SIZE);
	eseg.read(dat, ESEG_SIZE);
	delete dat;

	precomputeDialogOffsets();

	FilePack varia;
	varia.open("varia.res");
	font7.load(varia, 7, 11, 1);
	font8.load(varia, 8, 31, 0);
	varia.close();

	off.open("off.res");
	on.open("on.res");
	ons.open("ons.res");
	lan000.open("lan_000.res");
	lan500.open("lan_500.res");
	mmm.open("mmm.res");
	sam_mmm.open("sam_mmm.res");
	sam_sam.open("sam_sam.res");
	voices.open("voices.res");

	return true;
}
Example #2
0
bool TeenAgentEngine::showLogo() {
	FilePack logo;
	if (!logo.open("unlogic.res"))
		return true;

	byte bg[0xfa00];
	byte palette[0x400];

	Common::ScopedPtr<Common::SeekableReadStream> frame(logo.getStream(1));
	if (!frame)
		return true;

	frame->read(bg, sizeof(bg));
	memset(palette, 0, sizeof(palette));

	for(uint c = 0; c < 0x100; ++c) {
		uint idx = c * 4;
		frame->read(palette + idx, 3);
		palette[idx] *= 4;
		palette[idx + 1] *= 4;
		palette[idx + 2] *= 4;
	}
	_system->setPalette(palette, 0, 0x100);

	uint n = logo.fileCount();
	for(uint f = 0; f < 4; ++f)
		for(uint i = 2; i <= n; ++i) {
			{
				int r = skipEvents();
				if (r != 0)
					return r > 0? true: false;
			}
			_system->copyRectToScreen(bg, 320, 0, 0, 320, 200);

			frame.reset(logo.getStream(i));
			if (!frame)
				return true;

			Surface s;
			s.load(frame, Surface::kTypeOns);
			if (s.empty())
				return true;

			_system->copyRectToScreen((const byte *)s.pixels, s.w, s.x, s.y, s.w, s.h);
			_system->updateScreen();

			_system->delayMillis(100);
		}
	return true;
}
Example #3
0
Inventory::Inventory(TeenAgentEngine *engine) {
	_engine = engine;
	_active = false;

	FilePack varia;
	varia.open("varia.res");

	{
		Common::ScopedPtr<Common::SeekableReadStream> s(varia.getStream(3));
		if (!s)
			error("no inventory background");
		debug(0, "loading inventory background...");
		_background.load(*s, Surface::kTypeOns);
	}

	uint32 items_size = varia.getSize(4);
	if (items_size == 0)
		error("invalid inventory items size");
	debug(0, "loading items, size: %u", items_size);
	_items = new byte[items_size];
	varia.read(4, _items, items_size);

	byte offsets = _items[0];
	assert(offsets == 92);
	for (byte i = 0; i < offsets; ++i) {
		_offset[i] = READ_LE_UINT16(_items + i * 2 + 1);
	}
	_offset[92] = items_size;

	Resources *res = Resources::instance();
	for (byte i = 0; i <= 92; ++i) {
		InventoryObject io;
		uint16 obj_addr = res->dseg.get_word(0xc4a4 + i * 2);
		if (obj_addr != 0)
			io.load(res->dseg.ptr(obj_addr));
		_objects.push_back(io);
	}

	_inventory = res->dseg.ptr(0xc48d);

	for (int y = 0; y < 4; ++y)
		for (int x = 0; x < 6; ++x) {
			int i = y * 6 + x;
			_graphics[i]._rect.left = 28 + 45 * x - 1;
			_graphics[i]._rect.top = 23 + 31 * y - 1;
			_graphics[i]._rect.right = _graphics[i]._rect.left + 40;
			_graphics[i]._rect.bottom = _graphics[i]._rect.top + 26;
		}

	varia.close();
	_hoveredObj = _selectedObj = NULL;
}
Example #4
0
bool TeenAgentEngine::showMetropolis() {
	_system->fillScreen(0);
	_system->updateScreen();

	FilePack varia;
	varia.open("varia.res");

	byte palette[0x400];
	memset(palette, 0, sizeof(palette));
	{
		Common::ScopedPtr<Common::SeekableReadStream> s(varia.getStream(5));
		for(uint c = 0; c < 0x400; c += 4) {
			s->read(palette + c, 3);
			palette[c] *= 4;
			palette[c + 1] *= 4;
			palette[c + 2] *= 4;
		}
	}

	_system->setPalette(palette, 0, 0x100);

	byte varia_6[21760], varia_9[18302];
	varia.read(6, varia_6, sizeof(varia_6));
	varia.read(9, varia_9, sizeof(varia_9));

	byte colors[56 * 160 * 2];
	memset(colors, 0, sizeof(colors));

	int logo_y = -56;
	for(uint f = 0; f < 300; ++f) {
		{
			int r = skipEvents();
			if (r != 0)
				return r > 0? true: false;
		}

		Graphics::Surface *surface = _system->lockScreen();
		if (logo_y > 0) {
			surface->fillRect(Common::Rect(0, 0, 320, logo_y), 0);
		}

		{
			//generate colors matrix
			memmove(colors + 320, colors + 480, 8480);
			for(uint c = 0; c < 17; ++c) {
				byte x = (random.getRandomNumber(184) + 5) & 0xff;
				uint offset = 8800 + random.getRandomNumber(158);
				colors[offset++] = x;
				colors[offset++] = x;
			}
			for(uint y = 1; y < 56; ++y) {
				for(uint x = 1; x < 160; ++x) {
					uint offset = y * 160 + x;
					uint v =
						(uint)colors[offset - 161] + colors[offset - 160] + colors[offset - 159] +
						(uint)colors[offset - 1] + colors[offset + 1] +
						(uint)colors[offset + 161] + colors[offset + 160] + colors[offset + 159];
					v >>= 3;
					colors[offset + 8960] = v;
				}
			}
			memmove(colors, colors + 8960, 8960);
		}

		byte *dst = (byte *)surface->getBasePtr(0, 131);
		byte *src = varia_6;
		for(uint y = 0; y < 68; ++y) {
			for(uint x = 0; x < 320; ++x) {
				if (*src++ == 1) {
					*dst++ = colors[19 * 160 + y / 2 * 160 + x / 2];
				} else
					++dst;
			}
		}
		_system->unlockScreen();

		_system->copyRectToScreen(
			varia_9 + (logo_y < 0? -logo_y * 320: 0), 320,
			0, logo_y >= 0? logo_y: 0,
			320, logo_y >= 0? 57: 57 + logo_y);

		if (logo_y < 82 - 57)
			++logo_y;


		_system->updateScreen();
		_system->delayMillis(100);
	}
	return true;
}