本文整理汇总了C++中common::SeekableReadStream类的典型用法代码示例。如果您正苦于以下问题:C++ SeekableReadStream类的具体用法?C++ SeekableReadStream怎么用?C++ SeekableReadStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SeekableReadStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void ActorType::load(byte *dataStart, Common::SeekableReadStream &stream) {
_actorTypeId = stream.readUint32LE();
_surfInfo.load(stream);
uint32 pointsConfigOffs = stream.readUint32LE();
uint namedPointsCount = stream.readUint16LE();
stream.skip(2); // Skip padding
uint32 namedPointsOffs = stream.readUint32LE();
_color.r = stream.readByte();
_color.g = stream.readByte();
_color.b = stream.readByte();
stream.readByte(); // Skip padding
_scale = stream.readByte();
_priority = stream.readByte();
_value1E = stream.readUint16LE();
_pathWalkPointsIndex = stream.readUint16LE();
_scaleLayerIndex = stream.readUint16LE();
_pathWalkRectIndex = stream.readUint16LE();
_priorityLayerIndex = stream.readUint16LE();
_regionLayerIndex = stream.readUint16LE();
_flags = stream.readUint16LE();
_pointsConfig = dataStart + pointsConfigOffs;
stream.seek(namedPointsOffs);
_namedPoints.load(namedPointsCount, stream);
debug(5, "ActorType::load() _actorTypeId: %08X; _color(%d,%d,%d); _scale: %d; _priority: %d; _value1E: %d",
_actorTypeId, _color.r, _color.g, _color.b, _scale, _priority, _value1E);
debug(5, "ActorType::load() _pathWalkPointsIndex: %d; _scaleLayerIndex: %d; _pathWalkRectIndex: %d",
_pathWalkPointsIndex, _scaleLayerIndex, _pathWalkRectIndex);
debug(5, "ActorType::load() _priorityLayerIndex: %d; _regionLayerIndex: %d; _flags: %04X",
_priorityLayerIndex, _regionLayerIndex,_flags);
}
示例2: load
void ImageFile::load(Common::SeekableReadStream &stream, bool skipPalette, bool animImages) {
loadPalette(stream);
int streamSize = stream.size();
while (stream.pos() < streamSize) {
ImageFrame frame;
frame._width = stream.readUint16LE() + 1;
frame._height = stream.readUint16LE() + 1;
frame._paletteBase = stream.readByte();
if (animImages) {
// Animation cutscene image files use a 16-bit x offset
frame._offset.x = stream.readUint16LE();
frame._rleEncoded = (frame._offset.x & 0xff) == 1;
frame._offset.y = stream.readByte();
} else {
// Standard image files have a separate byte for the RLE flag, and an 8-bit X offset
frame._rleEncoded = stream.readByte() == 1;
frame._offset.x = stream.readByte();
frame._offset.y = stream.readByte();
}
frame._rleEncoded = !skipPalette && frame._rleEncoded;
if (frame._paletteBase) {
// Nibble packed frame data
frame._size = (frame._width * frame._height) / 2;
} else if (frame._rleEncoded) {
// This size includes the header size, which we subtract
frame._size = stream.readUint16LE() - 11;
frame._rleMarker = stream.readByte();
} else {
// Uncompressed data
frame._size = frame._width * frame._height;
}
// Load data for frame and decompress it
byte *data = new byte[frame._size + 4];
stream.read(data, frame._size);
Common::fill(data + frame._size, data + frame._size + 4, 0);
frame.decompressFrame(data, IS_ROSE_TATTOO);
delete[] data;
push_back(frame);
}
}
示例3: readDataRLE
bool TGADecoder::readDataRLE(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth) {
// RLE-TrueColor / RLE-Black/White
if (imageType == TYPE_RLE_TRUECOLOR || imageType == TYPE_RLE_BW || imageType == TYPE_RLE_CMAP) {
_surface.create(_surface.w, _surface.h, _format);
uint32 count = _surface.w * _surface.h;
byte *data = (byte *)_surface.getPixels();
while (count > 0) {
uint32 header = tga.readByte();
byte type = (header & 0x80) >> 7;
uint32 rleCount = (header & 0x7F) + 1;
// RLE-packet
if (type == 1) {
if (pixelDepth == 32 && imageType == TYPE_RLE_TRUECOLOR) {
uint32 color = tga.readUint32LE();
while (rleCount-- > 0) {
*((uint32 *)data) = color;
data += 4;
count--;
}
} else if (pixelDepth == 24 && imageType == TYPE_RLE_TRUECOLOR) {
byte r = tga.readByte();
byte g = tga.readByte();
byte b = tga.readByte();
while (rleCount-- > 0) {
#ifdef SCUMM_LITTLE_ENDIAN
*data++ = r;
*data++ = g;
*data++ = b;
#else
*data++ = b;
*data++ = g;
*data++ = r;
#endif
count--;
}
} else if (pixelDepth == 16 && imageType == TYPE_RLE_TRUECOLOR) {
const uint16 rgb = tga.readUint16LE();
while (rleCount-- > 0) {
*((uint16 *)data) = rgb;
data += 2;
count--;
}
} else if (pixelDepth == 8 && imageType == TYPE_RLE_BW) {
byte color = tga.readByte();
while (rleCount-- > 0) {
*data++ = color;
*data++ = color;
*data++ = color;
*data++ = color;
count--;
}
} else if (pixelDepth == 8 && imageType == TYPE_RLE_CMAP) {
byte index = tga.readByte();
while (rleCount-- > 0) {
*data++ = index;
count--;
}
} else {
warning("Unhandled pixel-depth for image-type 10");
return false;
}
// Raw-packet
} else if (type == 0) {
if (pixelDepth == 32 && imageType == TYPE_RLE_TRUECOLOR) {
while (rleCount-- > 0) {
uint32 color = tga.readUint32LE();
*((uint32 *)data) = color;
data += 4;
count--;
}
} else if (pixelDepth == 24 && imageType == TYPE_RLE_TRUECOLOR) {
while (rleCount-- > 0) {
byte r = tga.readByte();
byte g = tga.readByte();
byte b = tga.readByte();
#ifdef SCUMM_LITTLE_ENDIAN
*data++ = r;
*data++ = g;
*data++ = b;
#else
*data++ = b;
*data++ = g;
*data++ = r;
#endif
count--;
}
} else if (pixelDepth == 16 && imageType == TYPE_RLE_TRUECOLOR) {
while (rleCount-- > 0) {
*((uint16 *)data) = tga.readUint16LE();
data += 2;
count--;
}
} else if (pixelDepth == 8 && imageType == TYPE_RLE_BW) {
while (rleCount-- > 0) {
byte color = tga.readByte();
*data++ = color;
*data++ = color;
*data++ = color;
//.........这里部分代码省略.........
示例4: saveGame
bool PersistenceService::saveGame(uint slotID, const Common::String &screenshotFilename) {
// FIXME: This code is a hack which bypasses the savefile API,
// and should eventually be removed.
// Überprüfen, ob die Slot-ID zulässig ist.
if (slotID >= SLOT_COUNT) {
error("Tried to save to an invalid slot (%d). Only slot ids form 0 to %d are allowed.", slotID, SLOT_COUNT - 1);
return false;
}
// Dateinamen erzeugen.
Common::String filename = generateSavegameFilename(slotID);
// Spielstanddatei öffnen und die Headerdaten schreiben.
Common::SaveFileManager *sfm = g_system->getSavefileManager();
Common::OutSaveFile *file = sfm->openForSaving(filename);
file->writeString(FILE_MARKER);
file->writeByte(0);
file->writeString(VERSIONID);
file->writeByte(0);
char buf[20];
snprintf(buf, 20, "%d", VERSIONNUM);
file->writeString(buf);
file->writeByte(0);
TimeDate dt;
g_system->getTimeAndDate(dt);
file->writeString(formatTimestamp(dt));
file->writeByte(0);
if (file->err()) {
error("Unable to write header data to savegame file \"%s\".", filename.c_str());
}
// Alle notwendigen Module persistieren.
OutputPersistenceBlock writer;
bool success = true;
success &= Kernel::getInstance()->getScript()->persist(writer);
success &= RegionRegistry::instance().persist(writer);
success &= Kernel::getInstance()->getGfx()->persist(writer);
success &= Kernel::getInstance()->getSfx()->persist(writer);
success &= Kernel::getInstance()->getInput()->persist(writer);
if (!success) {
error("Unable to persist modules for savegame file \"%s\".", filename.c_str());
}
// Write the save game data uncompressed, since the final saved game will be
// compressed anyway.
char sBuffer[10];
snprintf(sBuffer, 10, "%u", writer.getDataSize());
file->writeString(sBuffer);
file->writeByte(0);
snprintf(sBuffer, 10, "%u", writer.getDataSize());
file->writeString(sBuffer);
file->writeByte(0);
file->write(writer.getData(), writer.getDataSize());
// Get the screenshot
Common::SeekableReadStream *thumbnail = Kernel::getInstance()->getGfx()->getThumbnail();
if (thumbnail) {
byte *buffer = new byte[FILE_COPY_BUFFER_SIZE];
thumbnail->seek(0, SEEK_SET);
while (!thumbnail->eos()) {
int bytesRead = thumbnail->read(&buffer[0], FILE_COPY_BUFFER_SIZE);
file->write(&buffer[0], bytesRead);
}
delete[] buffer;
} else {
warning("The screenshot file \"%s\" does not exist. Savegame is written without a screenshot.", filename.c_str());
}
file->finalize();
delete file;
// Savegameinformationen für diesen Slot aktualisieren.
_impl->readSlotSavegameInformation(slotID);
// Empty the cache, to remove old thumbnails
Kernel::getInstance()->getResourceManager()->emptyThumbnailCache();
// Erfolg signalisieren.
return true;
}
示例5: show
int TattooMap::show() {
Debugger &debugger = *_vm->_debugger;
Events &events = *_vm->_events;
Music &music = *_vm->_music;
Resources &res = *_vm->_res;
TattooScene &scene = *(TattooScene *)_vm->_scene;
Screen &screen = *_vm->_screen;
int result = 0;
// Check if we need to keep track of how many times player has been to the map
for (uint idx = 0; idx < scene._sceneTripCounters.size(); ++idx) {
SceneTripEntry &entry = scene._sceneTripCounters[idx];
if (entry._sceneNumber == OVERHEAD_MAP || entry._sceneNumber == OVERHEAD_MAP2) {
if (--entry._numTimes == 0) {
_vm->setFlagsDirect(entry._flag);
scene._sceneTripCounters.remove_at(idx);
}
}
}
if (music._midiOption) {
// See if Holmes or Watson is the active character
Common::String song;
if (_vm->readFlags(FLAG_PLAYER_IS_HOLMES))
// Player is Holmes
song = "Cue9";
else if (_vm->readFlags(FLAG_ALT_MAP_MUSIC))
song = "Cue8";
else
song = "Cue7";
if (music.loadSong(song)) {
music.setMIDIVolume(music._musicVolume);
if (music._musicOn)
music.startSong();
}
}
screen.initPaletteFade(1364485);
// Load the custom mouse cursors for the map
ImageFile cursors("omouse.vgs");
events.setCursor(cursors[0]._frame);
events.warpMouse(Common::Point(SHERLOCK_SCREEN_WIDTH / 2, SHERLOCK_SCREEN_HEIGHT / 2));
// Load the data for the map
_iconImages = new ImageFile("mapicons.vgs");
loadData();
// Load the palette
Common::SeekableReadStream *stream = res.load("map.pal");
stream->read(screen._cMap, PALETTE_SIZE);
screen.translatePalette(screen._cMap);
delete stream;
// Load the map image and draw it to the back buffer
ImageFile *map = new ImageFile("map.vgs");
screen._backBuffer1.create(SHERLOCK_SCREEN_WIDTH * 2, SHERLOCK_SCREEN_HEIGHT * 2);
screen._backBuffer1.blitFrom((*map)[0], Common::Point(0, 0));
delete map;
screen.clear();
screen.setPalette(screen._cMap);
drawMapIcons();
// Copy the map drawn in the back buffer to the secondary back buffer
screen._backBuffer2.create(SHERLOCK_SCREEN_WIDTH * 2, SHERLOCK_SCREEN_HEIGHT * 2);
screen._backBuffer2.blitFrom(screen._backBuffer1);
// Display the built map to the screen
screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
// Set initial scroll position
_targetScroll = _bigPos;
screen._currentScroll = Common::Point(-1, -1);
do {
// Allow for event processing and get the current mouse position
events.pollEventsAndWait();
events.setButtonState();
Common::Point mousePos = events.screenMousePos();
if (debugger._showAllLocations == LOC_REFRESH) {
drawMapIcons();
screen.slamArea(screen._currentScroll.x, screen._currentScroll.y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_WIDTH);
}
checkMapNames(true);
if (mousePos.x < (SHERLOCK_SCREEN_WIDTH / 6))
_targetScroll.x -= 2 * SCROLL_SPEED * (SHERLOCK_SCREEN_WIDTH / 6 - mousePos.x) / (SHERLOCK_SCREEN_WIDTH / 6);
if (mousePos.x > (SHERLOCK_SCREEN_WIDTH * 5 / 6))
_targetScroll.x += 2 * SCROLL_SPEED * (mousePos.x - (SHERLOCK_SCREEN_WIDTH * 5 / 6)) / (SHERLOCK_SCREEN_WIDTH / 6);
if (mousePos.y < (SHERLOCK_SCREEN_HEIGHT / 6))
_targetScroll.y -= 2 * SCROLL_SPEED * (SHERLOCK_SCREEN_HEIGHT / 6 - mousePos.y) / (SHERLOCK_SCREEN_HEIGHT / 6);
if (mousePos.y > (SHERLOCK_SCREEN_HEIGHT * 5 / 6))
_targetScroll.y += 2 * SCROLL_SPEED * (mousePos.y - SHERLOCK_SCREEN_HEIGHT * 5 / 6) / (SHERLOCK_SCREEN_HEIGHT / 6);
if (_targetScroll.x < 0)
//.........这里部分代码省略.........
示例6: readHeader
void TXB::readHeader(Common::SeekableReadStream &txb, bool &needDeSwizzle) {
// Number of bytes for the pixel data in one full image
uint32 dataSize = txb.readUint32LE();
_dataSize = dataSize;
txb.skip(4); // Some float
// Image dimensions
uint32 width = txb.readUint16LE();
uint32 height = txb.readUint16LE();
// How's the pixel data encoded?
byte encoding = txb.readByte();
// Number of mip maps in the image
byte mipMapCount = txb.readByte();
txb.skip(2); // Unknown (Always 0x0101 on 0x0A and 0x0C types, 0x0100 on 0x09?)
txb.skip(4); // Some float
txb.skip(108); // Reserved
needDeSwizzle = false;
uint32 minDataSize, mipMapSize;
if (encoding == kEncodingBGRA) {
// Raw BGRA
needDeSwizzle = true;
_compressed = false;
_hasAlpha = true;
_format = kPixelFormatBGRA;
_formatRaw = kPixelFormatRGBA8;
_dataType = kPixelDataType8;
minDataSize = 4;
mipMapSize = width * height * 4;
} else if (encoding == kEncodingDXT1) {
// S3TC DXT1
_compressed = true;
_hasAlpha = false;
_format = kPixelFormatBGR;
_formatRaw = kPixelFormatDXT1;
_dataType = kPixelDataType8;
minDataSize = 8;
mipMapSize = width * height / 2;
} else if (encoding == kEncodingDXT5) {
// S3TC DXT5
_compressed = true;
_hasAlpha = true;
_format = kPixelFormatBGRA;
_formatRaw = kPixelFormatDXT5;
_dataType = kPixelDataType8;
minDataSize = 16;
mipMapSize = width * height;
} else if (encoding == 0x09)
// TODO: This seems to be some compression with 8bit per pixel. No min
// data size; 2*2 and 1*1 mipmaps seem to be just that big.
// Image data doesn't seem to be simple grayscale, paletted,
// RGB2222 or RGB332 data either.
throw Common::Exception("Unsupported TXB encoding 0x09");
else
throw Common::Exception("Unknown TXB encoding 0x%02X (%dx%d, %d, %d)",
encoding, width, height, mipMapCount, dataSize);
_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);
if (((width < 4) || (height < 4)) && (width != height))
// Invalid mipmap dimensions
break;
mipMap->size = MAX<uint32>(mipMapSize, minDataSize);
mipMap->data = 0;
if (dataSize < mipMap->size) {
// Wouldn't fit
delete mipMap;
break;
}
dataSize -= mipMap->size;
_mipMaps.push_back(mipMap);
width >>= 1;
height >>= 1;
mipMapSize >>= 2;
//.........这里部分代码省略.........
示例7: loadStream
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;
}
示例8: readPoint
Common::Point GameModule::readPoint(Common::SeekableReadStream &s) {
Common::Point p;
p.x = s.readUint16LE();
p.y = s.readUint16LE();
return p;
}
示例9: loadAnimations
void GameModule::loadAnimations(Common::SeekableReadStream &s) {
debug(0, "GameModule::loadAnimations()");
s.seek(0x168);
_animationsCount = s.readUint32LE();
uint32 offs = s.readUint32LE();
_animations = new Animation[_animationsCount];
for (int i = 0; i < _animationsCount; ++i) {
Animation &anim = _animations[i];
s.seek(offs + i * 20);
anim.frameCount = s.readUint32LE();
uint32 frameSpriteIndicesOffs = s.readUint32LE();
uint32 frameTicksOffs = s.readUint32LE();
uint32 frameRects1Offs = s.readUint32LE();
uint32 frameRects2Offs = s.readUint32LE();
anim.frameSpriteIndices = new int[anim.frameCount];
s.seek(frameSpriteIndicesOffs);
for (int j = 0; j < anim.frameCount; ++j)
anim.frameSpriteIndices[j] = s.readUint32LE();
anim.frameTicks = new int16[anim.frameCount];
s.seek(frameTicksOffs);
for (int j = 0; j < anim.frameCount; ++j)
anim.frameTicks[j] = s.readUint16LE();
anim.frameRects1 = new Common::Rect[anim.frameCount];
s.seek(frameRects1Offs);
for (int j = 0; j < anim.frameCount; ++j)
anim.frameRects1[j] = readRect(s);
anim.frameRects2 = new Common::Rect[anim.frameCount];
s.seek(frameRects2Offs);
for (int j = 0; j < anim.frameCount; ++j)
anim.frameRects2[j] = readRect(s);
}
}
示例10: handleRGBS
void CUP_Player::handleRGBS(Common::SeekableReadStream &dataStream, uint32 dataSize) {
dataStream.read(_paletteData, 256 * 3);
_paletteChanged = true;
}
示例11: Sections
/*
Island Sections (Num Entries HQR - 3 / 6 = Total Sections available)
3 (0) - Objects layout
4 (1) - Objects data
5 (2) - Quads (2 triangles)
6 (3) - Texture UV mapping
7 (4) - Height Maps
8 (5) - Intensity
*/
void Island::loadIslandSection(int sectionIdx, int entryIdx) {
// 7 (4) - Height Maps
int16 heightmap[65][65];
Common::SeekableReadStream *stream = _ile->createReadStreamForIndex(entryIdx + 4);
_sectionsLayout = new byte[256];
stream->read(heightmap, 65*65);
delete stream;
// 6 (3) - Texture UV mapping
GroundTextureInfo *textureInfo;
stream = _ile->createReadStreamForIndex(entryIdx + 3);
textureInfo = new GroundTextureInfo[stream->size() / 12];
stream->read(textureInfo, 65*65);
delete stream;
// 8 (5) - Intensity
byte intensity[65][65];
stream = _ile->createReadStreamForIndex(entryIdx + 5);
stream->read(intensity, 65*65);
delete stream;
// 5 (2) - Quads (2 triangles)
GroundSquare squares[64][64];
stream = _ile->createReadStreamForIndex(entryIdx + 2);
stream->read(squares, 64 * 64 * 8);
delete stream;
// Parse data
int16 maxHeight = 0;
Common::Array<float> vertices;
vertices.reserve(9 * 64 * 64 * 4 * 2);
Common::Array<uint16> faces;
faces.reserve(6 * 64 * 64);
// Vertex Count - In order of verts that make tris
uint16 idx = 0;
uint16 uvOrder[6] = {0, 1, 2, 2, 0, 1};
uint16 idxOrder1[6] = {0, 2, 3, 0, 3, 1};
uint16 idxOrder2[6] = {0, 2, 1, 1, 2, 3};
// For Every QUAD
for (int32 x = 0; x < 64; ++x)
{
for (int32 y = 0; y < 64; ++y)
{
// Pass the pointer from the quad database to this quad (2 triangles passed)
GroundTriangle *tri = squares[x][y].triangle;
// Orientation
uint16 *idxOrder = (tri[0].orientation == 0) ? idxOrder1 : idxOrder2;
// For both tris in this quad...
for (int32 t = 0; t < 2; ++t)
{
// Data Usage for this Tri
int mdMax = 0;
if (tri[t].useColor)
mdMax++;
if (tri[t].useTexture)
mdMax++;
// For all the data usage in this tri
for (int32 md = 0; md < mdMax; ++md)
{
// For each vertex, offset by triangle num in quad
for (int32 i = 3 * t; i < (3 + 3 * t); ++i)
{
int32 xi = x + idxOrder[i] / 2;
int32 yi = y + idxOrder[i] % 2;
// Vertex position
vertices.push_back(((float)(xi) - 32) / 0x20);
vertices.push_back(((float)(heightmap[xi][yi])) / 0x4000);
vertices.push_back(((float)(64 - yi) - 32) / 0x20);
if (heightmap[xi][yi] > maxHeight)
maxHeight = heightmap[xi][yi];
// Vertex color and UV
if (tri[t].useTexture && (mdMax < 2 || md == 1))
{
float intens = intensity[xi][yi] / 16.0f + 0.3;
if (intens > 1.0)
intens = 1.0;
vertices.push_back(intens);
vertices.push_back(intens);
vertices.push_back(intens);
//.........这里部分代码省略.........
示例12: handleHEAD
void CUP_Player::handleHEAD(Common::SeekableReadStream &dataStream, uint32 dataSize) {
_playbackRate = dataStream.readUint16LE();
_width = dataStream.readUint16LE();
_height = dataStream.readUint16LE();
}
示例13: loadLibrary
void ComposerEngine::loadLibrary(uint id) {
if (getGameType() == GType_ComposerV1 && !_libraries.empty()) {
// kill the previous page, starting with any scripts running on it
for (Common::List<OldScript *>::iterator i = _oldScripts.begin(); i != _oldScripts.end(); i++)
delete *i;
_oldScripts.clear();
Library *library = &_libraries.front();
unloadLibrary(library->_id);
}
Common::String filename;
if (getGameType() == GType_ComposerV1) {
if (!id || _bookGroup.empty())
filename = getStringFromConfig("Common", "StartPage");
else
filename = getStringFromConfig(_bookGroup, Common::String::format("%d", id));
filename = mangleFilename(filename);
// bookGroup is the basename of the path.
// TODO: tidy this up.
_bookGroup.clear();
for (uint i = 0; i < filename.size(); i++) {
if (filename[i] == '~' || filename[i] == '/' || filename[i] == ':')
continue;
for (uint j = 0; j < filename.size(); j++) {
if (filename[j] == '/') {
_bookGroup.clear();
continue;
}
if (filename[j] == '.')
break;
_bookGroup += filename[j];
}
break;
}
} else {
if (!id)
id = atoi(getStringFromConfig("Common", "StartUp").c_str());
filename = getFilename("Libs", id);
}
Library library;
library._id = id;
library._archive = new ComposerArchive();
if (!library._archive->openFile(filename))
error("failed to open '%s'", filename.c_str());
_libraries.push_front(library);
Library &newLib = _libraries.front();
Common::Array<uint16> buttonResources = library._archive->getResourceIDList(ID_BUTN);
for (uint i = 0; i < buttonResources.size(); i++) {
uint16 buttonId = buttonResources[i];
Common::SeekableReadStream *stream = library._archive->getResource(ID_BUTN, buttonId);
Button button(stream, buttonId, getGameType());
bool inserted = false;
for (Common::List<Button>::iterator b = newLib._buttons.begin(); b != newLib._buttons.end(); b++) {
if (button._zorder < b->_zorder)
continue;
newLib._buttons.insert(b, button);
inserted = true;
break;
}
if (!inserted)
newLib._buttons.push_back(button);
}
Common::Array<uint16> ambientResources = library._archive->getResourceIDList(ID_AMBI);
for (uint i = 0; i < ambientResources.size(); i++) {
Common::SeekableReadStream *stream = library._archive->getResource(ID_AMBI, ambientResources[i]);
Button button(stream);
newLib._buttons.insert(newLib._buttons.begin(), button);
}
Common::Array<uint16> accelResources = library._archive->getResourceIDList(ID_ACEL);
for (uint i = 0; i < accelResources.size(); i++) {
Common::SeekableReadStream *stream = library._archive->getResource(ID_ACEL, accelResources[i]);
KeyboardHandler handler;
handler.keyId = stream->readUint16LE();
handler.modifierId = stream->readUint16LE();
handler.scriptId = stream->readUint16LE();
newLib._keyboardHandlers.push_back(handler);
}
Common::Array<uint16> randResources = library._archive->getResourceIDList(ID_RAND);
for (uint i = 0; i < randResources.size(); i++) {
Common::SeekableReadStream *stream = library._archive->getResource(ID_RAND, randResources[i]);
Common::Array<RandomEvent> &events = _randomEvents[randResources[i]];
uint16 count = stream->readUint16LE();
for (uint j = 0; j < count; j++) {
RandomEvent random;
random.scriptId = stream->readUint16LE();
random.weight = stream->readUint16LE();
events.push_back(random);
}
//.........这里部分代码省略.........
示例14: screenSaver
void DrasculaEngine::screenSaver() {
int xr, yr;
byte *copia, *ghost;
float coeff = 0, coeff2 = 0;
int count = 0;
int count2 = 0;
int tempLine[320];
int tempRow[200];
hideCursor();
clearRoom();
loadPic("sv.alg", bgSurface, HALF_PAL);
// inicio_ghost();
copia = (byte *)malloc(64000);
ghost = (byte *)malloc(65536);
// carga_ghost();
Common::SeekableReadStream *stream = _archives.open("ghost.drv");
if (!stream)
error("Cannot open file ghost.drv");
stream->read(ghost, 65536);
delete stream;
updateEvents();
xr = mouseX;
yr = mouseY;
for (;;) {
// efecto(bgSurface);
memcpy(copia, bgSurface, 64000);
coeff += 0.1f;
coeff2 = coeff;
if (++count > 319)
count = 0;
for (int i = 0; i < 320; i++) {
tempLine[i] = (int)(sin(coeff2) * 16);
coeff2 += 0.02f;
tempLine[i] = checkWrapY(tempLine[i]);
}
coeff2 = coeff;
for (int i = 0; i < 200; i++) {
tempRow[i] = (int)(sin(coeff2) * 16);
coeff2 += 0.02f;
tempRow[i] = checkWrapX(tempRow[i]);
}
if (++count2 > 199)
count2 = 0;
int x1_, y1_, off1, off2;
byte *screenBuffer = (byte *)_system->lockScreen()->pixels;
for (int i = 0; i < 200; i++) {
for (int j = 0; j < 320; j++) {
x1_ = j + tempRow[i];
x1_ = checkWrapX(x1_);
y1_ = i + count2;
y1_ = checkWrapY(y1_);
off1 = 320 * y1_ + x1_;
x1_ = j + count;
x1_ = checkWrapX(x1_);
y1_ = i + tempLine[j];
y1_ = checkWrapY(y1_);
off2 = 320 * y1_ + x1_;
screenBuffer[320 * i + j] = ghost[bgSurface[off2] + (copia[off1] << 8)];
}
}
_system->unlockScreen();
_system->updateScreen();
_system->delayMillis(20);
// end of efecto()
updateEvents();
if (rightMouseButton == 1 || leftMouseButton == 1)
break;
if (mouseX != xr)
break;
if (mouseY != yr)
break;
}
// fin_ghost();
free(copia);
free(ghost);
//.........这里部分代码省略.........
示例15: detectSaveGameFormat
/**
* Savegame format detector
* @param fHandle Savefile to check
* @return Savegame format on success, ANIMSIZE_UNKNOWN on failure
*
* This function seeks through the savefile and tries to determine the
* savegame format it uses. There's a miniscule chance that the detection
* algorithm could get confused and think that the file uses both the older
* and the newer format but that is such a remote possibility that I wouldn't
* worry about it at all.
*
* Also detects the temporary Operation Stealth savegame format now.
*/
enum CineSaveGameFormat detectSaveGameFormat(Common::SeekableReadStream &fHandle) {
const uint32 prevStreamPos = fHandle.pos();
// First check for the temporary Operation Stealth savegame format.
fHandle.seek(0);
ChunkHeader hdr;
loadChunkHeader(fHandle, hdr);
fHandle.seek(prevStreamPos);
if (hdr.id == TEMP_OS_FORMAT_ID) {
return TEMP_OS_FORMAT;
}
// Ok, so the savegame isn't using the temporary Operation Stealth savegame format.
// Let's check for the plain Future Wars savegame format and its different versions then.
// The animDataTable begins at savefile position 0x2315.
// Each animDataTable entry takes 23 bytes in older saves (Revisions 21772-31443)
// and 30 bytes in the save format after that (Revision 31444 and onwards).
// There are 255 entries in the animDataTable in both of the savefile formats.
static const uint animDataTableStart = 0x2315;
static const uint animEntriesCount = 255;
static const uint oldAnimEntrySize = 23;
static const uint newAnimEntrySize = 30;
static const uint animEntrySizeChoices[] = {oldAnimEntrySize, newAnimEntrySize};
Common::Array<uint> animEntrySizeMatches;
// Try to walk through the savefile using different animDataTable entry sizes
// and make a list of all the successful entry sizes.
for (uint i = 0; i < ARRAYSIZE(animEntrySizeChoices); i++) {
// 206 = 2 * 50 * 2 + 2 * 3 (Size of global and object script entries)
// 20 = 4 * 2 + 2 * 6 (Size of overlay and background incrust entries)
static const uint sizeofScreenParams = 2 * 6;
static const uint globalScriptEntrySize = 206;
static const uint objectScriptEntrySize = 206;
static const uint overlayEntrySize = 20;
static const uint bgIncrustEntrySize = 20;
static const uint chainEntrySizes[] = {
globalScriptEntrySize,
objectScriptEntrySize,
overlayEntrySize,
bgIncrustEntrySize
};
uint animEntrySize = animEntrySizeChoices[i];
// Jump over the animDataTable entries and the screen parameters
int32 newPos = animDataTableStart + animEntrySize * animEntriesCount + sizeofScreenParams;
// Check that there's data left after the point we're going to jump to
if (newPos >= fHandle.size()) {
continue;
}
fHandle.seek(newPos);
// Jump over the remaining items in the savegame file
// (i.e. the global scripts, object scripts, overlays and background incrusts).
bool chainWalkSuccess = true;
for (uint chainIndex = 0; chainIndex < ARRAYSIZE(chainEntrySizes); chainIndex++) {
// Read entry count and jump over the entries
int entryCount = fHandle.readSint16BE();
newPos = fHandle.pos() + chainEntrySizes[chainIndex] * entryCount;
// Check that we didn't go past the end of file.
// Note that getting exactly to the end of file is acceptable.
if (newPos > fHandle.size()) {
chainWalkSuccess = false;
break;
}
fHandle.seek(newPos);
}
// If we could walk the chain successfully and
// got exactly to the end of file then we've got a match.
if (chainWalkSuccess && fHandle.pos() == fHandle.size()) {
// We found a match, let's save it
animEntrySizeMatches.push_back(animEntrySize);
}
}
// Check that we got only one entry size match.
// If we didn't, then return an error.
enum CineSaveGameFormat result = ANIMSIZE_UNKNOWN;
if (animEntrySizeMatches.size() == 1) {
const uint animEntrySize = animEntrySizeMatches[0];
assert(animEntrySize == oldAnimEntrySize || animEntrySize == newAnimEntrySize);
if (animEntrySize == oldAnimEntrySize) {
result = ANIMSIZE_23;
} else { // animEntrySize == newAnimEntrySize
// Check data and mask pointers in all of the animDataTable entries
// to see whether we've got the version with the broken data and mask pointers or not.
// In the broken format all data and mask pointers were always zero.
//.........这里部分代码省略.........