本文整理汇总了C++中common::File::readUint32LE方法的典型用法代码示例。如果您正苦于以下问题:C++ File::readUint32LE方法的具体用法?C++ File::readUint32LE怎么用?C++ File::readUint32LE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::File
的用法示例。
在下文中一共展示了File::readUint32LE方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFile
/**
* Opens a file and loads a sound effect.
*
* @param fileName Sfx filename
*
* @returns True is everything is OK, False otherwise
*/
bool FPSfx::loadFile(const char *fileName) {
if (!_soundSupported)
return true;
SoundCodecs codec = FPCODEC_UNKNOWN;
Common::File file;
if (file.open(fileName))
codec = FPCODEC_ADPCM;
else if (file.open(setExtension(fileName, ".MP3")))
codec = FPCODEC_MP3;
else if (file.open(setExtension(fileName, ".OGG")))
codec = FPCODEC_OGG;
else if (file.open(setExtension(fileName, ".FLA")))
codec = FPCODEC_FLAC;
else {
warning("FPSfx::LoadFile(): Cannot open sfx file!");
return false;
}
Common::SeekableReadStream *buffer;
switch (codec) {
case FPCODEC_ADPCM: {
if (file.readUint32BE() != MKTAG('A', 'D', 'P', 0x10)) {
warning("FPSfx::LoadFile(): Invalid ADP header!");
return false;
}
uint32 rate = file.readUint32LE();
uint32 channels = file.readUint32LE();
buffer = file.readStream(file.size() - file.pos());
_rewindableStream = Audio::makeADPCMStream(buffer, DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, channels);
}
break;
case FPCODEC_MP3:
#ifdef USE_MAD
buffer = file.readStream(file.size());
_rewindableStream = Audio::makeMP3Stream(buffer, DisposeAfterUse::YES);
#endif
break;
case FPCODEC_OGG:
#ifdef USE_VORBIS
buffer = file.readStream(file.size());
_rewindableStream = Audio::makeVorbisStream(buffer, DisposeAfterUse::YES);
#endif
break;
case FPCODEC_FLAC:
buffer = file.readStream(file.size());
#ifdef USE_FLAC
_rewindableStream = Audio::makeFLACStream(buffer, DisposeAfterUse::YES);
#endif
break;
default:
return false;
}
_fileLoaded = true;
return true;
}
示例2: load
void BIFFile::load() {
Common::File bif;
open(bif);
readHeader(bif);
if (_id != kBIFID)
throw Common::Exception("Not a BIF file");
if ((_version != kVersion1) && (_version != kVersion11))
throw Common::Exception("Unsupported BIF file version %08X", _version);
uint32 varResCount = bif.readUint32LE();
uint32 fixResCount = bif.readUint32LE();
if (fixResCount != 0)
throw Common::Exception("TODO: Fixed BIF resources");
_iResources.resize(varResCount);
uint32 offVarResTable = bif.readUint32LE();
try {
readVarResTable(bif, offVarResTable);
if (bif.err())
throw Common::Exception(Common::kReadError);
} catch (Common::Exception &e) {
e.add("Failed reading BIF file");
throw e;
}
}
示例3: readSoundData
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);
}
}
示例4: writeParrotLobbyLinkUpdaterEntries
void writeParrotLobbyLinkUpdaterEntries() {
static const int OFFSETS[3] = { 0x5A5B38, 0x5A5320, 0x5A4360 };
static const int COUNTS[5] = { 7, 5, 6, 9, 1 };
static const int SKIP[5] = { 36, 36, 40, 36, 0 };
uint recordOffset = OFFSETS[_version], linkOffset;
byte vals[8];
outputFile.seek(dataOffset);
for (int groupNum = 0; groupNum < 4; ++groupNum) {
for (int entryNum = 0; entryNum < COUNTS[groupNum];
++entryNum, recordOffset += 36) {
inputFile.seek(recordOffset - FILE_DIFF[_version]);
linkOffset = inputFile.readUint32LE();
for (int idx = 0; idx < 8; ++idx)
vals[idx] = inputFile.readUint32LE();
// Write out the entry
inputFile.seek(linkOffset - FILE_DIFF[_version]);
outputFile.writeString(inputFile);
outputFile.write(vals, 8);
}
// Skip space between groups
recordOffset += SKIP[groupNum];
}
uint size = outputFile.size() - dataOffset;
writeEntryHeader("DATA/PARROT_LOBBY_LINK_UPDATOR", dataOffset, size);
dataOffset += size;
}
示例5: load
void NDSFile::load() {
Common::File nds;
open(nds);
if (!isNDS(nds))
throw Common::Exception("Not a support NDS ROM file");
nds.seek(0x40);
uint32 fileNameTableOffset = nds.readUint32LE();
uint32 fileNameTableLength = nds.readUint32LE();
uint32 fatOffset = nds.readUint32LE();
//uint32 fatLength = nds.readUint32LE();
try {
readNames(nds, fileNameTableOffset, fileNameTableLength);
readFAT(nds, fatOffset);
if (nds.err())
throw Common::Exception(Common::kReadError);
} catch (Common::Exception &e) {
e.add("Failed reading NDS file");
throw;
}
}
示例6: open
bool XARCArchive::open(const Common::String &filename) {
Common::File stream;
if (!stream.open(filename)) {
return false;
}
_filename = filename;
// Unknown: always 1? version?
uint32 unknown = stream.readUint32LE();
debugC(kDebugUnknown, "Stark::XARC: \"%s\" has unknown=%d", _filename.c_str(), unknown);
if (unknown != 1) {
warning("Stark::XARC: \"%s\" has unknown=%d with unknown meaning", _filename.c_str(), unknown);
}
// Read the number of contained files
uint32 numFiles = stream.readUint32LE();
debugC(20, kDebugArchive, "Stark::XARC: \"%s\" contains %d files", _filename.c_str(), numFiles);
// Read the offset to the contents of the first file
uint32 offset = stream.readUint32LE();
debugC(20, kDebugArchive, "Stark::XARC: \"%s\"'s first file has offset=%d", _filename.c_str(), offset);
for (uint32 i = 0; i < numFiles; i++) {
XARCMember *member = new XARCMember(this, stream, offset);
_members.push_back(Common::ArchiveMemberPtr(member));
// Set the offset to the next member
offset += member->getLength();
}
return true;
}
示例7: writeSoundNames
void writeSoundNames(const char *sourceFilename, Common::File &target, uint offset) {
Common::File source;
if (!source.open(sourceFilename)) {
error("Unable to open '%s'", sourceFilename);
}
source.seek(offset);
// Count the sounds
uint count = 0;
while (1) {
uint32 id = source.readUint32LE();
if (!id)
break;
source.skip(32);
count++;
}
target.writeLong(count);
source.seek(offset);
for (uint i = 0; i < count; i++) {
uint32 id = source.readUint32LE();
char name[32];
source.read(name, sizeof(name));
target.writeLong(id);
target.write(name, sizeof(name));
}
source.close();
}
示例8: startSound
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);
}
}
示例9: setupHEMusicFile
void SoundHE::setupHEMusicFile() {
int i, total_size;
Common::File musicFile;
Common::String buf(_vm->generateFilename(-4));
if (musicFile.open(buf) == true) {
musicFile.seek(4, SEEK_SET);
total_size = musicFile.readUint32BE();
musicFile.seek(16, SEEK_SET);
_heMusicTracks = musicFile.readUint32LE();
debug(5, "Total music tracks %d", _heMusicTracks);
int musicStart = (_vm->_game.heversion >= 80) ? 56 : 20;
musicFile.seek(musicStart, SEEK_SET);
_heMusic = (HEMusic *)malloc((_heMusicTracks + 1) * sizeof(HEMusic));
for (i = 0; i < _heMusicTracks; i++) {
_heMusic[i].id = musicFile.readUint32LE();
_heMusic[i].offset = musicFile.readUint32LE();
_heMusic[i].size = musicFile.readUint32LE();
if (_vm->_game.heversion >= 80) {
musicFile.seek(+9, SEEK_CUR);
} else {
musicFile.seek(+13, SEEK_CUR);
}
}
musicFile.close();
}
}
示例10: LzssReadStream
Common::SeekableReadStream *Hqr::createReadStreamForIndex(int index) const {
if (index >= _numIndices)
return 0;
uint32 realSize;
uint32 compressedSize;
uint16 mode;
Common::File *file = new Common::File();
file->open(_hqrFileName);
file->seek(_indices[index]);
realSize = file->readUint32LE();
compressedSize = file->readUint32LE();
mode = file->readUint16LE();
uint32 begin = _indices[index] + 10;
uint32 end = 0;
if (mode == 0) {
end = begin + realSize;
} else {
end = begin + compressedSize;
}
Common::SeekableReadStream *stream = new Common::SeekableSubReadStream(file, begin, end, DisposeAfterUse::YES);
if (mode != 0) {
stream = new LzssReadStream(stream, mode, realSize);
}
return stream;
}
示例11: SeekableSubReadStream
Common::SeekableReadStream *MADSResourceManager::loadResource(const char *resourceName, bool loadFlag) {
Common::File hagFile;
uint32 offset = 0, size = 0;
// If the first character is a '@' then look for an external file
if (*resourceName == '@') {
++resourceName;
hagFile.open(resourceName);
if (loadFlag)
return hagFile.readStream(hagFile.size());
else
return new Common::SeekableSubReadStream(&hagFile, 0, hagFile.size());
}
// If the first character is the wildcard (resource indicator), skip over it
if (*resourceName == '*')
++resourceName;
char resName[20];
strcpy(resName, resourceName);
str_upper(resName);
hagFile.open(getResourceFilename(resName));
// Validate hag file header
char headerBuffer[16];
if ((hagFile.read(headerBuffer, 16) != 16) || (strncmp(headerBuffer, madsConcatString, 10) != 0))
error("Invalid HAG file opened");
int numEntries = hagFile.readUint16LE();
int resIndex = -1;
while (++resIndex < numEntries) {
// Read in the details of the next resource
char resourceBuffer[14];
offset = hagFile.readUint32LE();
size = hagFile.readUint32LE();
hagFile.read(resourceBuffer, 14);
if (!strcmp(resName, resourceBuffer))
break;
}
if (resIndex == numEntries)
error("Invalid resource '%s' specified", resourceName);
// Get the resource, either loading it in it's entirely or getting a stream reference
if (loadFlag) {
hagFile.seek(offset);
return hagFile.readStream(size);
} else {
return new Common::SeekableSubReadStream(&hagFile, offset, offset + size);
}
}
示例12: open
bool SliceAnimations::open(const Common::String &name) {
Common::File file;
if (!file.open(_vm->getResourceStream(name), name))
return false;
_timestamp = file.readUint32LE();
_pageSize = file.readUint32LE();
_pageCount = file.readUint32LE();
_paletteCount = file.readUint32LE();
if (_timestamp != 0x3457b6f6) // Timestamp: Wed, 29 Oct 1997 22:21:42 GMT
return false;
_palettes.resize(_paletteCount);
for (uint32 i = 0; i != _paletteCount; ++i) {
for (uint32 j = 0; j != 256; ++j) {
uint8 color_r = file.readByte();
uint8 color_g = file.readByte();
uint8 color_b = file.readByte();
_palettes[i].color[j].r = color_r;
_palettes[i].color[j].g = color_g;
_palettes[i].color[j].b = color_b;
uint16 rgb555 = ((uint16)color_r << 10) |
((uint16)color_g << 5) |
(uint16)color_b;
_palettes[i].color555[j] = rgb555;
}
}
uint32 animationCount = file.readUint32LE();
_animations.resize(animationCount);
for (uint32 i = 0; i != animationCount; ++i) {
_animations[i].frameCount = file.readUint32LE();
_animations[i].frameSize = file.readUint32LE();
_animations[i].fps = file.readFloatLE();
_animations[i].positionChange.x = file.readFloatLE();
_animations[i].positionChange.y = file.readFloatLE();
_animations[i].positionChange.z = file.readFloatLE();
_animations[i].facingChange = file.readFloatLE();
_animations[i].offset = file.readUint32LE();
}
_pages.resize(_pageCount);
for (uint32 i = 0; i != _pageCount; ++i)
_pages[i]._data = nullptr;
return true;
}
示例13: loadSoundEffect
void Music::loadSoundEffect(const Common::String filename, bool loop, bool waitTillFinished) {
stopSoundEffect();
Common::File *file = _vm->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
if (!file)
return;
_vm->_anim->_doBlack = false;
uint32 magicBytes = file->readUint32LE();
if (magicBytes != 1219009121) {
warning("readSound: Bad signature, skipping");
return;
}
uint32 soundTag = file->readUint32LE();
uint32 soundSize = file->readUint32LE();
if (soundTag != 0)
return;
file->skip(soundSize); // skip the header
while (soundTag != 65535) {
_vm->updateEvents();
soundTag = file->readUint32LE();
soundSize = file->readUint32LE() - 8;
if ((soundTag == 30) || (soundTag == 31)) {
if (waitTillFinished) {
while (isSoundEffectActive()) {
_vm->updateEvents();
_vm->waitTOF();
}
}
file->skip(4);
uint16 sampleRate = file->readUint16LE();
file->skip(2);
playSoundEffect(sampleRate, soundSize, loop, file);
} else if (soundTag == 65535) {
if (waitTillFinished) {
while (isSoundEffectActive()) {
_vm->updateEvents();
_vm->waitTOF();
}
}
} else
file->skip(soundSize);
}
}
示例14:
byte *Sword2Engine::fetchPsxBackground(uint32 location) {
Common::File file;
PSXScreensEntry header;
uint32 screenOffset, dataOffset;
uint32 totSize; // Total size of background, counting data, offset table and additional header
byte *buffer;
if (!file.open("screens.clu")) {
GUIErrorMessage("Broken Sword 2: Cannot open screens.clu");
return NULL;
}
file.seek(location * 4, SEEK_SET);
screenOffset = file.readUint32LE();
if (screenOffset == 0) { // We don't have screen data for this location number.
file.close();
return NULL;
}
// Get to the beginning of PSXScreensEntry
file.seek(screenOffset + ResHeader::size(), SEEK_SET);
buffer = (byte *)malloc(PSXScreensEntry::size());
file.read(buffer, PSXScreensEntry::size());
// Prepare the header
header.read(buffer);
free(buffer);
file.seek(screenOffset + header.bgOffset + 4, SEEK_SET);
dataOffset = file.readUint32LE();
file.seek(screenOffset + header.bgOffset, SEEK_SET);
totSize = header.bgSize + (dataOffset - header.bgOffset) + 8;
buffer = (byte *)malloc(totSize);
// Write some informations before background data
WRITE_LE_UINT16(buffer, header.bgXres);
WRITE_LE_UINT16(buffer + 2, header.bgYres);
WRITE_LE_UINT32(buffer + 4, header.bgOffset);
file.read(buffer + 8, totSize - 8); // Do not write on the header
file.close();
return buffer;
}
示例15: resId
// AUDIOnnn.MAP contains 10-byte entries:
// Early format:
// w 5 bits resource type and 11 bits resource number
// dw 7 bits volume number and 25 bits offset
// dw size
// Later format:
// w nEntry
// dw offset+volume (as in resource.map)
// dw size
// ending with 10 0xFFs
int ResourceManager::readAudioMapSCI1(ResourceSource *map, bool unload) {
Common::File file;
if (!file.open(map->getLocationName()))
return SCI_ERROR_RESMAP_NOT_FOUND;
bool oldFormat = (file.readUint16LE() >> 11) == kResourceTypeAudio;
file.seek(0);
for (;;) {
uint16 n = file.readUint16LE();
uint32 offset = file.readUint32LE();
uint32 size = file.readUint32LE();
if (file.eos() || file.err()) {
warning("Error while reading %s", map->getLocationName().c_str());
return SCI_ERROR_RESMAP_NOT_FOUND;
}
if (n == 0xffff)
break;
byte volume_nr;
if (oldFormat) {
n &= 0x07ff; // Mask out resource type
volume_nr = offset >> 25; // most significant 7 bits
offset &= 0x01ffffff; // least significant 25 bits
} else {
volume_nr = offset >> 28; // most significant 4 bits
offset &= 0x0fffffff; // least significant 28 bits
}
ResourceSource *src = findVolume(map, volume_nr);
if (src) {
const ResourceId resId(kResourceTypeAudio, n);
if (unload)
removeAudioResource(resId);
else
addResource(resId, src, offset, size, map->getLocationName());
} else {
warning("Failed to find audio volume %i", volume_nr);
return SCI_ERROR_NO_RESOURCE_FILES_FOUND;
}
}