From 734fc767d25d47b5da703dc1b4a3cfb494234155 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Fri, 29 Jun 2012 18:25:11 +0200 Subject: GOB: Open the Once Upon A Time archives --- engines/gob/pregob/onceupon/abracadabra.cpp | 4 ++-- engines/gob/pregob/onceupon/babayaga.cpp | 4 ++-- engines/gob/pregob/onceupon/onceupon.cpp | 29 ++++++++++++++++++++++++++++- engines/gob/pregob/onceupon/onceupon.h | 6 ++++++ 4 files changed, 38 insertions(+), 5 deletions(-) (limited to 'engines/gob/pregob/onceupon') diff --git a/engines/gob/pregob/onceupon/abracadabra.cpp b/engines/gob/pregob/onceupon/abracadabra.cpp index 84d84e89a5..6cfdfa7822 100644 --- a/engines/gob/pregob/onceupon/abracadabra.cpp +++ b/engines/gob/pregob/onceupon/abracadabra.cpp @@ -35,9 +35,9 @@ Abracadabra::~Abracadabra() { } void Abracadabra::run() { - warning("TODO: Abracadabra::run()"); + init(); - initScreen(); + warning("TODO: Abracadabra::run()"); } } // End of namespace OnceUpon diff --git a/engines/gob/pregob/onceupon/babayaga.cpp b/engines/gob/pregob/onceupon/babayaga.cpp index 21355ab9ed..9f4f53c4e0 100644 --- a/engines/gob/pregob/onceupon/babayaga.cpp +++ b/engines/gob/pregob/onceupon/babayaga.cpp @@ -35,9 +35,9 @@ BabaYaga::~BabaYaga() { } void BabaYaga::run() { - warning("TODO: BabaYaga::run()"); + init(); - initScreen(); + warning("TODO: BabaYaga::run()"); } } // End of namespace OnceUpon diff --git a/engines/gob/pregob/onceupon/onceupon.cpp b/engines/gob/pregob/onceupon/onceupon.cpp index 7f7dffa7ec..e3d1a8535f 100644 --- a/engines/gob/pregob/onceupon/onceupon.cpp +++ b/engines/gob/pregob/onceupon/onceupon.cpp @@ -166,10 +166,37 @@ namespace Gob { namespace OnceUpon { -OnceUpon::OnceUpon(GobEngine *vm) : PreGob(vm) { +OnceUpon::OnceUpon(GobEngine *vm) : PreGob(vm), _openedArchives(false) { + } OnceUpon::~OnceUpon() { + deinit(); +} + +void OnceUpon::init() { + deinit(); + + bool hasSTK1 = _vm->_dataIO->openArchive("stk1.stk", true); + bool hasSTK2 = _vm->_dataIO->openArchive("stk2.stk", true); + bool hasSTK3 = _vm->_dataIO->openArchive("stk3.stk", true); + + if (!hasSTK1 || !hasSTK2 || !hasSTK3) + error("OnceUpon::OnceUpon(): Failed to open archives"); + + _openedArchives = true; + + initScreen(); +} + +void OnceUpon::deinit() { + if (_openedArchives) { + _vm->_dataIO->closeArchive(true); + _vm->_dataIO->closeArchive(true); + _vm->_dataIO->closeArchive(true); + } + + _openedArchives = false; } void OnceUpon::setCopyProtectionPalette() { diff --git a/engines/gob/pregob/onceupon/onceupon.h b/engines/gob/pregob/onceupon/onceupon.h index c1c4d6fa0d..e5f70855ad 100644 --- a/engines/gob/pregob/onceupon/onceupon.h +++ b/engines/gob/pregob/onceupon/onceupon.h @@ -39,10 +39,16 @@ public: ~OnceUpon(); protected: + void init(); + void deinit(); + void setGamePalette(uint palette); private: void setCopyProtectionPalette(); + + + bool _openedArchives; }; } // End of namespace OnceUpon -- cgit v1.2.3