本文整理汇总了C++中common::SeekableReadStream::read方法的典型用法代码示例。如果您正苦于以下问题:C++ SeekableReadStream::read方法的具体用法?C++ SeekableReadStream::read怎么用?C++ SeekableReadStream::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::SeekableReadStream
的用法示例。
在下文中一共展示了SeekableReadStream::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool T7GFont::load(Common::SeekableReadStream &stream) {
// Read the mapping of characters to glyphs
if (stream.read(_mapChar2Glyph, 128) < 128) {
error("Groovie::T7GFont: Couldn't read the character to glyph map");
return false;
}
// Calculate the number of glyphs
byte numGlyphs = 0;
for (int i = 0; i < 128; i++)
if (_mapChar2Glyph[i] >= numGlyphs)
numGlyphs = _mapChar2Glyph[i] + 1;
// Read the glyph offsets
uint16 *glyphOffsets = new uint16[numGlyphs];
for (int i = 0; i < numGlyphs; i++)
glyphOffsets[i] = stream.readUint16LE();
if (stream.eos()) {
error("Groovie::T7GFont: Couldn't read the glyph offsets");
delete[] glyphOffsets;
return false;
}
// Allocate the glyph data
delete[] _glyphs;
_glyphs = new Glyph[numGlyphs];
// Ensure we're ready to read the first glyph. (Most versions don't
// need it, but the russian one does. This fixes bug #3095031.)
stream.seek(glyphOffsets[0]);
// Read the glyphs
_maxHeight = _maxWidth = 0;
for (int i = 0; (i < numGlyphs) && !stream.eos(); i++) {
// Verify we're at the expected stream position
if (stream.pos() != glyphOffsets[i]) {
uint16 offset = glyphOffsets[i];
delete[] glyphOffsets;
error("Groovie::T7GFont: Glyph %d starts at %d but the current "
"offset is %d", i, offset, stream.pos());
return false;
}
// Read the glyph information
Glyph *g = &_glyphs[i];
g->width = stream.readByte();
g->julia = stream.readByte();
// Read the pixels data into a dynamic array (we don't know its length)
Common::Array<byte> data;
data.reserve(300);
byte b = stream.readByte();
while (!stream.eos() && (b != 0xFF)) {
data.push_back(b);
b = stream.readByte();
}
// Verify the pixel data size
assert (data.size() % g->width == 0);
g->height = data.size() / g->width;
// Copy the pixel data into the definitive static array
g->pixels = new byte[data.size()];
memcpy(g->pixels, data.begin(), data.size());
// Update the max values
if (g->width > _maxWidth)
_maxWidth = g->width;
if (g->height > _maxHeight)
_maxHeight = g->height;
}
delete[] glyphOffsets;
return true;
}
示例2: loadTempSaveOS
bool CineEngine::loadTempSaveOS(Common::SeekableReadStream &in) {
char musicName[13];
char bgNames[8][13];
// First check the temporary Operation Stealth savegame format header.
ChunkHeader hdr;
loadChunkHeader(in, hdr);
if (hdr.id != TEMP_OS_FORMAT_ID) {
warning("loadTempSaveOS: File has incorrect identifier. Not loading savegame");
return false;
} else if (hdr.version > CURRENT_OS_SAVE_VER) {
warning("loadTempSaveOS: Detected newer format version. Not loading savegame");
return false;
} else if ((int)hdr.version < (int)CURRENT_OS_SAVE_VER) {
warning("loadTempSaveOS: Detected older format version. Trying to load nonetheless. Things may break");
} else { // hdr.id == TEMP_OS_FORMAT_ID && hdr.version == CURRENT_OS_SAVE_VER
debug(3, "loadTempSaveOS: Found correct header (Both the identifier and version number match).");
}
// There shouldn't be any data in the header's chunk currently so it's an error if there is.
if (hdr.size > 0) {
warning("loadTempSaveOS: Format header's chunk seems to contain data so format is incorrect. Not loading savegame");
return false;
}
// Ok, so we've got a correct header for a temporary Operation Stealth savegame.
// Let's start loading the plain savegame data then.
currentDisk = in.readUint16BE();
in.read(currentPartName, 13);
in.read(currentPrcName, 13);
in.read(currentRelName, 13);
in.read(currentMsgName, 13);
// Load the 8 background names.
for (uint i = 0; i < 8; i++) {
in.read(bgNames[i], 13);
}
in.read(currentCtName, 13);
// Moved the loading of current procedure, relation,
// backgrounds and Ct here because if they were at the
// end of this function then the global scripts loading
// made an array out of bounds access. In the original
// game's disassembly these aren't here but at the end.
// The difference is probably in how we handle loading
// the global scripts and some other things (i.e. the
// loading routines aren't exactly the same and subtle
// semantic differences result in having to do things
// in a different order).
{
// Not sure if this is needed with Operation Stealth...
checkDataDisk(currentDisk);
if (strlen(currentPrcName)) {
loadPrc(currentPrcName);
}
if (strlen(currentRelName)) {
loadRel(currentRelName);
}
// Load first background (Uses loadBg)
if (strlen(bgNames[0])) {
loadBg(bgNames[0]);
}
// Add backgrounds 1-7 (Uses addBackground)
for (int i = 1; i < 8; i++) {
if (strlen(bgNames[i])) {
addBackground(bgNames[i], i);
}
}
if (strlen(currentCtName)) {
loadCtOS(currentCtName);
}
}
loadObjectTable(in);
renderer->restorePalette(in, hdr.version);
g_cine->_globalVars.load(in, NUM_MAX_VAR);
loadZoneData(in);
loadCommandVariables(in);
char tempCommandBuffer[kMaxCommandBufferSize];
in.read(tempCommandBuffer, kMaxCommandBufferSize);
g_cine->_commandBuffer = tempCommandBuffer;
renderer->setCommand(g_cine->_commandBuffer);
loadZoneQuery(in);
// TODO: Use the loaded string (Current music name (String, 13 bytes)).
in.read(musicName, 13);
// TODO: Use the loaded value (Is music loaded? (Uint16BE, Boolean)).
in.readUint16BE();
// TODO: Use the loaded value (Is music playing? (Uint16BE, Boolean)).
in.readUint16BE();
renderer->_cmdY = in.readUint16BE();
//.........这里部分代码省略.........
示例3: loadStream
bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
destroy();
if (stream.readByte() != 'B')
return false;
if (stream.readByte() != 'M')
return false;
/* uint32 fileSize = */ stream.readUint32LE();
/* uint16 res1 = */ stream.readUint16LE();
/* uint16 res2 = */ stream.readUint16LE();
uint32 imageOffset = stream.readUint32LE();
uint32 infoSize = stream.readUint32LE();
if (infoSize != 40) {
warning("Only Windows v3 bitmaps are supported");
return false;
}
uint32 width = stream.readUint32LE();
int32 height = stream.readSint32LE();
if (width == 0 || height == 0)
return false;
if (height < 0) {
warning("Right-side up bitmaps not supported");
return false;
}
/* uint16 planes = */ stream.readUint16LE();
uint16 bitsPerPixel = stream.readUint16LE();
if (bitsPerPixel != 8 && bitsPerPixel != 24 && bitsPerPixel != 32) {
warning("%dbpp bitmaps not supported", bitsPerPixel);
return false;
}
uint32 compression = stream.readUint32LE();
if (compression != 0) {
warning("Compressed bitmaps not supported");
return false;
}
/* uint32 imageSize = */ stream.readUint32LE();
/* uint32 pixelsPerMeterX = */ stream.readUint32LE();
/* uint32 pixelsPerMeterY = */ stream.readUint32LE();
_paletteColorCount = stream.readUint32LE();
/* uint32 colorsImportant = */ stream.readUint32LE();
if (bitsPerPixel == 8) {
if (_paletteColorCount == 0)
_paletteColorCount = 256;
// Read the palette
_palette = new byte[_paletteColorCount * 3];
for (uint16 i = 0; i < _paletteColorCount; i++) {
_palette[i * 3 + 2] = stream.readByte();
_palette[i * 3 + 1] = stream.readByte();
_palette[i * 3 + 0] = stream.readByte();
stream.readByte();
}
}
// Start us at the beginning of the image
stream.seek(imageOffset);
Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8();
// BGRA for 24bpp and 32 bpp
if (bitsPerPixel == 24 || bitsPerPixel == 32)
format = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0);
_surface = new Graphics::Surface();
_surface->create(width, height, format);
int srcPitch = width * (bitsPerPixel >> 3);
const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0;
if (bitsPerPixel == 8) {
byte *dst = (byte *)_surface->pixels;
for (int32 i = 0; i < height; i++) {
stream.read(dst + (height - i - 1) * width, width);
stream.skip(extraDataLength);
}
} else if (bitsPerPixel == 24) {
byte *dst = (byte *)_surface->pixels + (height - 1) * _surface->pitch;
for (int32 i = 0; i < height; i++) {
for (uint32 j = 0; j < width; j++) {
byte b = stream.readByte();
byte g = stream.readByte();
byte r = stream.readByte();
uint32 color = format.RGBToColor(r, g, b);
*((uint32 *)dst) = color;
dst += format.bytesPerPixel;
//.........这里部分代码省略.........
示例4: initGame
void Init::initGame() {
initVideo();
updateConfig();
if (!_vm->isDemo()) {
if (_vm->_dataIO->hasFile(_vm->_startStk))
_vm->_dataIO->openArchive(_vm->_startStk, true);
}
_vm->_util->initInput();
_vm->_video->initPrimary(_vm->_global->_videoMode);
_vm->_global->_mouseXShift = 1;
_vm->_global->_mouseYShift = 1;
_palDesc = new Video::PalDesc;
_vm->validateVideoMode(_vm->_global->_videoMode);
_vm->_global->_setAllPalette = true;
_palDesc->vgaPal = _vm->_draw->_vgaPalette;
_palDesc->unused1 = _vm->_draw->_unusedPalette1;
_palDesc->unused2 = _vm->_draw->_unusedPalette2;
_vm->_video->setFullPalette(_palDesc);
for (int i = 0; i < 10; i++)
_vm->_draw->_fascinWin[i].id = -1;
_vm->_draw->_winCount = 0;
for (int i = 0; i < 8; i++)
_vm->_draw->_fonts[i] = 0;
if (_vm->isDemo()) {
doDemo();
delete _palDesc;
_vm->_video->initPrimary(-1);
cleanup();
return;
}
if (_vm->_preGob) {
_vm->_preGob->run();
delete _palDesc;
_vm->_video->initPrimary(-1);
cleanup();
return;
}
Common::SeekableReadStream *infFile = _vm->_dataIO->getFile("intro.inf");
if (!infFile) {
for (int i = 0; i < 4; i++)
_vm->_draw->loadFont(i, _fontNames[i]);
} else {
for (int i = 0; i < 8; i++) {
if (infFile->eos())
break;
Common::String font = infFile->readLine();
if (infFile->eos() && font.empty())
break;
font += ".let";
_vm->_draw->loadFont(i, font.c_str());
}
delete infFile;
}
if (_vm->_dataIO->hasFile(_vm->_startTot)) {
_vm->_inter->allocateVars(Script::getVariablesCount(_vm->_startTot.c_str(), _vm));
_vm->_game->_curTotFile = _vm->_startTot;
_vm->_sound->cdTest(1, "GOB");
_vm->_sound->cdLoadLIC("gob.lic");
// Search for a Coktel logo animation or image to display
if (_vm->_dataIO->hasFile("coktel.imd")) {
_vm->_draw->initScreen();
_vm->_draw->_cursorIndex = -1;
_vm->_util->longDelay(200); // Letting everything settle
VideoPlayer::Properties props;
int slot;
if ((slot = _vm->_vidPlayer->openVideo(true, "coktel.imd", props)) >= 0) {
_vm->_vidPlayer->play(slot, props);
_vm->_vidPlayer->closeVideo(slot);
}
_vm->_draw->closeScreen();
} else if (_vm->_dataIO->hasFile("coktel.clt")) {
Common::SeekableReadStream *stream = _vm->_dataIO->getFile("coktel.clt");
if (stream) {
_vm->_draw->initScreen();
//.........这里部分代码省略.........
示例5: load
void ConversationData::load(const Common::String &filename) {
Common::File inFile;
char buffer[16];
inFile.open(filename);
MadsPack convFileUnpacked(&inFile);
// **** Section 0: Header *************************************************
Common::SeekableReadStream *convFile = convFileUnpacked.getItemStream(0);
_nodeCount = convFile->readUint16LE();
_dialogCount = convFile->readUint16LE();
_messageCount = convFile->readUint16LE();
_textLineCount = convFile->readUint16LE();
_unk2 = convFile->readUint16LE();
_maxImports = convFile->readUint16LE();
_speakerCount = convFile->readUint16LE();
for (uint idx = 0; idx < MAX_SPEAKERS; ++idx) {
convFile->read(buffer, 16);
_portraits[idx] = buffer;
}
for (uint idx = 0; idx < MAX_SPEAKERS; ++idx) {
_speakerFrame[idx] = convFile->readUint16LE();
}
convFile->read(buffer, 14);
_speechFile = Common::String(buffer);
// Total text length in section 5
_textSize = convFile->readUint32LE();
_commandsSize = convFile->readUint32LE();
// The rest of the section 0 is padding to allow room for a set of pointers
// to the contents of the remaining sections loaded into memory as a
// continuous data block containing both the header and the sections
delete convFile;
// **** Section 1: Nodes **************************************************
convFile = convFileUnpacked.getItemStream(1);
_nodes.clear();
for (uint i = 0; i < _nodeCount; i++) {
ConvNode node;
node._index = convFile->readUint16LE();
node._dialogCount = convFile->readUint16LE();
node._unk1 = convFile->readSint16LE(); // TODO
node._active = convFile->readSint16LE() != 0;
node._unk3 = convFile->readSint16LE(); // TODO
_nodes.push_back(node);
}
delete convFile;
// **** Section 2: Dialogs ************************************************
convFile = convFileUnpacked.getItemStream(2);
assert(convFile->size() == _dialogCount * 8);
_dialogs.resize(_dialogCount);
for (uint idx = 0; idx < _dialogCount; ++idx) {
_dialogs[idx]._textLineIndex = convFile->readSint16LE();
_dialogs[idx]._speechIndex = convFile->readSint16LE();
_dialogs[idx]._scriptOffset = convFile->readUint16LE();
_dialogs[idx]._scriptSize = convFile->readUint16LE();
}
delete convFile;
// **** Section 3: Messages ***********************************************
convFile = convFileUnpacked.getItemStream(3);
assert(convFile->size() == _messageCount * 4);
_messages.resize(_messageCount);
for (uint idx = 0; idx < _messageCount; ++idx) {
_messages[idx]._stringIndex = convFile->readUint16LE();
_messages[idx]._count = convFile->readUint16LE();
}
delete convFile;
// **** Section 4: Text line offsets **************************************
convFile = convFileUnpacked.getItemStream(4);
assert(convFile->size() == _textLineCount * 2);
uint16 *textLineOffsets = new uint16[_textLineCount]; // deleted below in section 5
for (uint16 i = 0; i < _textLineCount; i++)
textLineOffsets[i] = convFile->readUint16LE();
delete convFile;
// **** Section 5: Text lines *********************************************
convFile = convFileUnpacked.getItemStream(5);
assert(convFile->size() == _textSize);
Common::String textLine;
_textLines.resize(_textLineCount);
char textLineBuffer[256];
uint16 nextOffset;
for (uint16 i = 0; i < _textLineCount; i++) {
//.........这里部分代码省略.........
示例6: initSceneScript
void KyraEngine_MR::initSceneScript(int unk1) {
const SceneDesc &scene = _sceneList[_mainCharacter.sceneId];
char filename[16];
strcpy(filename, scene.filename1);
strcat(filename, ".DAT");
_res->exists(filename, true);
Common::SeekableReadStream *stream = _res->createReadStream(filename);
assert(stream);
stream->seek(2, SEEK_CUR);
byte scaleTable[15];
stream->read(scaleTable, 15);
stream->read(_sceneDatPalette, 45);
stream->read(_sceneDatLayerTable, 15);
int16 shapesCount = stream->readSint16LE();
for (int i = 0; i < 15; ++i)
_scaleTable[i] = (uint16(scaleTable[i]) << 8) / 100;
if (shapesCount > 0) {
strcpy(filename, scene.filename1);
strcat(filename, "9.CPS");
_screen->loadBitmap(filename, 3, 3, 0);
int pageBackUp = _screen->_curPage;
_screen->_curPage = 2;
for (int i = 0; i < shapesCount; ++i) {
int16 x = stream->readSint16LE();
int16 y = stream->readSint16LE();
int16 w = stream->readSint16LE();
int16 h = stream->readSint16LE();
_sceneShapeDescs[i].drawX = stream->readSint16LE();
_sceneShapeDescs[i].drawY = stream->readSint16LE();
_sceneShapes[i] = _screen->encodeShape(x, y, w, h, 0);
assert(_sceneShapes[i]);
}
_screen->_curPage = pageBackUp;
}
delete stream;
stream = 0;
strcpy(filename, scene.filename1);
strcat(filename, ".CPS");
_screen->loadBitmap(filename, 3, 3, 0);
Common::set_to(_specialSceneScriptState, ARRAYEND(_specialSceneScriptState), false);
_sceneEnterX1 = 160;
_sceneEnterY1 = 0;
_sceneEnterX2 = 296;
_sceneEnterY2 = 93;
_sceneEnterX3 = 160;
_sceneEnterY3 = 171;
_sceneEnterX4 = 24;
_sceneEnterY4 = 93;
_sceneMinX = 0;
_sceneMaxX = 319;
_emc->init(&_sceneScriptState, &_sceneScriptData);
strcpy(filename, scene.filename2);
strcat(filename, ".EMC");
_res->exists(filename, true);
_emc->load(filename, &_sceneScriptData, &_opcodes);
strcpy(filename, scene.filename2);
strcat(filename, ".");
loadLanguageFile(filename, _sceneStrings);
runSceneScript8();
_emc->start(&_sceneScriptState, 0);
_sceneScriptState.regs[0] = _mainCharacter.sceneId;
_sceneScriptState.regs[5] = unk1;
while (_emc->isValid(&_sceneScriptState))
_emc->run(&_sceneScriptState);
_screen->copyRegionToBuffer(3, 0, 0, 320, 200, _gamePlayBuffer);
for (int i = 0; i < 10; ++i) {
_emc->init(&_sceneSpecialScripts[i], &_sceneScriptData);
_emc->start(&_sceneSpecialScripts[i], i+9);
_sceneSpecialScriptsTimer[i] = 0;
}
_sceneEnterX1 &= ~3;
_sceneEnterY1 &= ~1;
_sceneEnterX2 &= ~3;
_sceneEnterY2 &= ~1;
_sceneEnterX3 &= ~3;
_sceneEnterY3 &= ~1;
_sceneEnterX4 &= ~3;
_sceneEnterY4 &= ~1;
}
示例7: fadeRead
int Screen::fadeRead(Common::SeekableReadStream &stream, byte *buf, int totalSize) {
warning("TODO: fadeRead");
stream.read(buf, totalSize);
return totalSize;
}
示例8: testFileSystem
// This function leaks. For now I don't care
bool PspUnitTests::testFileSystem() {
// create memory
const uint32 BufSize = 32 * 1024;
char* buffer = new char[BufSize];
int i;
Common::WriteStream *wrStream;
Common::SeekableReadStream *rdStream;
PSP_INFO_PRINT("testing fileSystem...\n");
// fill buffer
for (i=0; i<(int)BufSize; i += 4) {
buffer[i] = 'A';
buffer[i + 1] = 'B';
buffer[i + 2] = 'C';
buffer[i + 3] = 'D';
}
// create a file
const char *path = "./file.test";
Common::FSNode file(path);
PSP_INFO_PRINT("creating write stream...\n");
wrStream = file.createWriteStream();
if (!wrStream) {
PSP_ERROR("%s couldn't be created.\n", path);
return false;
}
// write contents
char* index = buffer;
int32 totalLength = BufSize;
int32 curLength = 50;
PSP_INFO_PRINT("writing...\n");
while(totalLength - curLength > 0) {
if ((int)wrStream->write(index, curLength) != curLength) {
PSP_ERROR("couldn't write %d bytes\n", curLength);
return false;
}
totalLength -= curLength;
index += curLength;
//curLength *= 2;
//PSP_INFO_PRINT("write\n");
}
// write the rest
if ((int)wrStream->write(index, totalLength) != totalLength) {
PSP_ERROR("couldn't write %d bytes\n", curLength);
return false;
}
delete wrStream;
PSP_INFO_PRINT("reading...\n");
rdStream = file.createReadStream();
if (!rdStream) {
PSP_ERROR("%s couldn't be created.\n", path);
return false;
}
// seek to beginning
if (!rdStream->seek(0, SEEK_SET)) {
PSP_ERROR("couldn't seek to the beginning after writing the file\n");
return false;
}
// read the contents
char *readBuffer = new char[BufSize + 4];
memset(readBuffer, 0, (BufSize + 4));
index = readBuffer;
while (rdStream->read(index, 100) == 100) {
index += 100;
}
if (!rdStream->eos()) {
PSP_ERROR("didn't find EOS at end of stream\n");
return false;
}
// compare
for (i=0; i<(int)BufSize; i++)
if (buffer[i] != readBuffer[i]) {
PSP_ERROR("reading/writing mistake at %x. Got %x instead of %x\n", i, readBuffer[i], buffer[i]);
return false;
}
// Check for exceeding limit
for (i=0; i<4; i++) {
if (readBuffer[BufSize + i]) {
PSP_ERROR("read exceeded limits. %d = %x\n", BufSize + i, readBuffer[BufSize + i]);
}
}
delete rdStream;
//.........这里部分代码省略.........
示例9: initialise
/**
* Initialises and loads the data of an animation
*/
void MadsAnimation::initialise(const Common::String &filename, uint16 flags, M4Surface *surface, M4Surface *depthSurface) {
MadsPack anim(filename.c_str(), _vm);
bool madsRes = filename[0] == '*';
char buffer[20];
int streamIndex = 1;
// Chunk 1: header
// header
Common::SeekableReadStream *animStream = anim.getItemStream(0);
int spriteListCount = animStream->readUint16LE();
int miscEntriesCount = animStream->readUint16LE();
int frameEntryCount = animStream->readUint16LE();
int messagesCount = animStream->readUint16LE();
animStream->skip(1);
_flags = animStream->readByte();
animStream->skip(2);
_animMode = animStream->readUint16LE();
_roomNumber = animStream->readUint16LE();
animStream->skip(2);
_field12 = animStream->readUint16LE() != 0;
_spriteListIndex = animStream->readUint16LE();
_scrollX = animStream->readSint16LE();
_scrollY = animStream->readSint16LE();
_scrollTicks = animStream->readUint16LE();
animStream->skip(8);
animStream->read(buffer, FILENAME_SIZE);
buffer[FILENAME_SIZE] = '\0';
_interfaceFile = Common::String(buffer);
for (int i = 0; i < 10; ++i) {
animStream->read(buffer, FILENAME_SIZE);
buffer[FILENAME_SIZE] = '\0';
_spriteSetNames[i] = Common::String(buffer);
}
animStream->skip(81);
animStream->read(buffer, FILENAME_SIZE);
buffer[FILENAME_SIZE] = '\0';
_lbmFilename = Common::String(buffer);
animStream->skip(365);
animStream->read(buffer, FILENAME_SIZE);
buffer[FILENAME_SIZE] = '\0';
_spritesFilename = Common::String(buffer);
animStream->skip(48);
animStream->read(buffer, FILENAME_SIZE);
buffer[FILENAME_SIZE] = '\0';
_soundName = Common::String(buffer);
animStream->skip(13);
animStream->read(buffer, FILENAME_SIZE);
buffer[FILENAME_SIZE] = '\0';
_dsrName = Common::String(buffer);
animStream->read(buffer, FILENAME_SIZE);
buffer[FILENAME_SIZE] = '\0';
Common::String fontResource(buffer);
if (_animMode == 4)
flags |= 0x4000;
if (flags & 0x100)
loadInterface(surface, depthSurface);
// Initialise the reference list
for (int i = 0; i < spriteListCount; ++i)
_spriteListIndexes.push_back(-1);
delete animStream;
if (messagesCount > 0) {
// Chunk 2
// Following is a list of any messages for the animation
animStream = anim.getItemStream(streamIndex++);
for (int i = 0; i < messagesCount; ++i) {
AnimMessage rec;
rec.soundId = animStream->readSint16LE();
animStream->read(rec.msg, 64);
animStream->skip(4);
rec.pos.x = animStream->readSint16LE();
rec.pos.y = animStream->readSint16LE();
rec.flags = animStream->readUint16LE();
rec.rgb1.r = animStream->readByte() << 2;
rec.rgb1.g = animStream->readByte() << 2;
rec.rgb1.b = animStream->readByte() << 2;
rec.rgb2.r = animStream->readByte() << 2;
rec.rgb2.g = animStream->readByte() << 2;
rec.rgb2.b = animStream->readByte() << 2;
animStream->skip(2); // Space for kernelMsgIndex
rec.kernelMsgIndex = -1;
animStream->skip(6);
//.........这里部分代码省略.........
示例10: loadGamePcFile
void AGOSEngine::loadGamePcFile() {
Common::SeekableReadStream *in;
int fileSize;
if (getFileName(GAME_BASEFILE) != NULL) {
/* Read main gamexx file */
in = _archives.open(getFileName(GAME_BASEFILE));
if (!in) {
error("loadGamePcFile: Can't load gamexx file '%s'", getFileName(GAME_BASEFILE));
}
if (getFeatures() & GF_CRUNCHED_GAMEPC) {
uint srcSize = in->size();
byte *srcBuf = (byte *)malloc(srcSize);
in->read(srcBuf, srcSize);
uint dstSize = READ_BE_UINT32(srcBuf + srcSize - 4);
byte *dstBuf = (byte *)malloc(dstSize);
decrunchFile(srcBuf, dstBuf, srcSize);
free(srcBuf);
Common::MemoryReadStream stream(dstBuf, dstSize);
readGamePcFile(&stream);
free(dstBuf);
} else {
readGamePcFile(in);
}
delete in;
}
if (getFileName(GAME_TBLFILE) != NULL) {
/* Read list of TABLE resources */
in = _archives.open(getFileName(GAME_TBLFILE));
if (!in) {
error("loadGamePcFile: Can't load table resources file '%s'", getFileName(GAME_TBLFILE));
}
fileSize = in->size();
_tblList = (byte *)malloc(fileSize);
if (_tblList == NULL)
error("loadGamePcFile: Out of memory for strip table list");
in->read(_tblList, fileSize);
delete in;
/* Remember the current state */
_subroutineListOrg = _subroutineList;
_tablesHeapPtrOrg = _tablesHeapPtr;
_tablesHeapCurPosOrg = _tablesHeapCurPos;
}
if (getFileName(GAME_STRFILE) != NULL) {
/* Read list of TEXT resources */
in = _archives.open(getFileName(GAME_STRFILE));
if (!in)
error("loadGamePcFile: Can't load text resources file '%s'", getFileName(GAME_STRFILE));
fileSize = in->size();
_strippedTxtMem = (byte *)malloc(fileSize);
if (_strippedTxtMem == NULL)
error("loadGamePcFile: Out of memory for strip text list");
in->read(_strippedTxtMem, fileSize);
delete in;
}
if (getFileName(GAME_STATFILE) != NULL) {
/* Read list of ROOM STATE resources */
in = _archives.open(getFileName(GAME_STATFILE));
if (!in) {
error("loadGamePcFile: Can't load state resources file '%s'", getFileName(GAME_STATFILE));
}
_numRoomStates = in->size() / 8;
_roomStates = (RoomState *)calloc(_numRoomStates, sizeof(RoomState));
if (_roomStates == NULL)
error("loadGamePcFile: Out of memory for room state list");
for (uint s = 0; s < _numRoomStates; s++) {
uint16 num = in->readUint16BE() - (_itemArrayInited - 2);
_roomStates[num].state = in->readUint16BE();
_roomStates[num].classFlags = in->readUint16BE();
_roomStates[num].roomExitStates = in->readUint16BE();
}
delete in;
}
if (getFileName(GAME_RMSLFILE) != NULL) {
/* Read list of ROOM ITEMS resources */
in = _archives.open(getFileName(GAME_RMSLFILE));
if (!in) {
error("loadGamePcFile: Can't load room resources file '%s'", getFileName(GAME_RMSLFILE));
}
fileSize = in->size();
_roomsList = (byte *)malloc(fileSize);
if (_roomsList == NULL)
error("loadGamePcFile: Out of memory for room items list");
//.........这里部分代码省略.........
示例11:
ASFGUID(Common::SeekableReadStream &stream) {
stream.read(id, 16);
}
示例12: loadPlainSaveFW
bool CineEngine::loadPlainSaveFW(Common::SeekableReadStream &in, CineSaveGameFormat saveGameFormat) {
char bgName[13];
// At savefile position 0x0000:
currentDisk = in.readUint16BE();
// At 0x0002:
in.read(currentPartName, 13);
// At 0x000F:
in.read(currentDatName, 13);
// At 0x001C:
musicIsPlaying = in.readSint16BE();
// At 0x001E:
in.read(currentPrcName, 13);
// At 0x002B:
in.read(currentRelName, 13);
// At 0x0038:
in.read(currentMsgName, 13);
// At 0x0045:
in.read(bgName, 13);
// At 0x0052:
in.read(currentCtName, 13);
checkDataDisk(currentDisk);
if (strlen(currentPartName)) {
loadPart(currentPartName);
}
if (strlen(currentPrcName)) {
loadPrc(currentPrcName);
}
if (strlen(currentRelName)) {
loadRel(currentRelName);
}
if (strlen(bgName)) {
loadBg(bgName);
}
if (strlen(currentCtName)) {
loadCtFW(currentCtName);
}
// At 0x005F:
loadObjectTable(in);
// At 0x2043 (i.e. 0x005F + 2 * 2 + 255 * 32):
renderer->restorePalette(in, 0);
// At 0x2083 (i.e. 0x2043 + 16 * 2 * 2):
g_cine->_globalVars.load(in, NUM_MAX_VAR);
// At 0x2281 (i.e. 0x2083 + 255 * 2):
loadZoneData(in);
// At 0x22A1 (i.e. 0x2281 + 16 * 2):
loadCommandVariables(in);
// At 0x22A9 (i.e. 0x22A1 + 4 * 2):
char tempCommandBuffer[kMaxCommandBufferSize];
in.read(tempCommandBuffer, kMaxCommandBufferSize);
g_cine->_commandBuffer = tempCommandBuffer;
renderer->setCommand(g_cine->_commandBuffer);
// At 0x22F9 (i.e. 0x22A9 + 0x50):
renderer->_cmdY = in.readUint16BE();
// At 0x22FB:
bgVar0 = in.readUint16BE();
// At 0x22FD:
allowPlayerInput = in.readUint16BE();
// At 0x22FF:
playerCommand = in.readSint16BE();
// At 0x2301:
commandVar1 = in.readSint16BE();
// At 0x2303:
isDrawCommandEnabled = in.readUint16BE();
// At 0x2305:
var5 = in.readUint16BE();
// At 0x2307:
var4 = in.readUint16BE();
// At 0x2309:
var3 = in.readUint16BE();
// At 0x230B:
var2 = in.readUint16BE();
// At 0x230D:
commandVar2 = in.readSint16BE();
// At 0x230F:
renderer->_messageBg = in.readUint16BE();
// At 0x2311:
in.readUint16BE();
// At 0x2313:
in.readUint16BE();
//.........这里部分代码省略.........
示例13: importOriginalSaveFile
bool EoBCoreEngine::importOriginalSaveFile(int destSlot, const char *sourceFile) {
Common::Array<Common::String> origFiles;
Common::Array<int> newSlots;
if (sourceFile) {
// If a source file is specified via the console command we just check whether it exists.
if (Common::File::exists(sourceFile))
origFiles.push_back(sourceFile);
else
return false;
} else {
// Check for original save files in the game path (usually at least the "Quick Start Party" file will be present).
int numMax = (_flags.gameID == GI_EOB1) ? 1 : 6;
const char *pattern = (_flags.gameID == GI_EOB1) ? "EOBDATA.SAV" : "EOBDATA%d.SAV";
for (int i = 0; i < numMax; ++i) {
Common::String temp = Common::String::format(pattern, i);
Common::SeekableReadStream *fs = _res->createReadStream(temp);
if (fs) {
Common::String dsc;
if (_flags.gameID == GI_EOB2) {
char descStr[20];
fs->read(descStr, 20);
dsc = Common::String::format("(\"%s\")", descStr).c_str();
}
delete fs;
::GUI::MessageDialog dialog(Common::String::format(_("The following original save game file has been found in your game path:\n\n%s %s\n\nDo you wish to use this save game file with ScummVM?\n\n"), temp.c_str(), dsc.c_str()), _("Yes"), _("No"));
if (dialog.runModal())
origFiles.push_back(temp);
}
}
}
int numFilesFound = origFiles.size();
if (!numFilesFound)
return false;
_gui->updateSaveSlotsList(_targetName, true);
// Find free save slots for the original save files
if (destSlot == -1) {
int assignedSlots = 0;
for (int testSlot = 0; testSlot < 990 && assignedSlots < numFilesFound; testSlot++) {
if (Common::find(_gui->_saveSlots.begin(), _gui->_saveSlots.end(), testSlot) == _gui->_saveSlots.end()) {
newSlots.push_back(testSlot);
assignedSlots++;
}
}
// This will probably never happen, since we do have 990 save slots
if (assignedSlots != numFilesFound)
warning("%d original save files could not be converted due to missing save game slots", numFilesFound - assignedSlots);
} else {
newSlots.push_back(destSlot);
}
if (destSlot != -1) {
if (Common::find(_gui->_saveSlots.begin(), _gui->_saveSlots.end(), destSlot) != _gui->_saveSlots.end()) {
::GUI::MessageDialog dialog(Common::String::format(_("A save game file was found in the specified slot %d. Overwrite?\n\n"), destSlot), _("Yes"), _("No"));
if (!dialog.runModal())
return false;
}
}
int importedCount = 0;
for (int i = 0; i < numFilesFound; i++) {
Common::String desc = readOriginalSaveFile(origFiles[i]);
if (desc.empty()) {
warning("Unable to import original save file '%s'", origFiles[i].c_str());
} else {
// We can't make thumbnails here, since we do not want to load all the level data, monsters, etc. for each save we convert.
// Instead, we use an empty surface to avoid that createThumbnailFromScreen() makes a completely pointless thumbnail from
// whatever screen that is currently shown when this function is called.
Graphics::Surface dummy;
saveGameStateIntern(newSlots[i], desc.c_str(), &dummy);
warning("Imported original save file '%s' ('%s')", origFiles[i].c_str(), desc.c_str());
importedCount++;
}
}
_currentLevel = 0;
_currentSub = 0;
_currentBlock = 0;
_currentDirection = 0;
_itemInHand = 0;
_hasTempDataFlags = 0;
_partyEffectFlags = 0;
memset(_characters, 0, sizeof(EoBCharacter) * 6);
_inf->reset();
if (destSlot == -1 && importedCount) {
::GUI::MessageDialog dialog(Common::String::format(_("%d original save game files have been successfully imported into\nScummVM. If you want to manually import original save game files later you will\nneed to open the ScummVM debug console and use the command 'import_savefile'.\n\n"), importedCount));
dialog.runModal();
}
return true;
}
示例14: loadResourcesFromSave
/**
* 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 currentAnim, 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();
currentAnim = 0;
while (currentAnim < NUM_MAX_ANIMDATA) {
// Seek to the start of the current animation's entry
fHandle.seek(fileStartPos + currentAnim * 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();
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) {
currentAnim++; // Jump over the invalid entry
continue;
}
// Alright, the animation entry looks to be valid so let's start handling it...
if (strcmp(currentPartName, name)) {
closePart();
loadPart(name);
}
animName = g_cine->_partBuffer[foundFileIdx].partName;
loadRelatedPalette(animName); // Is this for Future Wars only?
const int16 prevAnim = currentAnim;
currentAnim = loadResource(animName, currentAnim);
assert(currentAnim > prevAnim); // Make sure we advance forward
}
loadPart(part);
// Make sure we jump over all the animation entries
fHandle.seek(fileStartPos + NUM_MAX_ANIMDATA * entrySize);
}
示例15: loadFile
bool BinkPlayer::loadFile(const Common::String &filename) {
_fname = filename;
if (_demo) {
// The demo uses a .lab suffix
_fname += ".lab";
return MoviePlayer::loadFile(_fname);
}
_fname += ".m4b";
Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(_fname);
if (!stream) {
warning("BinkPlayer::loadFile(): Can't create stream for: %s", _fname.c_str());
return false;
}
// set the default start of the bink video in case there is no SMUSH header
uint32 startBinkPos = 0x0;
// clear existing subtitles
_subtitles.clear();
char header[6];
// read the first 5 bytes of the header
stream->read(header, 5);
header[5] = 0;
if (!strcmp(header, "SMUSH")) {
// handle SMUSH header
unsigned char smushHeader[0x2000];
// read the first part
uint32 consumed = 16;
stream->read(smushHeader, consumed);
// decode the first part
for (unsigned int i = 0; i < consumed; i++) {
smushHeader[i] ^= 0xd2;
}
Common::MemoryReadStream msStart(smushHeader, consumed);
TextSplitter tsStart("", &msStart);
// extract the length / the start of the following BINK header
tsStart.scanString("%d", 1, &startBinkPos);
assert(startBinkPos < sizeof(smushHeader));
// read the rest (5 bytes less because of the string "SMUSH" at the beginning)
stream->read(smushHeader+consumed, startBinkPos - consumed - 5);
// decode the reset
for (unsigned int i = consumed; i < startBinkPos - 5; i++) {
smushHeader[i] ^= 0xd2;
}
consumed = startBinkPos - 5;
Common::MemoryReadStream msSmush(smushHeader, consumed);
TextSplitter tsSmush("", &msSmush);
// skip the first line which contains the length
tsSmush.nextLine();
tsSmush.expectString("BEGINDATA");
while (!tsSmush.checkString("ENDOFDATA")) {
unsigned int start, end;
char textId[256];
// extract single subtitle entry
tsSmush.scanString("%d\t%d\t%s", 3, &start, &end, textId);
Subtitle st(start, end, textId);
_subtitles.push_back(st);
}
tsSmush.expectString("ENDOFDATA");
}
// set current subtitle index to the first subtitle
_subtitleIndex = _subtitles.begin();
if (!bikCheck(stream, startBinkPos)) {
warning("BinkPlayer::loadFile(): Could not find BINK header for: %s", _fname.c_str());
delete stream;
return false;
}
Common::SeekableReadStream *bink = nullptr;
bink = new Common::SeekableSubReadStream(stream, startBinkPos, stream->size(), DisposeAfterUse::YES);
_videoDecoder->setDefaultHighColorFormat(Graphics::PixelFormat(4, 8, 8, 8, 0, 8, 16, 24, 0));
return _videoDecoder->loadStream(bink);
}