void Sound::loadSfxFile(const GameSpecificSettings *gss) { char filename[16]; Common::File *file = new Common::File(); if (!_hasEffectsFile) { _effects = makeCompressedSound(_mixer, file, gss->effects_filename); _hasEffectsFile = (_effects != 0); } const bool dataIsUnsigned = true; if (!_hasEffectsFile) { sprintf(filename, "%s.voc", gss->effects_filename); file->open(filename); if (file->isOpen()) { _hasEffectsFile = true; _effects = new VocSound(_mixer, file, dataIsUnsigned); } } if (!_hasEffectsFile) { sprintf(filename, "%s", gss->effects_filename); file->open(filename); if (file->isOpen()) { _hasEffectsFile = true; _effects = new VocSound(_mixer, file, dataIsUnsigned); } } }
void Sound::loadVoiceFile(const GameSpecificSettings *gss) { // Game versions which use separate voice files if (_vm->getGameType() == GType_FF || _vm->getGameId() == GID_SIMON1CD32) return; char filename[16]; Common::File *file = new Common::File(); if (!_hasVoiceFile) { _voice = makeCompressedSound(_mixer, file, gss->speech_filename); _hasVoiceFile = (_voice != 0); } if (!_hasVoiceFile && _vm->getGameType() == GType_SIMON2) { // for simon2 mac/amiga, only read index file file->open("voices.idx"); if (file->isOpen() == true) { int end = file->size(); _filenums = (uint16 *)malloc((end / 6 + 1) * 2); _offsets = (uint32 *)malloc((end / 6 + 1) * 4); for (int i = 1; i <= end / 6; i++) { _filenums[i] = file->readUint16BE(); _offsets[i] = file->readUint32BE(); } _hasVoiceFile = true; } } if (!_hasVoiceFile) { sprintf(filename, "%s.wav", gss->speech_filename); file->open(filename); if (file->isOpen()) { _hasVoiceFile = true; _voice = new WavSound(_mixer, file); } } const bool dataIsUnsigned = true; if (!_hasVoiceFile) { sprintf(filename, "%s.voc", gss->speech_filename); file->open(filename); if (file->isOpen()) { _hasVoiceFile = true; _voice = new VocSound(_mixer, file, dataIsUnsigned); } } if (!_hasVoiceFile) { sprintf(filename, "%s", gss->speech_filename); file->open(filename); if (file->isOpen()) { _hasVoiceFile = true; if (_vm->getGameType() == GType_PP) _voice = new WavSound(_mixer, file); else _voice = new VocSound(_mixer, file, dataIsUnsigned); } } }
Localizer::Localizer() { Common::File f; const char *namesToTry[] = { "GRIM.TAB", "Grim.tab", "grim.tab" }; if (g_grim->getGameFlags() & GF_DEMO) return; for (unsigned i = 0; i < sizeof(namesToTry) / sizeof(namesToTry[0]); i++) { f.open(namesToTry[i]); if (f.isOpen()) break; } if (!f.isOpen()) { error("Localizer::Localizer: Unable to find localization information (grim.tab)"); return; } long filesize = f.size(); // Read in the data char *data = new char[filesize + 1]; f.read(data, filesize); data[filesize] = '\0'; f.close(); if (filesize < 4 || READ_BE_UINT32(data) != MKID_BE('RCNE')) error("Invalid magic reading grim.tab"); // Decode the data for (int i = 4; i < filesize; i++) data[i] ^= '\xdd'; char *nextline; for (char *line = data + 4; line != NULL && *line != '\0'; line = nextline) { nextline = strchr(line, '\n'); if (nextline) { if (nextline[-1] == '\r') nextline[-1] = '\0'; nextline++; } char *tab = strchr(line, '\t'); if (!tab) continue; LocaleEntry entry; entry.text = new char[(tab - line) + 1]; strncpy(entry.text, line, tab - line); entry.text[tab - line] = '\0'; entry.translation = new char[strlen(tab + 1) + 1]; strcpy(entry.translation, tab + 1); _entries.push_back(entry); } qsort(_entries.begin(), _entries.size(), sizeof(LocaleEntry), sortCallback); delete[] data; }
void SndRes::setVoiceBank(int serial) { Common::File *file; if (_voiceSerial == serial) return; #ifdef ENABLE_IHNM // If we got the Macintosh version of IHNM, just set the voice bank // so that we know which voices* subfolder to look for later if (_vm->getGameId() == GID_IHNM && _vm->isMacResources()) { _voiceSerial = serial; // Set a dummy voice context _voiceContext = new VoiceResourceContext_RES(); return; } #endif // If there are no voice files present, don't set the voice bank if (!_vm->_voiceFilesExist) return; // Close previous voice bank file if (_voiceContext != NULL) { file = _voiceContext->getFile(NULL); if (file->isOpen()) { file->close(); } } _voiceSerial = serial; _voiceContext = _vm->_resource->getContext(GAME_VOICEFILE, _voiceSerial); }
void Sound::playVoice(uint sound) { if (_filenums) { if (_lastVoiceFile != _filenums[sound]) { _mixer->stopHandle(_voiceHandle); char filename[16]; _lastVoiceFile = _filenums[sound]; sprintf(filename, "voices%d.dat", _filenums[sound]); Common::File *file = new Common::File(); file->open(filename); if (file->isOpen() == false) error("playVoice: Can't load voice file %s", filename); delete _voice; _voice = new WavSound(_mixer, file, _offsets); } } if (!_voice) return; _mixer->stopHandle(_voiceHandle); if (_vm->getGameType() == GType_PP) { if (sound < 11) _voice->playSound(sound, sound + 1, Audio::Mixer::kMusicSoundType, &_voiceHandle, true, -1500); else _voice->playSound(sound, sound, Audio::Mixer::kMusicSoundType, &_voiceHandle, true); } else if (_vm->getGameType() == GType_FF || _vm->getGameId() == GID_SIMON1CD32) { _voice->playSound(sound, Audio::Mixer::kSpeechSoundType, &_voiceHandle, false); } else { _voice->playSound(sound, Audio::Mixer::kSpeechSoundType, &_voiceHandle, false); } }
void MoviePlayerDXA::readSoundData(Common::SeekableReadStream *stream) { uint32 tag = stream->readUint32BE(); if (tag == MKTAG('W','A','V','E')) { uint32 size = stream->readUint32BE(); if (_sequenceNum) { Common::File in; stream->skip(size); in.open("audio.wav"); if (!in.isOpen()) { error("Can't read offset file 'audio.wav'"); } in.seek(_sequenceNum * 8, SEEK_SET); uint32 offset = in.readUint32LE(); size = in.readUint32LE(); in.seek(offset, SEEK_SET); _bgSoundStream = Audio::makeWAVStream(in.readStream(size), DisposeAfterUse::YES); in.close(); } else { _bgSoundStream = Audio::makeWAVStream(stream->readStream(size), DisposeAfterUse::YES); } } else { _bgSoundStream = Audio::SeekableAudioStream::openStreamFile(baseName); } }
void Sound::switchVoiceFile(const GameSpecificSettings *gss, uint disc) { if (_lastVoiceFile == disc) return; _mixer->stopHandle(_voiceHandle); delete _voice; _hasVoiceFile = false; _lastVoiceFile = disc; char filename[16]; Common::File *file = new Common::File(); if (!_hasVoiceFile) { sprintf(filename, "%s%d", gss->speech_filename, disc); _voice = makeCompressedSound(_mixer, file, filename); _hasVoiceFile = (_voice != 0); } if (!_hasVoiceFile) { sprintf(filename, "%s%d.wav", gss->speech_filename, disc); file->open(filename); if (file->isOpen() == false) { error("switchVoiceFile: Can't load voice file %s", filename); } _hasVoiceFile = true; _voice = new WavSound(_mixer, file); } }
void MoviePlayerDXA::startSound() { uint32 offset, size; if (getSoundTag() == MKID_BE('WAVE')) { size = _fileStream->readUint32BE(); if (_sequenceNum) { Common::File in; _fileStream->seek(size, SEEK_CUR); in.open((const char *)"audio.wav"); if (!in.isOpen()) { error("Can't read offset file 'audio.wav'"); } in.seek(_sequenceNum * 8, SEEK_SET); offset = in.readUint32LE(); size = in.readUint32LE(); in.seek(offset, SEEK_SET); _bgSoundStream = Audio::makeWAVStream(in.readStream(size), DisposeAfterUse::YES); in.close(); } else { _bgSoundStream = Audio::makeWAVStream(_fileStream->readStream(size), DisposeAfterUse::YES); } } else { _bgSoundStream = Audio::SeekableAudioStream::openStreamFile(baseName); } if (_bgSoundStream != NULL) { _vm->_mixer->stopHandle(_bgSound); _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_bgSound, _bgSoundStream); } }
void AGOSEngine::decompressData(const char *srcName, byte *dst, uint32 offset, uint32 srcSize, uint32 dstSize) { #ifdef USE_ZLIB Common::File in; in.open(srcName); if (in.isOpen() == false) error("decompressData: Can't load %s", srcName); in.seek(offset, SEEK_SET); if (srcSize != dstSize) { byte *srcBuffer = (byte *)malloc(srcSize); if (in.read(srcBuffer, srcSize) != srcSize) error("decompressData: Read failed"); unsigned long decompressedSize = dstSize; if (!Common::uncompress(dst, &decompressedSize, srcBuffer, srcSize)) error("decompressData: Zlib uncompress error"); free(srcBuffer); } else { if (in.read(dst, dstSize) != dstSize) error("decompressData: Read failed"); } in.close(); #else error("Zlib support is required for Amiga and Macintosh versions"); #endif }
bool ThemeEngine::themeConfigUsable(const Common::FSNode &node, Common::String &themeName) { Common::File stream; bool foundHeader = false; if (node.getName().matchString("*.zip", true) && !node.isDirectory()) { Common::Archive *zipArchive = Common::makeZipArchive(node); if (zipArchive && zipArchive->hasFile("THEMERC")) { // Open THEMERC from the ZIP file. stream.open("THEMERC", *zipArchive); } // Delete the ZIP archive again. Note: This only works because // stream.open() only uses ZipArchive::createReadStreamForMember, // and that in turn happens to read all the data for a given // archive member into a memory block. So there will be no dangling // reference to zipArchive anywhere. This could change if we // ever modify ZipArchive::createReadStreamForMember. delete zipArchive; } else if (node.isDirectory()) { Common::FSNode headerfile = node.getChild("THEMERC"); if (!headerfile.exists() || !headerfile.isReadable() || headerfile.isDirectory()) return false; stream.open(headerfile); } if (stream.isOpen()) { Common::String stxHeader = stream.readLine(); foundHeader = themeConfigParseHeader(stxHeader, themeName); } return foundHeader; }
void AGOSEngine_Simon1::playMusic(uint16 music, uint16 track) { stopMusic(); // Support for compressed music from the ScummVM Music Enhancement Project _system->getAudioCDManager()->stop(); _system->getAudioCDManager()->play(music + 1, -1, 0, 0); if (_system->getAudioCDManager()->isPlaying()) return; if (getPlatform() == Common::kPlatformAmiga) { playModule(music); } else if (getFeatures() & GF_TALKIE) { char buf[4]; // WORKAROUND: For a script bug in the CD versions // We skip this music resource, as it was replaced by // a sound effect, and the script was never updated. if (music == 35) return; _midi.setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.) _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET); _gameFile->read(buf, 4); if (!memcmp(buf, "GMF\x1", 4)) { _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET); _midi.loadSMF(_gameFile, music); } else { _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET); _midi.loadMultipleSMF(_gameFile); } _midi.startTrack(0); _midi.startTrack(track); } else if (getPlatform() == Common::kPlatformAcorn) { // TODO: Add support for Desktop Tracker format in Acorn disk version } else { char filename[15]; Common::File f; sprintf(filename, "MOD%d.MUS", music); f.open(filename); if (f.isOpen() == false) error("playMusic: Can't load music from '%s'", filename); _midi.setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.) if (getFeatures() & GF_DEMO) _midi.loadS1D(&f); else _midi.loadSMF(&f, music); _midi.startTrack(0); _midi.startTrack(track); } }
bool Resource::readTableFile(const GameVersion *gameVersion) { Common::File tableFile; tableFile.open(_tableFilename); if (tableFile.isOpen() && tableFile.readUint32BE() == 'QTBL') { if (tableFile.readUint32BE() != CURRENT_TBL_VERSION) warning("Incorrect version of queen.tbl, please update it"); tableFile.seek(gameVersion->tableOffset); readTableEntries(&tableFile); return true; } return false; }
bool ThemeEngine::loadThemeXML(const Common::String &themeId) { assert(_parser); assert(_themeArchive); _themeName.clear(); // // Now that we have a Common::Archive, verify that it contains a valid THEMERC File // Common::File themercFile; themercFile.open("THEMERC", *_themeArchive); if (!themercFile.isOpen()) { warning("Theme '%s' contains no 'THEMERC' file.", themeId.c_str()); return false; } Common::String stxHeader = themercFile.readLine(); if (!themeConfigParseHeader(stxHeader, _themeName) || _themeName.empty()) { warning("Corrupted 'THEMERC' file in theme '%s'", themeId.c_str()); return false; } Common::ArchiveMemberList members; if (0 == _themeArchive->listMatchingMembers(members, "*.stx")) { warning("Found no STX files for theme '%s'.", themeId.c_str()); return false; } // // Loop over all STX files, load and parse them // for (Common::ArchiveMemberList::iterator i = members.begin(); i != members.end(); ++i) { assert((*i)->getName().hasSuffix(".stx")); if (_parser->loadStream((*i)->createReadStream()) == false) { warning("Failed to load STX file '%s'", (*i)->getDisplayName().c_str()); _parser->close(); return false; } if (_parser->parse() == false) { warning("Failed to parse STX file '%s'", (*i)->getDisplayName().c_str()); _parser->close(); return false; } _parser->close(); } assert(!_themeName.empty()); return true; }
void AGOSEngine_PN::loadGamePcFile() { Common::File in; if (getFileName(GAME_BASEFILE) != NULL) { // Read dataBase in.open(getFileName(GAME_BASEFILE)); if (in.isOpen() == false) { error("loadGamePcFile: Can't load database file '%s'", getFileName(GAME_BASEFILE)); } _dataBaseSize = in.size(); _dataBase = (byte *)malloc(_dataBaseSize); if (_dataBase == NULL) error("loadGamePcFile: Out of memory for dataBase"); in.read(_dataBase, _dataBaseSize); in.close(); if (_dataBase[31] != 0) error("Later version of system requested"); } if (getFileName(GAME_TEXTFILE) != NULL) { // Read textBase in.open(getFileName(GAME_TEXTFILE)); if (in.isOpen() == false) { error("loadGamePcFile: Can't load textbase file '%s'", getFileName(GAME_TEXTFILE)); } _textBaseSize = in.size(); _textBase = (byte *)malloc(_textBaseSize); if (_textBase == NULL) error("loadGamePcFile: Out of memory for textBase"); in.read(_textBase, _textBaseSize); in.close(); if (_textBase[getlong(30L)] != 128) error("Unknown compression format"); } }
void AGOSEngine::playModule(uint16 music) { char filename[15]; Common::File f; uint32 offs = 0; if (getPlatform() == Common::kPlatformAmiga && getGameType() == GType_WW) { // Multiple tunes are stored in music files for main locations for (uint i = 0; i < 20; i++) { if (amigaWaxworksOffs[i].tune == music) { music = amigaWaxworksOffs[i].fileNum; offs = amigaWaxworksOffs[i].offs; } } } if (getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) sprintf(filename, "elvira2"); else if (getPlatform() == Common::kPlatformAcorn) sprintf(filename, "%dtune.DAT", music); else sprintf(filename, "%dtune", music); f.open(filename); if (f.isOpen() == false) { error("playModule: Can't load module from '%s'", filename); } Audio::AudioStream *audioStream; if (!(getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) && getFeatures() & GF_CRUNCHED) { uint32 srcSize = f.size(); byte *srcBuf = (byte *)malloc(srcSize); if (f.read(srcBuf, srcSize) != srcSize) error("playModule: Read failed"); uint32 dstSize = READ_BE_UINT32(srcBuf + srcSize - 4); byte *dstBuf = (byte *)malloc(dstSize); decrunchFile(srcBuf, dstBuf, srcSize); free(srcBuf); Common::MemoryReadStream stream(dstBuf, dstSize); audioStream = Audio::makeProtrackerStream(&stream, offs); free(dstBuf); } else { audioStream = Audio::makeProtrackerStream(&f); } _mixer->playStream(Audio::Mixer::kMusicSoundType, &_modHandle, audioStream); }
static const GLchar *readFile(const Common::String &filename) { Common::File file; file.open(Common::String("shaders/") + filename); if (!file.isOpen()) error("Could not open shader %s!", filename.c_str()); const int32 size = file.size(); GLchar *shaderSource = new GLchar[size + 1]; file.read(shaderSource, size); file.close(); shaderSource[size] = '\0'; return shaderSource; }
// This method is only used by Simon1 Amiga CD32 void Sound::readVoiceFile(const Common::String &filename) { _mixer->stopHandle(_voiceHandle); Common::File *file = new Common::File(); file->open(filename); if (file->isOpen() == false) error("readVoiceFile: Can't load voice file %s", filename.c_str()); const bool dataIsUnsigned = false; delete _voice; _voice = new RawSound(_mixer, file, dataIsUnsigned); }
void AGOSEngine::loadSound(uint16 sound, int16 pan, int16 vol, uint16 type) { byte *dst; if (getGameId() == GID_DIMP) { Common::File in; char filename[15]; assert(sound >= 1 && sound <= 32); sprintf(filename, "%s.wav", dimpSoundList[sound - 1]); in.open(filename); if (in.isOpen() == false) error("loadSound: Can't load %s", filename); uint32 dstSize = in.size(); dst = (byte *)malloc(dstSize); if (in.read(dst, dstSize) != dstSize) error("loadSound: Read failed"); in.close(); } else if (getFeatures() & GF_ZLIBCOMP) { char filename[15]; uint32 file, offset, srcSize, dstSize; if (getPlatform() == Common::kPlatformAmiga) { loadOffsets((const char*)"sfxindex.dat", _zoneNumber * 22 + sound, file, offset, srcSize, dstSize); } else { loadOffsets((const char*)"effects.wav", _zoneNumber * 22 + sound, file, offset, srcSize, dstSize); } if (getPlatform() == Common::kPlatformAmiga) sprintf(filename, "sfx%d.wav", file); else sprintf(filename, "effects.wav"); dst = (byte *)malloc(dstSize); decompressData(filename, dst, offset, srcSize, dstSize); } else { if (_curSfxFile == NULL) return; dst = _curSfxFile + READ_LE_UINT32(_curSfxFile + sound * 4); } if (type == Sound::TYPE_AMBIENT) _sound->playAmbientData(dst, sound, pan, vol); else if (type == Sound::TYPE_SFX) _sound->playSfxData(dst, sound, pan, vol); else if (type == Sound::TYPE_SFX5) _sound->playSfx5Data(dst, sound, pan, vol); }
void AGOSEngine::loadSoundFile(const char* filename) { Common::File in; in.open(filename); if (in.isOpen() == false) error("loadSound: Can't load %s", filename); uint32 dstSize = in.size(); byte *dst = (byte *)malloc(dstSize); if (in.read(dst, dstSize) != dstSize) error("loadSound: Read failed"); in.close(); _sound->playSfxData(dst, 0, 0, 0); }
void AGOSEngine::loadMenuFile() { Common::File in; in.open(getFileName(GAME_MENUFILE)); if (in.isOpen() == false) { error("loadMenuFile: Can't load menus file '%s'", getFileName(GAME_MENUFILE)); } uint fileSize = in.size(); _menuBase = (byte *)malloc(fileSize); if (_menuBase == NULL) error("loadMenuFile: Out of memory for menu data"); in.read(_menuBase, fileSize); in.close(); }
Common::File *Resource::openDataFile(const Common::String fileName, uint32 fileHeader) { Common::File *dataFile = new Common::File(); dataFile->open(translateFileName(fileName)); if (!dataFile->isOpen()) error("openDataFile: Couldn't open %s (%s)", translateFileName(fileName).c_str(), fileName.c_str()); if (fileHeader > 0) { uint32 headerTag = dataFile->readUint32BE(); if (headerTag != fileHeader) { dataFile->close(); error("openDataFile: Unexpected header in %s (%s) - expected: %d, got: %d", translateFileName(fileName).c_str(), fileName.c_str(), fileHeader, headerTag); } } return dataFile; }
uint AGOSEngine::loadTextFile_simon1(const char *filename, byte *dst) { Common::File fo; fo.open(filename); uint32 size; if (fo.isOpen() == false) error("loadTextFile: Can't open '%s'", filename); size = fo.size(); if (fo.read(dst, size) != size) error("loadTextFile: fread failed"); fo.close(); return size; }
void MusicPlayer::playSMF(int track, bool loop) { Common::StackLock lock(_mutex); if (_isPlaying && track == _track) { debugC(2, kDraciSoundDebugLevel, "Already plaing track %d", track); return; } stop(); _isGM = true; // Load MIDI resource data Common::File musicFile; Common::String musicFileName = Common::String::format(_pathMask.c_str(), track); musicFile.open(musicFileName.c_str()); if (!musicFile.isOpen()) { debugC(2, kDraciSoundDebugLevel, "Cannot open track %d", track); return; } int midiMusicSize = musicFile.size(); free(_midiData); _midiData = (byte *)malloc(midiMusicSize); musicFile.read(_midiData, midiMusicSize); musicFile.close(); MidiParser *parser = MidiParser::createParser_SMF(); if (parser->loadMusic(_midiData, midiMusicSize)) { parser->setTrack(0); parser->setMidiDriver(this); parser->setTimerRate(_driver->getBaseTempo()); parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1); _parser = parser; syncVolume(); _isLooping = loop; _isPlaying = true; _track = track; debugC(2, kDraciSoundDebugLevel, "Playing track %d", track); } else { debugC(2, kDraciSoundDebugLevel, "Cannot play track %d", track); delete parser; } }
void AGOSEngine::loadOffsets(const char *filename, int number, uint32 &file, uint32 &offset, uint32 &srcSize, uint32 &dstSize) { Common::File in; int offsSize = (getPlatform() == Common::kPlatformAmiga) ? 16 : 12; /* read offsets from index */ in.open(filename); if (in.isOpen() == false) { error("loadOffsets: Can't load index file '%s'", filename); } in.seek(number * offsSize, SEEK_SET); offset = in.readUint32LE(); dstSize = in.readUint32LE(); srcSize = in.readUint32LE(); file = in.readUint32LE(); in.close(); }
void loadTextData(const char *pFileName, byte *pDestinationBuffer) { Common::File pFileHandle; uint16 entrySize; uint16 numEntry; uint16 i; byte *tempBuffer; uint16 dataSize; assert(pFileName); assert(pDestinationBuffer); pFileHandle.open(pFileName); assert(pFileHandle.isOpen()); entrySize = pFileHandle.readUint16BE(); numEntry = pFileHandle.readUint16BE(); dataSize = numEntry * entrySize; pFileHandle.read(pDestinationBuffer, numEntry * entrySize); tempBuffer = pDestinationBuffer; if (gameType == Cine::GID_FW) { dataSize = dataSize / 0x4E; loadRelatedPalette(pFileName); for (i = 0; i < 0x4E; i++) { gfxConvertSpriteToRaw(textTable[i][0], tempBuffer, 16, 8); generateMask(textTable[i][0], textTable[i][1], 16 * 8, 0); tempBuffer += dataSize; } } else { for (i = 0; i < 90; i++) { gfxConvertSpriteToRaw(textTable[i][0], tempBuffer, 8, 8); generateMask(textTable[i][0], textTable[i][1], 8 * 8, 0); tempBuffer += 0x40; } } pFileHandle.close(); }
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); }
bool ThemeEngine::themeConfigUsable(const Common::ArchiveMember &member, Common::String &themeName) { Common::File stream; bool foundHeader = false; if (member.getName().matchString("*.zip", true)) { Common::Archive *zipArchive = Common::makeZipArchive(member.createReadStream()); if (zipArchive && zipArchive->hasFile("THEMERC")) { stream.open("THEMERC", *zipArchive); } delete zipArchive; } if (stream.isOpen()) { Common::String stxHeader = stream.readLine(); foundHeader = themeConfigParseHeader(stxHeader, themeName); } return foundHeader; }
// This method is only used by Simon1 Amiga CD32 & Windows void Sound::readSfxFile(const Common::String &filename) { if (_hasEffectsFile) return; _mixer->stopHandle(_effectsHandle); Common::File *file = new Common::File(); file->open(filename); if (file->isOpen() == false) { error("readSfxFile: Can't load sfx file %s", filename.c_str()); } const bool dataIsUnsigned = (_vm->getGameId() != GID_SIMON1CD32); delete _effects; if (_vm->getGameId() == GID_SIMON1CD32) { _effects = new VocSound(_mixer, file, dataIsUnsigned, 0, SOUND_BIG_ENDIAN); } else _effects = new WavSound(_mixer, file); }
bool ScummDebugger::Cmd_ImportRes(int argc, const char** argv) { Common::File file; uint32 size; int resnum; if (argc != 4) { DebugPrintf("Syntax: importres <restype> <filename> <resnum>\n"); return true; } resnum = atoi(argv[3]); // FIXME add bounds check if (!strncmp(argv[1], "scr", 3)) { file.open(argv[2], Common::File::kFileReadMode); if (file.isOpen() == false) { DebugPrintf("Could not open file %s\n", argv[2]); return true; } if (_vm->_game.features & GF_SMALL_HEADER) { size = file.readUint16LE(); file.seek(-2, SEEK_CUR); } else if (_vm->_game.features & GF_SMALL_HEADER) { if (_vm->_game.version == 4) file.seek(8, SEEK_CUR); size = file.readUint32LE(); file.readUint16LE(); file.seek(-6, SEEK_CUR); } else { file.readUint32BE(); size = file.readUint32BE(); file.seek(-8, SEEK_CUR); } file.read(_vm->res.createResource(rtScript, resnum, size), size); } else DebugPrintf("Unknown importres type '%s'\n", argv[1]); return true; }
SeekableAudioStream *SeekableAudioStream::openStreamFile(const Common::String &basename) { SeekableAudioStream *stream = NULL; Common::File *fileHandle = new Common::File(); for (int i = 0; i < ARRAYSIZE(STREAM_FILEFORMATS)-1 && stream == NULL; ++i) { Common::String filename = basename + STREAM_FILEFORMATS[i].fileExtension; fileHandle->open(filename); if (fileHandle->isOpen()) { // Create the stream object stream = STREAM_FILEFORMATS[i].openStreamFile(fileHandle, DisposeAfterUse::YES); fileHandle = 0; break; } } delete fileHandle; if (stream == NULL) debug(1, "SeekableAudioStream::openStreamFile: Could not open compressed AudioFile %s", basename.c_str()); return stream; }