[Scummvm-cvs-logs] SF.net SVN: scummvm:[55565] scummvm/trunk/engines/gob
drmccoy at users.sourceforge.net
drmccoy at users.sourceforge.net
Thu Jan 27 14:27:58 CET 2011
Revision: 55565
http://scummvm.svn.sourceforge.net/scummvm/?rev=55565&view=rev
Author: drmccoy
Date: 2011-01-27 13:27:58 +0000 (Thu, 27 Jan 2011)
Log Message:
-----------
GOB: Implement backuping of sprites, sounds, fonts in totSub
Modified Paths:
--------------
scummvm/trunk/engines/gob/game.cpp
scummvm/trunk/engines/gob/game.h
Modified: scummvm/trunk/engines/gob/game.cpp
===================================================================
--- scummvm/trunk/engines/gob/game.cpp 2011-01-27 13:27:29 UTC (rev 55564)
+++ scummvm/trunk/engines/gob/game.cpp 2011-01-27 13:27:58 UTC (rev 55565)
@@ -46,6 +46,7 @@
Environments::Environments(GobEngine *vm) : _vm(vm) {
for (uint i = 0; i < kEnvironmentCount; i++) {
Environment &e = _environments[i];
+ Media &m = _media[i];
e.cursorHotspotX = 0;
e.cursorHotspotY = 0;
@@ -53,6 +54,9 @@
e.script = 0;
e.resources = 0;
e.curTotFile[0] = '\0';
+
+ for (int j = 0; j < 17; j++)
+ m.fonts[j] = 0;
}
}
@@ -86,6 +90,9 @@
if (!has(_environments[i].resources, i + 1))
delete _environments[i].resources;
}
+
+ for (uint i = 0; i < kEnvironmentCount; i++)
+ clearMedia(i);
}
void Environments::set(uint8 env) {
@@ -165,7 +172,83 @@
return false;
}
+bool Environments::clearMedia(uint8 env) {
+ if (env >= kEnvironmentCount)
+ return false;
+ Media &m = _media[env];
+
+ for (int i = 0; i < 10; i++)
+ m.sprites[i].reset();
+
+ for (int i = 0; i < 10; i++)
+ m.sounds[i].free();
+
+ for (int i = 0; i < 17; i++) {
+ delete m.fonts[i];
+ m.fonts[i] = 0;
+ }
+
+ return true;
+}
+
+bool Environments::setMedia(uint8 env) {
+ if (env >= kEnvironmentCount)
+ return false;
+
+ clearMedia(env);
+
+ Media &m = _media[env];
+
+ for (int i = 0; i < 10; i++) {
+ m.sprites[i] = _vm->_draw->_spritesArray[i];
+ _vm->_draw->_spritesArray[i].reset();
+ }
+
+ for (int i = 0; i < 10; i++) {
+ SoundDesc *sound = _vm->_sound->sampleGetBySlot(i);
+ if (sound)
+ m.sounds[i].swap(*sound);
+ }
+
+ int n = MIN(Draw::kFontCount, 17);
+ for (int i = 0; i < n; i++) {
+ m.fonts[i] = _vm->_draw->_fonts[i];
+ _vm->_draw->_fonts[i] = 0;
+ }
+
+ return true;
+}
+
+bool Environments::getMedia(uint8 env) {
+ if (env >= kEnvironmentCount)
+ return false;
+
+ Media &m = _media[env];
+
+ for (int i = 0; i < 10; i++) {
+ _vm->_draw->_spritesArray[i] = m.sprites[i];
+ m.sprites[i].reset();
+ }
+
+ for (int i = 0; i < 10; i++) {
+ SoundDesc *sound = _vm->_sound->sampleGetBySlot(i);
+ if (sound)
+ m.sounds[i].swap(*sound);
+ m.sounds[i].free();
+ }
+
+ int n = MIN(Draw::kFontCount, 17);
+ for (int i = 0; i < n; i++) {
+ delete _vm->_draw->_fonts[i];
+ _vm->_draw->_fonts[i] = m.fonts[i];
+ m.fonts[i]= 0;
+ }
+
+ return true;
+}
+
+
Game::Game(GobEngine *vm) : _vm(vm) {
_captureCount = 0;
@@ -572,8 +655,10 @@
_environments->set(_numEnvironments);
- if (flags == 18)
- warning("Game::totSub(): Backup media");
+ if (flags == 18) {
+ warning("Backuping media to %d", _numEnvironments);
+ _environments->setMedia(_numEnvironments);
+ }
curBackupPos = _curEnvironment;
_numEnvironments++;
@@ -621,6 +706,11 @@
_curEnvironment = curBackupPos;
_environments->get(_numEnvironments);
+ if (flags == 18) {
+ warning("Restoring media from %d", _numEnvironments);
+ _environments->getMedia(_numEnvironments);
+ }
+
_vm->_global->_inter_animDataSize = _script->getAnimDataSize();
}
Modified: scummvm/trunk/engines/gob/game.h
===================================================================
--- scummvm/trunk/engines/gob/game.h 2011-01-27 13:27:29 UTC (rev 55564)
+++ scummvm/trunk/engines/gob/game.h 2011-01-27 13:27:58 UTC (rev 55565)
@@ -27,6 +27,8 @@
#define GOB_GAME_H
#include "gob/util.h"
+#include "gob/video.h"
+#include "gob/sound/sounddesc.h"
namespace Gob {
@@ -53,6 +55,10 @@
void clear();
+ bool setMedia(uint8 env);
+ bool getMedia(uint8 env);
+ bool clearMedia(uint8 env);
+
private:
struct Environment {
int32 cursorHotspotX;
@@ -63,9 +69,16 @@
Resources *resources;
};
+ struct Media {
+ SurfacePtr sprites[10];
+ SoundDesc sounds[10];
+ Font *fonts[17];
+ };
+
GobEngine *_vm;
Environment _environments[kEnvironmentCount];
+ Media _media[kEnvironmentCount];
};
class Game {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list