Exemple #1
0
LipSync *ResourceLoader::loadLipSync(const char *filename) {
	Common::String fname = filename;
	fname.toLowercase();
	LipSync *result;
	Block *b = getFileFromCache(fname.c_str());
	if (!b) {
		b = getFileBlock(fname.c_str());
		if (!b)
			return NULL;
	}

	result = new LipSync(filename, b->data(), b->len());

	// Some lipsync files have no data
	if (result->isValid()) {
		putIntoCache(fname, b);
		_lipsyncs.push_back(result);
	} else {
		delete result;
		delete b;
		result = NULL;
	}

	return result;
}
Exemple #2
0
void Inter_Geisha::oGeisha_checkData(OpFuncParams &params) {
	Common::String file = _vm->_game->_script->evalString();
	int16 varOff = _vm->_game->_script->readVarIndex();

	file.toLowercase();
	if (file.hasSuffix(".0ot"))
		file.setChar('t', file.size() - 3);

	bool exists = false;

	SaveLoad::SaveMode mode = _vm->_saveLoad->getSaveMode(file.c_str());
	if (mode == SaveLoad::kSaveModeNone) {

		exists = _vm->_dataIO->hasFile(file);
		if (!exists) {
			// NOTE: Geisha looks if fin.tot exists to check if it needs to open disk3.stk.
			//       This is completely normal, so don't print a warning.
			if (file != "fin.tot")
				warning("File \"%s\" not found", file.c_str());
		}

	} else if (mode == SaveLoad::kSaveModeSave)
		exists = _vm->_saveLoad->getSize(file.c_str()) >= 0;
	else if (mode == SaveLoad::kSaveModeExists)
		exists = true;

	WRITE_VAR_OFFSET(varOff, exists ? 50 : (uint32)-1);
}
Exemple #3
0
Video::VideoDecoder *ZVision::loadAnimation(const Common::String &fileName) {
	Common::String tmpFileName = fileName;
	tmpFileName.toLowercase();
	Video::VideoDecoder *animation = NULL;

	if (tmpFileName.hasSuffix(".rlf"))
		animation = new RLFDecoder();
	else if (tmpFileName.hasSuffix(".avi"))
		animation = new ZorkAVIDecoder();
#ifdef USE_MPEG2
	else if (tmpFileName.hasSuffix(".vob"))
		animation = new Video::MPEGPSDecoder();
#endif
	else
		error("Unknown suffix for animation %s", fileName.c_str());

	Common::File *_file = getSearchManager()->openFile(tmpFileName);
	if (!_file)
		error("Error opening %s", tmpFileName.c_str());

	bool loaded = animation->loadStream(_file);
	if (!loaded)
		error("Error loading animation %s", tmpFileName.c_str());

	return animation;
}
Exemple #4
0
void Sword1CheckDirectory(const Common::FSList &fslist, bool *filesFound, bool recursion = false) {
	for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
		if (!file->isDirectory()) {
			// The required game data files can be located in the game directory, or in
			// a subdirectory called "clusters". In the latter case, we don't want to
			// detect the game in that subdirectory, as this will detect the game twice
			// when mass add is searching inside a directory. In this case, the first
			// result (the game directory) will be correct, but the second result (the
			// clusters subdirectory) will be wrong, as the optional speech, music and
			// video data files will be ignored. Note that this fix will skip the game
			// data files if the user has placed them inside a "clusters" subdirectory,
			// or if he/she points ScummVM directly to the "clusters" directory of the
			// game CD. Fixes bug #3049346.
			Common::String directory = file->getParent().getName();
			directory.toLowercase();
			if (directory.hasPrefix("clusters") && directory.size() <= 9 && !recursion)
				continue;

			const char *fileName = file->getName().c_str();
			for (int cnt = 0; cnt < NUM_FILES_TO_CHECK; cnt++)
				if (scumm_stricmp(fileName, g_filesToCheck[cnt]) == 0)
					filesFound[cnt] = true;
		} else {
			for (int cnt = 0; cnt < ARRAYSIZE(g_dirNames); cnt++)
				if (scumm_stricmp(file->getName().c_str(), g_dirNames[cnt]) == 0) {
					Common::FSList fslist2;
					if (file->getChildren(fslist2, Common::FSNode::kListFilesOnly))
						Sword1CheckDirectory(fslist2, filesFound, true);
				}
		}
	}
}
Exemple #5
0
Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) {
	Common::File *file = new Common::File();
	assert(file->open(filePath));

	Common::String fileName = getFileName(filePath);
	fileName.toLowercase();

	SoundParams soundParams;

	if (engine->getGameId() == GID_NEMESIS) {
		for (int i = 0; i < 6; ++i) {
			if (RawZorkStream::_zNemSoundParamLookupTable[i].identifier == (fileName[6]))
				soundParams = RawZorkStream::_zNemSoundParamLookupTable[i];
		}
	}
	else if (engine->getGameId() == GID_GRANDINQUISITOR) {
		for (int i = 0; i < 6; ++i) {
			if (RawZorkStream::_zgiSoundParamLookupTable[i].identifier == (fileName[7]))
				soundParams = RawZorkStream::_zgiSoundParamLookupTable[i];
		}
	}
	
	if (soundParams.packed) {
		return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams.rate, soundParams.stereo, DisposeAfterUse::YES);
	} else {
		byte flags = 0;
		if (soundParams.stereo)
			flags |= Audio::FLAG_STEREO;

		return Audio::makeRawStream(file, soundParams.rate, flags, DisposeAfterUse::YES);
	}
}
Exemple #6
0
Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) {
	Common::File *file = new Common::File();
	Common::String actualName = filePath;
	bool found = engine->getSearchManager()->openFile(*file, actualName);
	bool isRaw = actualName.hasSuffix(".raw");

	if ((!found && isRaw) || (found && isRaw && file->size() < 10)) {
		if (found)
			file->close();

		// Check for an audio patch (.src)
		actualName.setChar('s', actualName.size() - 3);
		actualName.setChar('r', actualName.size() - 2);
		actualName.setChar('c', actualName.size() - 1);

		if (!engine->getSearchManager()->openFile(*file, actualName))
			return NULL;
	} else if (!found && !isRaw) {
		return NULL;
	}

	// Get the file name
	Common::StringTokenizer tokenizer(actualName, "/\\");
	Common::String fileName;
	while (!tokenizer.empty()) {
		fileName = tokenizer.nextToken();
	}

	fileName.toLowercase();

	const SoundParams *soundParams = NULL;

	if (engine->getGameId() == GID_NEMESIS) {
		for (int i = 0; i < 32; ++i) {
			if (RawZorkStream::_zNemSoundParamLookupTable[i].identifier == (fileName[6]))
				soundParams = &RawZorkStream::_zNemSoundParamLookupTable[i];
		}
	} else if (engine->getGameId() == GID_GRANDINQUISITOR) {
		for (int i = 0; i < 24; ++i) {
			if (RawZorkStream::_zgiSoundParamLookupTable[i].identifier == (fileName[7]))
				soundParams = &RawZorkStream::_zgiSoundParamLookupTable[i];
		}
	}

	if (soundParams == NULL)
		return NULL;

	if (soundParams->packed) {
		return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams->rate, soundParams->stereo, DisposeAfterUse::YES);
	} else {
		byte flags = 0;
		if (soundParams->bits16)
			flags |= Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN;
		if (soundParams->stereo)
			flags |= Audio::FLAG_STEREO;

		return Audio::makePCMStream(file, soundParams->rate, flags, DisposeAfterUse::YES);
	}
}
Exemple #7
0
OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
	_audio_sample_rate(audio_sample_rate),
	_audio_buffer_size(audio_buffer_size),
	_screen_changeid(0),
	_egl_surface_width(0),
	_egl_surface_height(0),
	_htc_fail(true),
	_force_redraw(false),
	_game_texture(0),
	_overlay_texture(0),
	_mouse_texture(0),
	_mouse_texture_palette(0),
	_mouse_texture_rgb(0),
	_mouse_hotspot(),
	_mouse_keycolor(0),
	_use_mouse_palette(false),
	_graphicsMode(0),
	_fullscreen(true),
	_ar_correction(true),
	_show_mouse(false),
	_show_overlay(false),
	_enable_zoning(false),
	_mixer(0),
	_shake_offset(0),
	_queuedEventTime(0),
	_event_queue_lock(createMutex()),
	_touch_pt_down(),
	_touch_pt_scroll(),
	_touch_pt_dt(),
	_eventScaleX(100),
	_eventScaleY(100),
	// TODO put these values in some option dlg?
	_touchpad_mode(true),
	_touchpad_scale(66),
	_dpad_scale(4),
	_fingersDown(0),
	_trackball_scale(2),
	_joystick_scale(10) {

	_fsFactory = new POSIXFilesystemFactory();

	Common::String mf = getSystemProperty("ro.product.manufacturer");

	LOGI("Running on: [%s] [%s] [%s] [%s] [%s] SDK:%s ABI:%s",
			mf.c_str(),
			getSystemProperty("ro.product.model").c_str(),
			getSystemProperty("ro.product.brand").c_str(),
			getSystemProperty("ro.build.fingerprint").c_str(),
			getSystemProperty("ro.build.display.id").c_str(),
			getSystemProperty("ro.build.version.sdk").c_str(),
			getSystemProperty("ro.product.cpu.abi").c_str());

	mf.toLowercase();
	/*_htc_fail = mf.contains("htc");

	if (_htc_fail)
		LOGI("Enabling HTC workaround");*/
}
Exemple #8
0
bool SoundEngine::canLoadResource(const Common::String &fileName) {
	Common::String fname = fileName;

	debugC(1, kDebugSound, "SoundEngine::canLoadResource(%s)", fileName.c_str());

	fname.toLowercase();

	return fname.hasSuffix(".ogg");
}
Exemple #9
0
bool AnimationResource::parseBooleanKey(Common::String s, bool &result) {
    s.toLowercase();
    if (!strcmp(s.c_str(), "true"))
        result = true;
    else if (!strcmp(s.c_str(), "false"))
        result = false;
    else
        return false;
    return true;
}
Exemple #10
0
const Font *FontManager::getFontByName(const Common::String &name) const {
	for (int i = 0; builtinFontNames[i].name; i++)
		if (!scumm_stricmp(name.c_str(), builtinFontNames[i].name))
			return getFontByUsage(builtinFontNames[i].id);

	Common::String lowercaseName = name;
	lowercaseName.toLowercase();
	if (!_fontMap.contains(lowercaseName))
		return 0;
	return _fontMap[lowercaseName];
}
Exemple #11
0
AnimationEmiPtr ResourceLoader::getAnimationEmi(const Common::String &fname) {
	Common::String filename = fname;
	filename.toLowercase();
	for (Common::List<AnimationEmi *>::const_iterator i = _emiAnims.begin(); i != _emiAnims.end(); ++i) {
		AnimationEmi *a = *i;
		if (filename == a->getFilename()) {
			return a;
		}
	}

	return loadAnimationEmi(fname);
}
Exemple #12
0
LipSyncPtr ResourceLoader::getLipSync(const Common::String &fname) {
	Common::String filename = fname;
	filename.toLowercase();
	for (Common::List<LipSync *>::const_iterator i = _lipsyncs.begin(); i != _lipsyncs.end(); ++i) {
		LipSync *l = *i;
		if (filename == l->getFilename()) {
			return l;
		}
	}

	return loadLipSync(fname);
}
Exemple #13
0
CMapPtr ResourceLoader::getColormap(const Common::String &fname) {
	Common::String filename = fname;
	filename.toLowercase();
	for (Common::List<CMap *>::const_iterator i = _colormaps.begin(); i != _colormaps.end(); ++i) {
		CMap *c = *i;
		if (filename.equals(c->_fname)) {
			return c;
		}
	}

	return loadColormap(fname);
}
Exemple #14
0
KeyframeAnimPtr ResourceLoader::getKeyframe(const Common::String &fname) {
	Common::String filename = fname;
	filename.toLowercase();
	for (Common::List<KeyframeAnim *>::const_iterator i = _keyframeAnims.begin(); i != _keyframeAnims.end(); ++i) {
		KeyframeAnim *k = *i;
		if (filename == k->getFilename()) {
			return k;
		}
	}

	return loadKeyframe(fname);
}
Exemple #15
0
ModelPtr ResourceLoader::getModel(const Common::String &fname, CMap *c) {
	Common::String filename = fname;
	filename.toLowercase();
	for (Common::List<Model *>::const_iterator i = _models.begin(); i != _models.end(); ++i) {
		Model *m = *i;
		if (filename == m->_fname && *m->_cmap == *c) {
			return m;
		}
	}

	return loadModel(fname, c);
}
Exemple #16
0
CachedArchive::CachedArchive(const FileInputList &files)
	: _files() {
	for (FileInputList::const_iterator i = files.begin(); i != files.end(); ++i) {
		Entry entry;

		entry.data = i->data;
		entry.size = i->size;

		Common::String name = i->name;
		name.toLowercase();
		_files[name] = entry;
	}
}
Exemple #17
0
Block *ResourceLoader::getBlock(const char *filename) {
    Common::String fname = filename;
    fname.toLowercase();
    Block *b = getFileFromCache(fname.c_str());
    if (!b) {
        b = getFileBlock(fname.c_str());
		if (b) {
			putIntoCache(fname, b);
		}
    }

    return b;
}
Exemple #18
0
Costume *ResourceLoader::loadCostume(const char *filename, Costume *prevCost) {
	Common::String fname = filename;
	fname.toLowercase();
	Block *b = getFileFromCache(fname.c_str());
	if (!b) {
		b = getFileBlock(fname.c_str());
		if (!b)
			error("Could not find costume \"%s\"", filename);
		putIntoCache(fname, b);
	}
	Costume *result = new Costume(filename, b->data(), b->len(), prevCost);

	return result;
}
Exemple #19
0
Material *ResourceLoader::loadMaterial(const Common::String &filename, CMap *c) {
	Common::String fname = fixFilename(filename, false);
	fname.toLowercase();
	Common::SeekableReadStream *stream;

	stream = openNewStreamFile(fname.c_str(), true);
	if(!stream)
		error("Could not find material %s", filename.c_str());

	Material *result = new Material(fname, stream, c);
	delete stream;

	return result;
}
Exemple #20
0
KeyframeAnim *ResourceLoader::loadKeyframe(const char *filename) {
	Common::String fname = filename;
	fname.toLowercase();
	Block *b = getFileFromCache(fname.c_str());
	if (!b) {
		b = getFileBlock(fname.c_str());
		if (!b)
			error("Could not find keyframe file %s", filename);
		putIntoCache(fname, b);
	}

	KeyframeAnim *result = new KeyframeAnim(filename, b->data(), b->len());
	_keyframeAnims.push_back(result);

	return result;
}
Exemple #21
0
Model *ResourceLoader::loadModel(const char *filename, CMap *c) {
	Common::String fname = filename;
	fname.toLowercase();
	Block *b = getFileFromCache(fname.c_str());
	if (!b) {
		b = getFileBlock(fname.c_str());
		if (!b)
			error("Could not find model %s", filename);
		putIntoCache(fname, b);
	}

	Model *result = new Model(filename, b->data(), b->len(), c);
	_models.push_back(result);

	return result;
}
Exemple #22
0
Font *ResourceLoader::loadFont(const char *filename) {
	Common::String fname = filename;
	fname.toLowercase();
	Block *b = getFileFromCache(fname.c_str());
	if (!b) {
		b = getFileBlock(fname.c_str());
		if (!b)
			error("Could not find font file %s", filename);
		putIntoCache(fname, b);
	}

	Font *result = new Font(filename, b->data(), b->len());
	_fonts.push_back(result);

	return result;
}
Exemple #23
0
PCSpeakerDevice *PCSpeakerFactoryManager::createDevice() {
	Common::String deviceName = ConfMan.get("pcspk_dev");
	deviceName.toLowercase();

	// Default to emulated
	if (deviceName.empty() || deviceName == "auto")
		deviceName = "emu";

	FactoryMap::iterator it = _factories.find(deviceName);
	if (it == _factories.end()) {
		// Default to the emulated version
		warning("'%s' is not a valid PC speaker device; defaulting to emulated", deviceName.c_str());
		return createEmulatedPCSpeaker();
	}

	return it->_value.factory();
}
Exemple #24
0
CMap *ResourceLoader::loadColormap(const char *filename) {
	Common::String fname = filename;
	fname.toLowercase();
	Block *b = getFileFromCache(fname.c_str());
	if (!b) {
		b = getFileBlock(fname.c_str());
		if (!b) {
			error("Could not find colormap %s", filename);
        }
		putIntoCache(fname, b);
	}

	CMap *result = new CMap(filename, b->data(), b->len());
	_colormaps.push_back(result);

	return result;
}
Exemple #25
0
bool CCArchive::getHeaderEntry(const Common::String &resourceName, CCEntry &ccEntry) const {
	Common::String resName = resourceName;

	if (!_prefix.empty() && resName.contains('|')) {
		resName.toLowercase();
		Common::String prefix = _prefix + "|";

		if (!strncmp(resName.c_str(), prefix.c_str(), prefix.size()))
			// Matching CC prefix, so strip it off and allow processing to
			// continue onto the base getHeaderEntry method
			resName = Common::String(resName.c_str() + prefix.size());
		else
			// Not matching prefix, so don't allow a match
			return false;
	}

	return BaseCCArchive::getHeaderEntry(resName, ccEntry);
}
Exemple #26
0
Bitmap *ResourceLoader::loadBitmap(const char *filename) {
	Common::String fname = filename;
	fname.toLowercase();
	Block *b = getFileFromCache(fname.c_str());
	if (!b) {
		b = getFileBlock(fname.c_str());
		if (!b) {	// Grim sometimes asks for non-existant bitmaps (eg, ha_overhead)
			warning("Could not find bitmap %s", filename);
			return NULL;
		}
		putIntoCache(fname, b);
	}

	Bitmap *result = g_grim->registerBitmap(filename, b->data(), b->len());
	_bitmaps.push_back(result);

	return result;
}
Exemple #27
0
Costume *ResourceLoader::loadCostume(const Common::String &filename, Costume *prevCost) {
	Common::String fname = fixFilename(filename);
	fname.toLowercase();

	Common::SeekableReadStream *stream = openNewStreamFile(fname.c_str(), true);
	if (!stream) {
		error("Could not find costume \"%s\"", filename.c_str());
	}
	Costume *result;
	if (g_grim->getGameType() == GType_MONKEY4) {
		result = new EMICostume(filename, prevCost);		
	} else {
		result = new Costume(filename, prevCost);
	}
	result->load(stream);
	delete stream;
	
	return result;
}
Exemple #28
0
void ResourceLoader::uncache(const char *filename) {
	Common::String fname = filename;
	fname.toLowercase();

	if (_cacheDirty) {
		qsort(_cache.begin(), _cache.size(), sizeof(ResourceCache), sortCallback);
		_cacheDirty = false;
	}

	for (unsigned int i = 0; i < _cache.size(); i++) {
		if (fname.compareTo(_cache[i].fname) == 0) {
			delete[] _cache[i].fname;
			_cacheMemorySize -= _cache[i].len;
			delete[] _cache[i].resPtr;
			_cache.remove_at(i);
			_cacheDirty = true;
		}
	}
}
Exemple #29
0
Material *ResourceLoader::loadMaterial(const Common::String &filename, CMap *c) {
    Common::String fname = fixFilename(filename, false);
    fname.toLowercase();
    Common::SeekableReadStream *stream;

    stream = openNewStreamFile(fname.c_str(), true);
    if (!stream) {
        // FIXME: EMI demo references files that aren't included. Return a known material.
        // This should be fixed in the data files instead.
        if (g_grim->getGameType() == GType_MONKEY4 && g_grim->getGameFlags() & ADGF_DEMO) {
            const Common::String replacement("fx/candle.sprb");
            warning("Could not find material %s, using %s instead", filename.c_str(), replacement.c_str());
            return loadMaterial(replacement, NULL);
        }
    }

    Material *result = new Material(fname, stream, c);
    delete stream;

    return result;
}
Exemple #30
0
Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) {
	Common::File *file = new Common::File();
	assert(file->open(filePath));

	Common::String fileName = getFileName(filePath);
	fileName.toLowercase();

	SoundParams soundParams = { ' ', 0, false, false };
	bool foundParams = false;
	char fileIdentifier = (engine->getGameId() == GID_NEMESIS) ? fileName[6] : fileName[7];

	if (engine->getGameId() == GID_NEMESIS) {
		for (uint i = 0; i < ARRAYSIZE(RawZorkStream::_zNemSoundParamLookupTable); ++i) {
			if (RawZorkStream::_zNemSoundParamLookupTable[i].identifier == fileIdentifier) {
				soundParams = RawZorkStream::_zNemSoundParamLookupTable[i];
				foundParams = true;
			}
		}
	} else if (engine->getGameId() == GID_GRANDINQUISITOR) {
		for (uint i = 0; i < ARRAYSIZE(RawZorkStream::_zgiSoundParamLookupTable); ++i) {
			if (RawZorkStream::_zgiSoundParamLookupTable[i].identifier == fileIdentifier) {
				soundParams = RawZorkStream::_zgiSoundParamLookupTable[i];
				foundParams = true;
			}
		}
	}

	if (!foundParams)
		error("Unable to find sound params for file '%s'. File identifier is '%c'", filePath.c_str(), fileIdentifier);

	if (soundParams.packed) {
		return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams.rate, soundParams.stereo, DisposeAfterUse::YES);
	} else {
		byte flags = 0;
		if (soundParams.stereo)
			flags |= Audio::FLAG_STEREO;

		return Audio::makeRawStream(file, soundParams.rate, flags, DisposeAfterUse::YES);
	}
}