void DirectorEngine::loadMac() { if (getVersion() < 4) { // The data is part of the resource fork of the executable _mainArchive = new MacArchive(); if (!_mainArchive->openFile(getEXEName())) error("Failed to open Mac binary '%s'", getEXEName().c_str()); } else { // The RIFX is located in the data fork of the executable _macBinary = new Common::MacResManager(); if (!_macBinary->open(getEXEName()) || !_macBinary->hasDataFork()) error("Failed to open Mac binary '%s'", getEXEName().c_str()); Common::SeekableReadStream *dataFork = _macBinary->getDataFork(); _mainArchive = new RIFXArchive(); // First we need to detect PPC vs. 68k uint32 tag = dataFork->readUint32BE(); uint32 startOffset; if (SWAP_BYTES_32(tag) == MKTAG('P', 'J', '9', '3') || tag == MKTAG('P', 'J', '9', '5') || tag == MKTAG('P', 'J', '0', '0')) { // PPC: The RIFX shares the data fork with the binary startOffset = dataFork->readUint32BE(); } else { // 68k: The RIFX is the only thing in the data fork startOffset = 0; } if (!_mainArchive->openStream(dataFork, startOffset)) error("Failed to load RIFX from Mac binary"); } }
void FrameSequence::openFrameSequence() { if (!_resFork->hasResFork()) return; Common::SeekableReadStream *res = _resFork->getResource(MKTAG('P', 'F', 'r', 'm'), 0x80); if (!res) return; uint32 scale = res->readUint32BE(); _bounds.top = res->readUint16BE(); _bounds.left = res->readUint16BE(); _bounds.bottom = res->readUint16BE(); _bounds.right = res->readUint16BE(); _numFrames = res->readUint16BE(); _duration = 0; _frameTimes.clear(); for (uint32 i = 0; i < _numFrames; i++) { TimeValue time = res->readUint32BE(); _frameTimes.push_back(_duration); _duration += time; } setScale(scale); setSegment(0, _duration); setTime(0); _currentFrameNum = 0; newFrame(_currentFrameNum); triggerRedraw(); delete res; }
bool CUP_Player::parseNextHeaderTag(Common::SeekableReadStream &dataStream) { uint32 tag = dataStream.readUint32BE(); uint32 size = dataStream.readUint32BE() - 8; if (dataStream.eos()) return false; uint32 next = dataStream.pos() + size; debug(1, "New header tag %s %d dataSize %d", tag2str(tag), size, _dataSize); switch (tag) { case MKTAG('H','E','A','D'): handleHEAD(dataStream, size); break; case MKTAG('S','F','X','B'): handleSFXB(dataStream, size); break; case MKTAG('R','G','B','S'): handleRGBS(dataStream, size); break; case MKTAG('D','A','T','A'): _dataSize = size; return false; case MKTAG('G','F','X','B'): // this is never triggered default: warning("Unhandled tag %s", tag2str(tag)); break; } dataStream.seek(next); return true; }
void Walkmesh::appendFromStream(Common::SeekableReadStream &stream) { stream.seek(0); /** Header format: * * uint8[8] - WOK version * uint32 - walkmesh type * uint8[48] - reserved * float[3] - position */ if (stream.readUint32BE() != MKTAG('B', 'W', 'M', ' ') || stream.readUint32BE() != MKTAG('V', '1', '.', '0')) throw Common::Exception("Invalid WOK version"); stream.skip(64); uint32 vertexCount = stream.readUint32LE(); uint32 vertexOffset = stream.readUint32LE(); uint32 faceCount = stream.readUint32LE(); uint32 faceOffset = stream.readUint32LE(); uint32 faceTypeOffset = stream.readUint32LE(); //- appendFaceTypes(stream, faceCount, faceTypeOffset); appendIndices(stream, faceCount, faceOffset); appendVertices(stream, vertexCount, vertexOffset); }
/** * Load animDataTable from save * @param fHandle Savefile open for reading * @param saveGameFormat The used savegame format * @todo Add Operation Stealth savefile support * * Unlike the old code, this one actually rebuilds the table one frame * at a time. */ void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGameFormat saveGameFormat) { int16 foundFileIdx; char *animName, part[256], name[10]; strcpy(part, currentPartName); // We only support these variations of the savegame format at the moment. assert(saveGameFormat == ANIMSIZE_23 || saveGameFormat == ANIMSIZE_30_PTRS_INTACT); const int entrySize = ((saveGameFormat == ANIMSIZE_23) ? 23 : 30); const int fileStartPos = fHandle.pos(); for(int resourceIndex=0; resourceIndex<NUM_MAX_ANIMDATA; resourceIndex++) { // Seek to the start of the current animation's entry fHandle.seek(fileStartPos + resourceIndex * entrySize); // Read in the current animation entry fHandle.readUint16BE(); // width fHandle.readUint16BE(); fHandle.readUint16BE(); // bpp fHandle.readUint16BE(); // height bool validPtr = false; // Handle variables only present in animation entries of size 30 if (entrySize == 30) { validPtr = (fHandle.readUint32BE() != 0); // Read data pointer fHandle.readUint32BE(); // Discard mask pointer } foundFileIdx = fHandle.readSint16BE(); int16 frameIndex = fHandle.readSint16BE(); // frame fHandle.read(name, 10); // Handle variables only present in animation entries of size 23 if (entrySize == 23) { validPtr = (fHandle.readByte() != 0); } // Don't try to load invalid entries. if (foundFileIdx < 0 || !validPtr) { //resourceIndex++; // Jump over the invalid entry continue; } // Alright, the animation entry looks to be valid so let's start handling it... if (strcmp(currentPartName, name) != 0) { closePart(); loadPart(name); } animName = g_cine->_partBuffer[foundFileIdx].partName; loadRelatedPalette(animName); // Is this for Future Wars only? loadResource(animName, resourceIndex, frameIndex); } loadPart(part); // Make sure we jump over all the animation entries fHandle.seek(fileStartPos + NUM_MAX_ANIMDATA * entrySize); }
bool IFFDecoder::loadStream(Common::SeekableReadStream &stream) { destroy(); const uint32 form = stream.readUint32BE(); if (form != ID_FORM) { warning("Failed reading IFF-file"); return false; } stream.skip(4); const uint32 type = stream.readUint32BE(); switch (type) { case ID_ILBM: _type = TYPE_ILBM; break; case ID_PBM: _type = TYPE_PBM; break; } if (type == TYPE_UNKNOWN) { warning("Failed reading IFF-file"); return false; } while (1) { const uint32 chunkType = stream.readUint32BE(); const uint32 chunkSize = stream.readUint32BE(); if (stream.eos()) break; switch (chunkType) { case ID_BMHD: loadHeader(stream); break; case ID_CMAP: loadPalette(stream, chunkSize); break; case ID_CRNG: loadPaletteRange(stream, chunkSize); break; case ID_BODY: loadBitmap(stream); break; default: stream.skip(chunkSize); } } return true; }
uint32 MohawkEngine_Riven::getCurCardRMAP() { Common::SeekableReadStream *rmapStream = getResource(ID_RMAP, 1); rmapStream->seek(_curCard * 4); uint32 rmapCode = rmapStream->readUint32BE(); delete rmapStream; return rmapCode; }
void parseOpcodeDefault(Instruction &instr, Common::SeekableReadStream &ncs) { instr.argCount = getDirectArgumentCount(instr.opcode); const OpcodeArgument * const args = getDirectArguments(instr.opcode); for (size_t i = 0; i < instr.argCount; i++) { instr.argTypes[i] = args[i]; switch (instr.argTypes[i]) { case kOpcodeArgUint8: instr.args[i] = ncs.readByte(); break; case kOpcodeArgUint16: instr.args[i] = ncs.readUint16BE(); break; case kOpcodeArgSint16: instr.args[i] = ncs.readSint16BE(); break; case kOpcodeArgSint32: instr.args[i] = ncs.readSint32BE(); break; case kOpcodeArgUint32: instr.args[i] = (int32)ncs.readUint32BE(); break; default: break; } } }
void XEOSITEX::readHeader(Common::SeekableReadStream &xeositex) { const uint32 magic1 = xeositex.readUint32BE(); const uint32 magic2 = xeositex.readUint32BE(); if ((magic1 != kXEOSID) || (magic2 != kITEXID)) throw Common::Exception("Not a valid XEOSITEX (%s, %s)", Common::debugTag(magic1).c_str(), Common::debugTag(magic2).c_str()); const uint32 version = xeositex.readUint32LE(); if (version != 0) throw Common::Exception("Invalid XEOSITEX version %u", version); const uint32 pixelFormat = xeositex.readUint32LE(); if ((pixelFormat != 3) && (pixelFormat != 4)) throw Common::Exception("Invalid XEOSITEX pixel format %u", pixelFormat); if (pixelFormat == 3) { _format = kPixelFormatBGR; _formatRaw = kPixelFormatRGB8; _dataType = kPixelDataType8; } else if (pixelFormat == 4) { _format = kPixelFormatBGRA; _formatRaw = kPixelFormatRGBA8; _dataType = kPixelDataType8; } _wrapX = xeositex.readByte() != 0; _wrapY = xeositex.readByte() != 0; _flipX = xeositex.readByte() != 0; _flipY = xeositex.readByte() != 0; _coordTransform = xeositex.readByte(); const uint32 mipMaps = xeositex.readUint32LE(); _mipMaps.resize(mipMaps, 0); }
bool DIBDecoder::loadStream(Common::SeekableReadStream &stream) { uint32 headerSize = stream.readUint32LE(); if (headerSize != 40) return false; uint32 width = stream.readUint32LE(); uint32 height = stream.readUint32LE(); stream.readUint16LE(); // planes uint16 bitsPerPixel = stream.readUint16LE(); uint32 compression = stream.readUint32BE(); uint32 imageSize = stream.readUint32LE(); /* uint32 pixelsPerMeterX = */ stream.readUint32LE(); /* uint32 pixelsPerMeterY = */ stream.readUint32LE(); _paletteColorCount = stream.readUint32LE(); /* uint32 colorsImportant = */ stream.readUint32LE(); _paletteColorCount = (_paletteColorCount == 0) ? 255: _paletteColorCount; uint16 imageRawSize = stream.size() - 40; Common::SeekableSubReadStream subStream(&stream, 40, stream.size()); _codec = Image::createBitmapCodec(compression, width, height, bitsPerPixel); if (!_codec) return false; _surface = _codec->decodeFrame(subStream); return true; }
void parseOpcodeConst(Instruction &instr, Common::SeekableReadStream &ncs) { switch (instr.type) { case kInstTypeInt: instr.constValueInt = ncs.readSint32BE(); break; case kInstTypeFloat: instr.constValueFloat = ncs.readIEEEFloatBE(); break; case kInstTypeString: case kInstTypeResource: instr.constValueString = readStringQuoting(ncs, ncs.readUint16BE()); break; case kInstTypeObject: instr.constValueObject = ncs.readUint32BE(); break; default: throw Common::Exception("Illegal type for opcode CONST: 0x%02X", (uint8)instr.type); } instr.argTypes[0] = kOpcodeArgVariable; instr.argCount = 1; }
void NCSFile::load(Common::SeekableReadStream &ncs) { try { readHeader(ncs); if (_id != kNCSID) throw Common::Exception("Not an NCS file (%s)", Common::debugTag(_id).c_str()); if (_version != kVersion10) throw Common::Exception("Unsupported NCS file version %s", Common::debugTag(_version).c_str()); const byte sizeOpcode = ncs.readByte(); if (sizeOpcode != kOpcodeSCRIPTSIZE) throw Common::Exception("Script size opcode != 0x42 (0x%02X)", sizeOpcode); _size = ncs.readUint32BE(); if (_size > ncs.size()) throw Common::Exception("Script size %u > stream size %u", (uint)_size, (uint)ncs.size()); if (_size < ncs.size()) warning("Script size %u < stream size %u", (uint)_size, (uint)ncs.size()); parse(ncs); analyzeBlocks(); analyzeSubRoutines(); } catch (Common::Exception &e) { e.add("Failed to load NCS file"); throw e; } }
/** * Restore incrust list from savefile * @param fHandle Savefile open for reading */ void loadBgIncrustFromSave(Common::SeekableReadStream &fHandle) { BGIncrust tmp; int size = fHandle.readSint16BE(); for (int i = 0; i < size; i++) { fHandle.readUint32BE(); fHandle.readUint32BE(); tmp.unkPtr = 0; tmp.objIdx = fHandle.readUint16BE(); tmp.param = fHandle.readUint16BE(); tmp.x = fHandle.readUint16BE(); tmp.y = fHandle.readUint16BE(); tmp.frame = fHandle.readUint16BE(); tmp.part = fHandle.readUint16BE(); g_cine->_bgIncrustList.push_back(tmp); if (tmp.param == 0) { renderer->incrustSprite(g_cine->_objectTable[tmp.objIdx]); } else { renderer->incrustMask(g_cine->_objectTable[tmp.objIdx]); } } }
void ImageFile::loadPalette(Common::SeekableReadStream &stream) { // Check for palette uint16 width = stream.readUint16LE() + 1; uint16 height = stream.readUint16LE() + 1; byte paletteBase = stream.readByte(); byte rleEncoded = stream.readByte(); byte offsetX = stream.readByte(); byte offsetY = stream.readByte(); uint32 palSignature = 0; if ((width == 390) && (height == 2) && (!paletteBase) && (!rleEncoded) && (!offsetX) && (!offsetY)) { // We check for these specific values // We can't do "width * height", because at least the first German+Spanish menu bar is 60 x 13 // which is 780, which is the size of the palette. We obviously don't want to detect it as palette. // As another security measure, we also check for the signature text palSignature = stream.readUint32BE(); if (palSignature != MKTAG('V', 'G', 'A', ' ')) { // signature mismatch, rewind stream.seek(-12, SEEK_CUR); return; } // Found palette, so read it in stream.seek(8, SEEK_CUR); // Skip over the rest of the signature text "VGA palette" for (int idx = 0; idx < PALETTE_SIZE; ++idx) _palette[idx] = VGA_COLOR_TRANS(stream.readByte()); } else { // Not a palette, so rewind to start of frame data for normal frame processing stream.seek(-8, SEEK_CUR); } }
void Cache::load(const Common::String &name, Common::SeekableReadStream &stream) { // First check if the entry already exists if (_resources.contains(name)) return; int32 signature = stream.readUint32BE(); stream.seek(0); // Allocate a new cache entry _resources[name] = CacheEntry(); CacheEntry &cacheEntry = _resources[name]; // Check whether the file is compressed if (signature == MKTAG('L', 'Z', 'V', 26)) { // It's compressed, so decompress the file and store it's data in the cache entry Common::SeekableReadStream *decompressed = _vm->_res->decompress(stream); cacheEntry.resize(decompressed->size()); decompressed->read(&cacheEntry[0], decompressed->size()); delete decompressed; } else { // It's not, so read the raw data of the file into the cache entry cacheEntry.resize(stream.size()); stream.read(&cacheEntry[0], stream.size()); } }
void DDS::readHeader(Common::SeekableReadStream &dds) { if (dds.readUint32BE() == kDDSID) // We found the FourCC of a standard DDS readStandardHeader(dds); else // FourCC not found, should be a BioWare DDS then readBioWareHeader(dds); }
void MainWindow::exportBMUMP3Impl(Common::SeekableReadStream &bmu, Common::WriteStream &mp3) { if ((bmu.size() <= 8) || (bmu.readUint32BE() != MKTAG('B', 'M', 'U', ' ')) || (bmu.readUint32BE() != MKTAG('V', '1', '.', '0'))) throw Common::Exception("Not a valid BMU file"); mp3.writeStream(bmu); }
void CUP_Player::handleSFXB(Common::SeekableReadStream &dataStream, uint32 dataSize) { if (dataSize > 16) { // WRAP and OFFS chunks uint32 tag = dataStream.readUint32BE(); uint32 size = dataStream.readUint32BE(); if (tag == MKTAG('W','R','A','P')) { tag = dataStream.readUint32BE(); size = dataStream.readUint32BE(); if (tag == MKTAG('O','F','F','S')) { _sfxCount = (size - 8) / 4; _sfxBuffer = (uint8 *)malloc(dataSize - 16); if (_sfxBuffer) { dataStream.read(_sfxBuffer, dataSize - 16); } } } } }
bool Animation::loadStream(Common::SeekableReadStream &stream) { stream.skip(2); // skip not used x and y coord diff _loopCount = stream.readUint16LE(); _phaseCount = stream.readUint16LE(); stream.skip(2); // skip _frameCount here _baseX = stream.readUint16LE(); _baseY = stream.readUint16LE(); uint32 phaseTableOffset = stream.readUint32LE(); uint32 tableOfFrameOffsets = stream.pos(); stream.seek(phaseTableOffset); Phase tempPhase; _frameCount = 0; for (int phase = 0; phase < _phaseCount; phase++) { tempPhase._phaseOffsetX = stream.readSint16LE(); tempPhase._phaseOffsetY = stream.readSint16LE(); tempPhase._phaseToFrameIndex = stream.readUint16LE(); if (tempPhase._phaseToFrameIndex > _frameCount) { _frameCount = tempPhase._phaseToFrameIndex; } _phaseList.push_back(tempPhase); stream.skip(2); } if (_phaseCount) { _frameCount++; } Frame tempFrame; for (int frame = 0; frame < _frameCount; frame++) { stream.seek(tableOfFrameOffsets + frame * 4); uint32 frameInfoOffset = stream.readUint32LE(); stream.seek(frameInfoOffset); uint16 frameWidth = stream.readUint16LE(); uint16 frameHeight = stream.readUint16LE(); uint32 frameDataPos = stream.pos(); uint32 frameDataOffset = stream.readUint32BE(); tempFrame._surface = new Graphics::Surface(); tempFrame._surface->create(frameWidth, frameHeight, Graphics::PixelFormat::createFormatCLUT8()); if (frameDataOffset == MKTAG('m', 'a', 's', 'm')) { tempFrame._isCompressed = true; tempFrame._dataSize = stream.readUint32LE(); tempFrame._compressedData = (byte *)malloc(tempFrame._dataSize); stream.read(tempFrame._compressedData, tempFrame._dataSize); } else { tempFrame._isCompressed = false; tempFrame._dataSize = 0; tempFrame._compressedData = nullptr; stream.seek(frameDataPos); for (uint16 i = 0; i < frameHeight; i++) { stream.read(tempFrame._surface->getBasePtr(0, i), frameWidth); } } _frameList.push_back(tempFrame); } return true; }
void DDS::readStandardHeader(Common::SeekableReadStream &dds) { // All DDS header should be 124 bytes (+ 4 for the FourCC) big if (dds.readUint32LE() != 124) throw Common::Exception("Header size invalid"); // DDS features uint32 flags = dds.readUint32LE(); // Image dimensions uint32 height = dds.readUint32LE(); uint32 width = dds.readUint32LE(); dds.skip(4 + 4); // Pitch + Depth //uint32 pitchOrLineSize = dds.readUint32LE(); //uint32 depth = dds.readUint32LE(); uint32 mipMapCount = dds.readUint32LE(); // DDS doesn't provide any mip maps, only one full-size image if ((flags & kHeaderFlagsHasMipMaps) == 0) mipMapCount = 1; dds.skip(44); // Reserved // Read the pixel data format DDSPixelFormat format; format.size = dds.readUint32LE(); format.flags = dds.readUint32LE(); format.fourCC = dds.readUint32BE(); format.bitCount = dds.readUint32LE(); format.rBitMask = dds.readUint32LE(); format.gBitMask = dds.readUint32LE(); format.bBitMask = dds.readUint32LE(); format.aBitMask = dds.readUint32LE(); // Detect which specific format it describes detectFormat(format); dds.skip(16 + 4); // DDCAPS2 + Reserved _mipMaps.reserve(mipMapCount); for (uint32 i = 0; i < mipMapCount; i++) { MipMap *mipMap = new MipMap; mipMap->width = MAX<uint32>(width , 1); mipMap->height = MAX<uint32>(height, 1); setSize(*mipMap); mipMap->data = 0; width >>= 1; height >>= 1; _mipMaps.push_back(mipMap); } }
void TRXFile::loadDirectory(Common::SeekableReadStream &trx, std::vector<Packet> &packets) { for (std::vector<Packet>::iterator p = packets.begin(); p != packets.end(); ++p) { p->type = trx.readUint32BE(); p->offset = trx.readUint32LE(); if (p->offset >= (uint)trx.size()) throw Common::Exception("Offset of 0x%08X packet too big (%d)", p->type, p->offset); } }
void GFF4File::Header::read(Common::SeekableReadStream &gff4, uint32 version) { platformID = gff4.readUint32BE(); type = gff4.readUint32BE(); typeVersion = gff4.readUint32BE(); structCount = gff4.readUint32LE(); stringCount = 0; stringOffset = 0xFFFFFFFF; if (version == kVersion41) { stringCount = gff4.readUint32LE(); stringOffset = gff4.readUint32LE(); } hasSharedStrings = (stringCount > 0) || (stringOffset != 0xFFFFFFFF); dataOffset = gff4.readUint32LE(); }
bool ImuseChannel::appendData(Common::SeekableReadStream &b, int32 size) { if (_dataSize == -1) { assert(size > 8); uint32 imus_type = b.readUint32BE(); /*uint32 imus_size =*/ b.readUint32BE(); if (imus_type != MKTAG('i','M','U','S')) error("Invalid Chunk for imuse_channel"); size -= 8; _tbufferSize = size; assert(_tbufferSize); _tbuffer = (byte *)malloc(_tbufferSize); if (!_tbuffer) error("imuse_channel failed to allocate memory"); b.read(_tbuffer, size); _dataSize = -2; } else { if (_tbuffer) { byte *old = _tbuffer; int32 new_size = size + _tbufferSize; _tbuffer = (byte *)malloc(new_size); if (!_tbuffer) error("imuse_channel failed to allocate memory"); memcpy(_tbuffer, old, _tbufferSize); free(old); b.read(_tbuffer + _tbufferSize, size); _tbufferSize += size; } else { _tbufferSize = size; _tbuffer = (byte *)malloc(_tbufferSize); if (!_tbuffer) error("imuse_channel failed to allocate memory"); b.read(_tbuffer, size); } } processBuffer(); _srbufferSize = _sbufferSize; if (_sbuffer && _bitsize == 12) decode(); return true; }
bool Infogrames::Instruments::load(Common::SeekableReadStream &ins) { int i; int32 fsize; int32 offset[32]; int32 offsetRepeat[32]; int32 dataOffset; unload(); fsize = ins.readUint32BE(); dataOffset = fsize; for (i = 0; (i < 32) && !ins.eos(); i++) { offset[i] = ins.readUint32BE(); offsetRepeat[i] = ins.readUint32BE(); if ((offset[i] > fsize) || (offsetRepeat[i] > fsize) || (offset[i] < (ins.pos() + 4)) || (offsetRepeat[i] < (ins.pos() + 4))) { // Definitely no real entry anymore ins.seek(-8, SEEK_CUR); break; } dataOffset = MIN(dataOffset, MIN(offset[i], offsetRepeat[i])); ins.skip(4); // Unknown _samples[i].length = ins.readUint16BE() * 2; _samples[i].lengthRepeat = ins.readUint16BE() * 2; } if (dataOffset >= fsize) return false; _count = i; _sampleData = new int8[fsize - dataOffset]; ins.seek(dataOffset + 4); ins.read(_sampleData, fsize - dataOffset); for (i--; i >= 0; i--) { _samples[i].data = _sampleData + (offset[i] - dataOffset); _samples[i].dataRepeat = _sampleData + (offsetRepeat[i] - dataOffset); } return true; }
bool CUP_Player::parseNextBlockTag(Common::SeekableReadStream &dataStream) { uint32 tag = dataStream.readUint32BE(); uint32 size = dataStream.readUint32BE() - 8; uint32 next = dataStream.pos() + size; debug(1, "New block tag %s %d dataSize %d", tag2str(tag), size, _dataSize); switch (tag) { case MKTAG('F','R','A','M'): handleFRAM(dataStream, size); break; case MKTAG('L','Z','S','S'): if (handleLZSS(dataStream, size) && _outLzssBufSize != 0) { Common::MemoryReadStream memoryStream(_outLzssBufData, _outLzssBufSize); parseNextBlockTag(memoryStream); } break; case MKTAG('R','A','T','E'): handleRATE(dataStream, size); break; case MKTAG('R','G','B','S'): handleRGBS(dataStream, size); break; case MKTAG('S','N','D','E'): handleSNDE(dataStream, size); break; case MKTAG('T','O','I','L'): handleTOIL(dataStream, size); break; case MKTAG('S','R','L','E'): handleSRLE(dataStream, size); break; case MKTAG('B','L','O','K'): _dataSize -= size + 8; return false; case MKTAG('W','R','L','E'): // this is never triggered default: warning("Unhandled tag %s", tag2str(tag)); break; } dataStream.seek(next); return true; }
void parseOpcodeStore(Instruction &instr, Common::SeekableReadStream &ncs) { instr.args[0] = (uint8) instr.type; instr.args[1] = ncs.readUint32BE(); instr.args[2] = ncs.readUint32BE(); instr.argTypes[0] = kOpcodeArgUint8; instr.argTypes[1] = kOpcodeArgUint32; instr.argTypes[2] = kOpcodeArgUint32; instr.argCount = 3; instr.type = kInstTypeDirect; }
bool SaudChannel::appendData(Common::SeekableReadStream &b, int32 size) { if (_dataSize == -1) { assert(size > 8); uint32 saud_type = b.readUint32BE(); /*uint32 saud_size =*/ b.readUint32BE(); if (saud_type != MKID_BE('SAUD')) error("Invalid Chunk for SaudChannel : %X", saud_type); size -= 8; _dataSize = -2; } if (_tbuffer) { byte *old = _tbuffer; _tbuffer = (byte *)malloc(_tbufferSize + size); if (!_tbuffer) error("saud_channel failed to allocate memory"); memcpy(_tbuffer, old, _tbufferSize); free(old); b.read(_tbuffer + _tbufferSize, size); _tbufferSize += size; } else { _tbufferSize = size; _tbuffer = (byte *)malloc(_tbufferSize); if (!_tbuffer) error("saud_channel failed to allocate memory"); b.read(_tbuffer, _tbufferSize); } if (_keepSize) { _sbufferSize = _tbufferSize; _sbuffer = _tbuffer; _tbufferSize = 0; _tbuffer = 0; } else { processBuffer(); } return true; }
void Resources::addToCache(const Common::String &filename) { _cache.load(filename); // Check to see if the file is a library Common::SeekableReadStream *stream = load(filename); uint32 header = stream->readUint32BE(); if (header == MKTAG('L', 'I', 'B', 26)) loadLibraryIndex(filename, stream, false); else if (header == MKTAG('L', 'I', 'C', 26)) loadLibraryIndex(filename, stream, true); delete stream; }
void RivenGraphics::scheduleWaterEffect(uint16 sfxeID) { Common::SeekableReadStream *sfxeStream = _vm->getResource(ID_SFXE, sfxeID); if (sfxeStream->readUint16BE() != 'SL') error ("Unknown sfxe tag"); // Read in header info SFXERecord sfxeRecord; sfxeRecord.frameCount = sfxeStream->readUint16BE(); uint32 offsetTablePosition = sfxeStream->readUint32BE(); sfxeRecord.rect.left = sfxeStream->readUint16BE(); sfxeRecord.rect.top = sfxeStream->readUint16BE(); sfxeRecord.rect.right = sfxeStream->readUint16BE(); sfxeRecord.rect.bottom = sfxeStream->readUint16BE(); sfxeRecord.speed = sfxeStream->readUint16BE(); // Skip the rest of the fields... // Read in offsets sfxeStream->seek(offsetTablePosition); uint32 *frameOffsets = new uint32[sfxeRecord.frameCount]; for (uint16 i = 0; i < sfxeRecord.frameCount; i++) frameOffsets[i] = sfxeStream->readUint32BE(); sfxeStream->seek(frameOffsets[0]); // Read in the scripts for (uint16 i = 0; i < sfxeRecord.frameCount; i++) sfxeRecord.frameScripts.push_back(sfxeStream->readStream((i == sfxeRecord.frameCount - 1) ? sfxeStream->size() - frameOffsets[i] : frameOffsets[i + 1] - frameOffsets[i])); // Set it to the first frame sfxeRecord.curFrame = 0; sfxeRecord.lastFrameTime = 0; delete[] frameOffsets; delete sfxeStream; _waterEffects.push_back(sfxeRecord); }
/** * Restore overlay sprites from savefile * @param fHandle Savefile open for reading */ void loadOverlayFromSave(Common::SeekableReadStream &fHandle) { overlay tmp; fHandle.readUint32BE(); fHandle.readUint32BE(); tmp.objIdx = fHandle.readUint16BE(); tmp.type = fHandle.readUint16BE(); tmp.x = fHandle.readSint16BE(); tmp.y = fHandle.readSint16BE(); tmp.width = fHandle.readSint16BE(); tmp.color = fHandle.readSint16BE(); g_cine->_overlayList.push_back(tmp); }