TRECISION: Clean up location reading code

This commit is contained in:
Filippos Karapetis 2022-01-26 01:40:28 +02:00
parent 43d16746c0
commit 52a9b4a03c
4 changed files with 24 additions and 32 deletions

View File

@ -262,8 +262,11 @@ void GraphicsManager::drawTexturePixel(uint16 textureX, uint16 textureY, uint16
_screenBuffer.setPixel(screenX, screenY, texturePixel);
}
void GraphicsManager::loadBackground(Common::SeekableReadStream *stream, uint16 width, uint16 height) {
readSurface(stream, &_background, width, height);
void GraphicsManager::loadBackground(Common::SeekableReadStream *stream) {
SObject bgInfo;
bgInfo.readRect(stream);
readSurface(stream, &_background, bgInfo._rect.width(), bgInfo._rect.height());
_smkBackground.copyFrom(_background);
memcpy(_screenBuffer.getBasePtr(0, TOP), _background.getPixels(), _background.pitch * _background.h);
}

View File

@ -77,7 +77,7 @@ public:
void copyToScreenBuffer(const Graphics::Surface *surface, int x, int y, const byte *palette);
void blitToScreenBuffer(const Graphics::Surface *surface, int x, int y, const byte *palette, bool useSmkBg);
void paintScreen(bool flag);
void loadBackground(Common::SeekableReadStream *stream, uint16 width, uint16 height);
void loadBackground(Common::SeekableReadStream *stream);
void clearScreenBuffer();
void clearScreenBufferTop();
void clearScreenBufferInventory();

View File

@ -381,27 +381,27 @@ void TrecisionEngine::reEvent() {
_scheduler->doEvent(_curMessage->_class, _curMessage->_event, _curMessage->_priority, _curMessage->_u16Param1, _curMessage->_u16Param2, _curMessage->_u8Param, _curMessage->_u32Param);
}
Common::SeekableReadStreamEndian *TrecisionEngine::getLocStream() {
Common::String filename;
if (isAmiga()) {
filename = Common::String::format("%s.bm", _room[_curRoom]._baseName);
return readEndian(_dataFile.createReadStreamForMember(filename));
} else {
filename = Common::String::format("%s.cr", _room[_curRoom]._baseName);
return readEndian(_dataFile.createReadStreamForCompressedMember(filename));
}
}
void TrecisionEngine::readLoc() {
_soundMgr->stopAllExceptMusic();
_graphicsMgr->clearScreenBufferTop();
Common::String filename;
Common::SeekableReadStreamEndian *picFile;
if (isAmiga()) {
filename = Common::String::format("%s.bm", _room[_curRoom]._baseName);
picFile = readEndian(_dataFile.createReadStreamForMember(filename));
} else {
filename = Common::String::format("%s.cr", _room[_curRoom]._baseName);
picFile = readEndian(_dataFile.createReadStreamForCompressedMember(filename));
}
SObject bgInfo;
bgInfo.readRect(picFile);
_graphicsMgr->loadBackground(picFile, bgInfo._rect.width(), bgInfo._rect.height());
_sortTable.clear();
_sortTableReplay.clear();
Common::SeekableReadStreamEndian *picFile = getLocStream();
_graphicsMgr->loadBackground(picFile);
readObj(picFile);
_soundMgr->stopAll();
@ -444,20 +444,8 @@ void TrecisionEngine::redrawRoom() {
}
}
Common::String filename;
Common::SeekableReadStreamEndian *picFile;
if (isAmiga()) {
filename = Common::String::format("%s.bm", _room[_curRoom]._baseName);
picFile = readEndian(_dataFile.createReadStreamForMember(filename));
} else {
filename = Common::String::format("%s.cr", _room[_curRoom]._baseName);
picFile = readEndian(_dataFile.createReadStreamForCompressedMember(filename));
}
SObject bgInfo;
bgInfo.readRect(picFile);
_graphicsMgr->loadBackground(picFile, bgInfo._rect.width(), bgInfo._rect.height());
Common::SeekableReadStreamEndian *picFile = getLocStream();
_graphicsMgr->loadBackground(picFile);
_sortTable.clear();
_sortTable = _sortTableReplay;

View File

@ -232,6 +232,7 @@ public:
void setObjectAnim(uint16 objectId, uint16 animId);
void redrawRoom();
void readLoc();
Common::SeekableReadStreamEndian *getLocStream();
void tendIn();
void readExtraObj2C();
void readPositionerSnapshots();