Skip to content

Commit

Permalink
SCI32: Implement bitmap save routine
Browse files Browse the repository at this point in the history
  • Loading branch information
csnover committed Aug 1, 2016
1 parent c602115 commit 73d3e8d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
46 changes: 35 additions & 11 deletions engines/sci/engine/savegame.cpp
Expand Up @@ -159,16 +159,22 @@ void syncWithSerializer(Common::Serializer &s, SciString &obj) {
}
}

void syncWithSerializer(Common::Serializer &s, SciBitmap *obj) {
debug("TODO: Sync bitmap");

// if (s.isSaving()) {
// size = obj.getSize();
// s.syncAsUint32LE(size);
// } else {
// s.syncAsUint32LE(size);
// obj.setSize(size);
// }
void syncWithSerializer(Common::Serializer &s, SciBitmap *&obj) {
bool hasEntry;
if (s.isSaving()) {
hasEntry = obj != nullptr;
}
s.syncAsByte(hasEntry);

if (hasEntry) {
if (s.isLoading()) {
obj = new SciBitmap;
}

obj->saveLoadWithSerializer(s);
} else {
obj = nullptr;
}
}
#endif

Expand Down Expand Up @@ -703,12 +709,30 @@ void StringTable::saveLoadWithSerializer(Common::Serializer &ser) {
}

void BitmapTable::saveLoadWithSerializer(Common::Serializer &ser) {
if (ser.getVersion() < 36)
if (ser.getVersion() < 36) {
return;
}

// TODO: Should only include bitmaps with gc = true
sync_Table(ser, *this);
}

void SciBitmap::saveLoadWithSerializer(Common::Serializer &s) {
if (s.getVersion() < 36) {
return;
}

s.syncAsByte(_gc);
s.syncAsUint32LE(_dataSize);
if (s.isLoading()) {
_data = (byte *)malloc(_dataSize);
}
s.syncBytes(_data, _dataSize);

if (s.isLoading()) {
_buffer = Buffer(getWidth(), getHeight(), getPixels());
}
}
#endif

void GfxPalette::palVarySaveLoadPalette(Common::Serializer &s, Palette *palette) {
Expand Down
4 changes: 3 additions & 1 deletion engines/sci/engine/segment.h
Expand Up @@ -541,7 +541,7 @@ class BitmapTable;
* A convenience class for creating and modifying in-memory
* bitmaps.
*/
class SciBitmap {
class SciBitmap : public Common::Serializable {
byte *_data;
int _dataSize;
Buffer _buffer;
Expand Down Expand Up @@ -773,6 +773,8 @@ class SciBitmap {
}
return _data + getHunkPaletteOffset();
}

virtual void saveLoadWithSerializer(Common::Serializer &ser);
};

struct BitmapTable : public SegmentObjTable<SciBitmap *> {
Expand Down

0 comments on commit 73d3e8d

Please sign in to comment.