aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/plugins_table.h6
-rw-r--r--engines/prince/archive.h2
-rw-r--r--engines/prince/cursor.cpp1
-rw-r--r--engines/prince/graphics.cpp5
-rw-r--r--engines/prince/graphics.h1
-rw-r--r--engines/prince/prince.cpp71
-rw-r--r--engines/prince/prince.h22
-rw-r--r--engines/prince/script.cpp6
8 files changed, 61 insertions, 53 deletions
diff --git a/engines/plugins_table.h b/engines/plugins_table.h
index de2a8069de..939c756581 100644
--- a/engines/plugins_table.h
+++ b/engines/plugins_table.h
@@ -74,6 +74,9 @@ LINK_PLUGIN(PARALLACTION)
#if PLUGIN_ENABLED_STATIC(PEGASUS)
LINK_PLUGIN(PEGASUS)
#endif
+#if PLUGIN_ENABLED_STATIC(PRINCE)
+LINK_PLUGIN(PRINCE)
+#endif
#if PLUGIN_ENABLED_STATIC(QUEEN)
LINK_PLUGIN(QUEEN)
#endif
@@ -125,9 +128,6 @@ LINK_PLUGIN(TUCKER)
#if PLUGIN_ENABLED_STATIC(WINTERMUTE)
LINK_PLUGIN(WINTERMUTE)
#endif
-#if PLUGIN_ENABLED_STATIC(PRINCE)
-LINK_PLUGIN(PRINCE)
-#endif
#if PLUGIN_ENABLED_STATIC(ZVISION)
LINK_PLUGIN(ZVISION)
#endif
diff --git a/engines/prince/archive.h b/engines/prince/archive.h
index 8e106693dc..94503b65ce 100644
--- a/engines/prince/archive.h
+++ b/engines/prince/archive.h
@@ -28,7 +28,7 @@
// This is here just as remainder that archive support is missing
namespace Price {
-class Archive : public Common::Archive {
+class PtcArchive : public Common::Archive {
};
}
diff --git a/engines/prince/cursor.cpp b/engines/prince/cursor.cpp
index 9a9162fd27..414e7ce397 100644
--- a/engines/prince/cursor.cpp
+++ b/engines/prince/cursor.cpp
@@ -31,6 +31,7 @@ Cursor::Cursor() : _surface(NULL) {
}
Cursor::~Cursor() {
+ _surface->free();
delete _surface;
_surface = NULL;
}
diff --git a/engines/prince/graphics.cpp b/engines/prince/graphics.cpp
index 29d3a331df..025fa70003 100644
--- a/engines/prince/graphics.cpp
+++ b/engines/prince/graphics.cpp
@@ -35,6 +35,11 @@ GraphicsMan::GraphicsMan(PrinceEngine *vm)
_frontScreen->create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
}
+GraphicsMan::~GraphicsMan() {
+ _frontScreen->free();
+ delete _frontScreen;
+}
+
void GraphicsMan::update() {
if (_changed) {
_vm->_system->copyRectToScreen((byte*)_frontScreen->getBasePtr(0,0), 640, 0, 0, 640, 480);
diff --git a/engines/prince/graphics.h b/engines/prince/graphics.h
index 3ef768a073..884aac2c84 100644
--- a/engines/prince/graphics.h
+++ b/engines/prince/graphics.h
@@ -34,6 +34,7 @@ class GraphicsMan
{
public:
GraphicsMan(PrinceEngine *vm);
+ ~GraphicsMan();
void update();
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index 2b4390c755..d184f84518 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -83,9 +83,6 @@ PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc)
gDebugLevel = 10;
- _rnd = new Common::RandomSource("prince");
- _debugger = new Debugger(this);
- _midiPlayer = new MusicPlayer(this);
}
@@ -101,6 +98,13 @@ PrinceEngine::~PrinceEngine() {
delete _font;
delete _roomBmp;
delete _walizkaBmp;
+ delete _variaTxt;
+ delete[] _talkTxt;
+ delete _graph;
+ delete _mobList;
+ delete _objectList;
+ _midiPlayer->killMidi();
+ delete _midiPlayer;
}
GUI::Debugger *PrinceEngine::getDebugger() {
@@ -137,9 +141,14 @@ bool loadResource(T *resource, const char *resourceName) {
return ret;
}
-Common::Error PrinceEngine::run() {
+void PrinceEngine::init() {
+
_graph = new GraphicsMan(this);
+ _rnd = new Common::RandomSource("prince");
+ _debugger = new Debugger(this);
+ _midiPlayer = new MusicPlayer(this);
+
const Common::FSNode gameDataDir(ConfMan.get("path"));
debugEngine("Adding all path: %s", gameDataDir.getPath().c_str());
@@ -167,7 +176,7 @@ Common::Error PrinceEngine::run() {
Common::SeekableReadStream *talkTxtStream = SearchMan.createReadStreamForMember("talktxt.dat");
if (!talkTxtStream) {
error("Can't load talkTxtStream");
- return Common::kPathDoesNotExist;
+ return;
}
_talkTxtSize = talkTxtStream->size();
@@ -175,53 +184,27 @@ Common::Error PrinceEngine::run() {
talkTxtStream->read(_talkTxt, _talkTxtSize);
delete talkTxtStream;
+}
- MhwanhDecoder *logo = new MhwanhDecoder();
- loadResource(logo, "logo.raw");
- if (logo)
- {
- _graph->setPalette(logo->getPalette());
- _graph->draw(0, 0, logo->getSurface());
+void PrinceEngine::showLogo() {
+ MhwanhDecoder logo;
+ if (loadResource(&logo, "logo.raw")) {
+ _graph->setPalette(logo.getPalette());
+ _graph->draw(0, 0, logo.getSurface());
_graph->update();
_system->delayMillis(700);
}
- delete logo;
-
- mainLoop();
-
- return Common::kNoError;
}
-class MobList {
-public:
- bool loadFromStream(Common::SeekableReadStream &stream);
-
- Common::Array<Mob> _mobList;
-};
-
-bool MobList::loadFromStream(Common::SeekableReadStream &stream)
-{
- Mob mob;
- while (mob.loadFromStream(stream))
- _mobList.push_back(mob);
-
- return true;
-}
+Common::Error PrinceEngine::run() {
-class ObjectList {
-public:
- bool loadFromStream(Common::SeekableReadStream &stream);
+ init();
- Common::Array<Object> _objList;
-};
+ showLogo();
-bool ObjectList::loadFromStream(Common::SeekableReadStream &stream)
-{
- Object obj;
- while (obj.loadFromStream(stream))
- _objList.push_back(obj);
+ mainLoop();
- return true;
+ return Common::kNoError;
}
bool PrinceEngine::loadLocation(uint16 locationNr) {
@@ -417,8 +400,8 @@ void PrinceEngine::hotspot() {
Common::Point mousepos = _system->getEventManager()->getMousePos();
Common::Point mousePosCamera(mousepos.x + _cameraX, mousepos.y);
- for (Common::Array<Mob>::const_iterator it = _mobList->_mobList.begin()
- ; it != _mobList->_mobList.end() ; ++it) {
+ for (Common::Array<Mob>::const_iterator it = _mobList->_list.begin()
+ ; it != _mobList->_list.end() ; ++it) {
if (it->_visible)
continue;
if (it->_rect.contains(mousePosCamera)) {
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index 4f2ddf827a..85ed3cec0e 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -42,16 +42,32 @@
#include "video/flic_decoder.h"
+#include "prince/mob.h"
+#include "prince/object.h"
+
+
namespace Prince {
+template <typename ResourceType>
+struct ResourceList {
+ bool loadFromStream(Common::SeekableReadStream &stream) {
+ ResourceType resource;
+ while (resource.loadFromStream(stream))
+ _list.push_back(resource);
+ return true;
+ }
+ Common::Array<ResourceType> _list;
+};
+
+typedef ResourceList<Mob> MobList;
+typedef ResourceList<Object> ObjectList;
+
struct PrinceGameDescription;
class PrinceEngine;
class GraphicsMan;
class Script;
class Debugger;
-class ObjectList;
-class MobList;
class MusicPlayer;
class VariaTxt;
class Cursor;
@@ -124,6 +140,8 @@ private:
void scrollCameraLeft(int16 delta);
void drawScreen();
void showTexts();
+ void init();
+ void showLogo();
uint32 getTextWidth(const char *s);
void debugEngine(const char *s, ...);
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp
index a25e8241e1..94fbcba688 100644
--- a/engines/prince/script.cpp
+++ b/engines/prince/script.cpp
@@ -246,9 +246,9 @@ void Script::O_CHECKANIMFRAME() {
}
void Script::O_PUTBACKANIM() {
- uint16 roomId = readScript16bits();
- uint16 slot = readScript16bits();
- uint32 animId = readScript32bits();
+ uint16 roomId = readScriptValue();
+ uint16 slot = readScriptValue();
+ int32 animId = readScript32bits();
debugScript("O_PUTBACKANIM roomId %d, slot %d, animId %d", roomId, slot, animId);
}