mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-10 21:03:31 +00:00
GOB: Implement backuping of sprites, sounds, fonts in totSub
svn-id: r55565
This commit is contained in:
parent
95ed10adde
commit
eb3667d7c9
@ -46,6 +46,7 @@ namespace Gob {
|
|||||||
Environments::Environments(GobEngine *vm) : _vm(vm) {
|
Environments::Environments(GobEngine *vm) : _vm(vm) {
|
||||||
for (uint i = 0; i < kEnvironmentCount; i++) {
|
for (uint i = 0; i < kEnvironmentCount; i++) {
|
||||||
Environment &e = _environments[i];
|
Environment &e = _environments[i];
|
||||||
|
Media &m = _media[i];
|
||||||
|
|
||||||
e.cursorHotspotX = 0;
|
e.cursorHotspotX = 0;
|
||||||
e.cursorHotspotY = 0;
|
e.cursorHotspotY = 0;
|
||||||
@ -53,6 +54,9 @@ Environments::Environments(GobEngine *vm) : _vm(vm) {
|
|||||||
e.script = 0;
|
e.script = 0;
|
||||||
e.resources = 0;
|
e.resources = 0;
|
||||||
e.curTotFile[0] = '\0';
|
e.curTotFile[0] = '\0';
|
||||||
|
|
||||||
|
for (int j = 0; j < 17; j++)
|
||||||
|
m.fonts[j] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,6 +90,9 @@ void Environments::clear() {
|
|||||||
if (!has(_environments[i].resources, i + 1))
|
if (!has(_environments[i].resources, i + 1))
|
||||||
delete _environments[i].resources;
|
delete _environments[i].resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (uint i = 0; i < kEnvironmentCount; i++)
|
||||||
|
clearMedia(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Environments::set(uint8 env) {
|
void Environments::set(uint8 env) {
|
||||||
@ -165,6 +172,82 @@ bool Environments::has(Resources *resources, uint8 startEnv, int16 except) const
|
|||||||
return false;
|
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) {
|
Game::Game(GobEngine *vm) : _vm(vm) {
|
||||||
_captureCount = 0;
|
_captureCount = 0;
|
||||||
@ -572,8 +655,10 @@ void Game::totSub(int8 flags, const char *newTotFile) {
|
|||||||
|
|
||||||
_environments->set(_numEnvironments);
|
_environments->set(_numEnvironments);
|
||||||
|
|
||||||
if (flags == 18)
|
if (flags == 18) {
|
||||||
warning("Game::totSub(): Backup media");
|
warning("Backuping media to %d", _numEnvironments);
|
||||||
|
_environments->setMedia(_numEnvironments);
|
||||||
|
}
|
||||||
|
|
||||||
curBackupPos = _curEnvironment;
|
curBackupPos = _curEnvironment;
|
||||||
_numEnvironments++;
|
_numEnvironments++;
|
||||||
@ -621,6 +706,11 @@ void Game::totSub(int8 flags, const char *newTotFile) {
|
|||||||
_curEnvironment = curBackupPos;
|
_curEnvironment = curBackupPos;
|
||||||
_environments->get(_numEnvironments);
|
_environments->get(_numEnvironments);
|
||||||
|
|
||||||
|
if (flags == 18) {
|
||||||
|
warning("Restoring media from %d", _numEnvironments);
|
||||||
|
_environments->getMedia(_numEnvironments);
|
||||||
|
}
|
||||||
|
|
||||||
_vm->_global->_inter_animDataSize = _script->getAnimDataSize();
|
_vm->_global->_inter_animDataSize = _script->getAnimDataSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
#define GOB_GAME_H
|
#define GOB_GAME_H
|
||||||
|
|
||||||
#include "gob/util.h"
|
#include "gob/util.h"
|
||||||
|
#include "gob/video.h"
|
||||||
|
#include "gob/sound/sounddesc.h"
|
||||||
|
|
||||||
namespace Gob {
|
namespace Gob {
|
||||||
|
|
||||||
@ -53,6 +55,10 @@ public:
|
|||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
bool setMedia(uint8 env);
|
||||||
|
bool getMedia(uint8 env);
|
||||||
|
bool clearMedia(uint8 env);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Environment {
|
struct Environment {
|
||||||
int32 cursorHotspotX;
|
int32 cursorHotspotX;
|
||||||
@ -63,9 +69,16 @@ private:
|
|||||||
Resources *resources;
|
Resources *resources;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Media {
|
||||||
|
SurfacePtr sprites[10];
|
||||||
|
SoundDesc sounds[10];
|
||||||
|
Font *fonts[17];
|
||||||
|
};
|
||||||
|
|
||||||
GobEngine *_vm;
|
GobEngine *_vm;
|
||||||
|
|
||||||
Environment _environments[kEnvironmentCount];
|
Environment _environments[kEnvironmentCount];
|
||||||
|
Media _media[kEnvironmentCount];
|
||||||
};
|
};
|
||||||
|
|
||||||
class Game {
|
class Game {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user