aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorD G Turner2012-07-07 13:46:28 +0100
committerD G Turner2012-07-07 13:46:28 +0100
commit313502e2eea976899202064353675a61aa8c56a6 (patch)
tree212dc1e1a853e8c5c4dabeae4080c8d819fa6eed
parent91d6db93f00eb4ccf4179c26ee47c0c02ed2ed5e (diff)
downloadscummvm-rg350-313502e2eea976899202064353675a61aa8c56a6.tar.gz
scummvm-rg350-313502e2eea976899202064353675a61aa8c56a6.tar.bz2
scummvm-rg350-313502e2eea976899202064353675a61aa8c56a6.zip
TEENAGENT: Remove static Resources class Instance.
This is replaced by an engine instance. This should prevent issues with Return To Launcher and may remove issues with file handles.
-rw-r--r--engines/teenagent/actor.cpp6
-rw-r--r--engines/teenagent/actor.h9
-rw-r--r--engines/teenagent/callbacks.cpp294
-rw-r--r--engines/teenagent/dialog.cpp17
-rw-r--r--engines/teenagent/dialog.h22
-rw-r--r--engines/teenagent/inventory.cpp47
-rw-r--r--engines/teenagent/inventory.h4
-rw-r--r--engines/teenagent/music.cpp12
-rw-r--r--engines/teenagent/music.h7
-rw-r--r--engines/teenagent/resources.cpp25
-rw-r--r--engines/teenagent/resources.h8
-rw-r--r--engines/teenagent/scene.cpp103
-rw-r--r--engines/teenagent/scene.h7
-rw-r--r--engines/teenagent/teenagent.cpp28
-rw-r--r--engines/teenagent/teenagent.h3
15 files changed, 283 insertions, 309 deletions
diff --git a/engines/teenagent/actor.cpp b/engines/teenagent/actor.cpp
index cb8c798fb6..f9bf4c84ab 100644
--- a/engines/teenagent/actor.cpp
+++ b/engines/teenagent/actor.cpp
@@ -22,13 +22,14 @@
#include "teenagent/actor.h"
#include "teenagent/objects.h"
#include "teenagent/resources.h"
+#include "teenagent/teenagent.h"
#include "common/random.h"
#include "common/textconsole.h"
namespace TeenAgent {
-Actor::Actor() : head_index(0), idle_type(0) {}
+Actor::Actor(TeenAgentEngine *vm) : _vm(vm), head_index(0), idle_type(0) {}
//idle animation lists at dseg: 0x6540
Common::Rect Actor::renderIdle(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, uint zoom, Common::RandomSource &rnd) {
@@ -37,10 +38,9 @@ Common::Rect Actor::renderIdle(Graphics::Surface *surface, const Common::Point &
debug(0, "switched to idle animation %u", idle_type);
}
- Resources *res = Resources::instance();
byte *frames_idle;
do {
- frames_idle = res->dseg.ptr(res->dseg.get_word(0x6540 + idle_type * 2)) + index;
+ frames_idle = _vm->res->dseg.ptr(_vm->res->dseg.get_word(0x6540 + idle_type * 2)) + index;
index += delta_frame;
if (*frames_idle == 0) {
idle_type = rnd.getRandomNumber(2);
diff --git a/engines/teenagent/actor.h b/engines/teenagent/actor.h
index 9a7d395547..a2b8ef3d6a 100644
--- a/engines/teenagent/actor.h
+++ b/engines/teenagent/actor.h
@@ -28,11 +28,18 @@ class RandomSource;
namespace TeenAgent {
+class TeenAgentEngine;
+
class Actor : public Animation {
+private:
+ TeenAgentEngine *_vm;
+
uint head_index;
uint idle_type;
+
public:
- Actor();
+ Actor(TeenAgentEngine *vm);
+
Common::Rect render(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, bool head, uint zoom);
Common::Rect renderIdle(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, uint zoom, Common::RandomSource &rnd);
};
diff --git a/engines/teenagent/callbacks.cpp b/engines/teenagent/callbacks.cpp
index 8882531d27..a3e215fc7f 100644
--- a/engines/teenagent/callbacks.cpp
+++ b/engines/teenagent/callbacks.cpp
@@ -34,7 +34,6 @@ namespace TeenAgent {
#define INC_FLAG(addr) (++*res->dseg.ptr(addr))
void TeenAgentEngine::rejectMessage() {
- Resources *res = Resources::instance();
//random reject message:
uint i = _rnd.getRandomNumber(3);
//debug(0, "reject message: %s", (const char *)res->dseg.ptr(res->dseg.get_word(0x339e + 2 * i)));
@@ -46,7 +45,6 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
if (addr == 0)
return false;
- Resources *res = Resources::instance();
debug(0, "processCallback(%04x)", addr);
byte *code = res->cseg.ptr(addr);
@@ -97,7 +95,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playAnimation(913, 1);
setOns(1, 109);
setLan(2, 1);
- Dialog::show(scene, 0x748e, 914, 915, 0xe7, 0xd7, 2, 1);
+ Dialog::show(this, scene, 0x748e, 914, 915, 0xe7, 0xd7, 2, 1);
displayCredits(0xe3c2);
loadScene(42, 139, 156, 3);
@@ -115,12 +113,12 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
loadScene(40, 139, 156, 3);
playMusic(3);
- Dialog::show(scene, 0x750d, 920, 924, 0xe7, 0xeb, 1, 2); //as i told you, our organization...
+ Dialog::show(this, scene, 0x750d, 920, 924, 0xe7, 0xeb, 1, 2); //as i told you, our organization...
playSound(26, 50);
playAnimation(925, 0, true);
playAnimation(926, 1, true);
waitAnimation();
- Dialog::show(scene, 0x78a6, 927, 920, 0xeb, 0xe7, 2, 1);
+ Dialog::show(this, scene, 0x78a6, 927, 920, 0xeb, 0xe7, 2, 1);
displayCredits(0xe3ff);
loadScene(39, 139, 156, 3);
@@ -135,7 +133,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playSound(81, 21);
playAnimation(928, 1);
setOns(0, 112);
- Dialog::showMono(scene, 0x78e1, 929, 0xd1, 1); //he's coming
+ Dialog::showMono(this, scene, 0x78e1, 929, 0xd1, 1); //he's coming
showActor();
moveTo(319, 150, 1, true);
moveTo(63, 150, 1);
@@ -151,17 +149,17 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playMusic(3);
loadScene(40, 50, 186, 1);
setOns(0, 113);
- Dialog::show(scene, 0x78f1, 919, 0, 0xe7, 0xd1, 1, 0);
+ Dialog::show(this, scene, 0x78f1, 919, 0, 0xe7, 0xd1, 1, 0);
moveTo(196, 186, 1);
- Dialog::show(scene, 0x7958, 0, 920, 0xd1, 0xe7, 0, 1);
+ Dialog::show(this, scene, 0x7958, 0, 920, 0xd1, 0xe7, 0, 1);
playActorAnimation(932);
- Dialog::show(scene, 0x7e07, 0, 920, 0xd1, 0xe7, 0, 1);
+ Dialog::show(this, scene, 0x7e07, 0, 920, 0xd1, 0xe7, 0, 1);
playActorAnimation(932);
- Dialog::show(scene, 0x7e1a, 0, 920, 0xd1, 0xe7, 0, 1);
+ Dialog::show(this, scene, 0x7e1a, 0, 920, 0xd1, 0xe7, 0, 1);
playActorAnimation(932);
- Dialog::show(scene, 0x7e2c, 0, 922, 0xd1, 0xe7, 0, 1);
+ Dialog::show(this, scene, 0x7e2c, 0, 922, 0xd1, 0xe7, 0, 1);
playActorAnimation(933);
- Dialog::show(scene, 0x7e70, 0, 920, 0xd1, 0xe7, 0, 1);
+ Dialog::show(this, scene, 0x7e70, 0, 920, 0xd1, 0xe7, 0, 1);
moveTo(174, 186, 1);
playAnimation(851, 0, true);
playActorAnimation(934, true);
@@ -211,7 +209,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
SET_FLAG(0xDBE4, 1);
} else {
processCallback(0x4173);
- Dialog::pop(scene, 0xDB72, 0, 0, 0xd1, 0xd1, 0, 0);
+ Dialog::pop(this, scene, 0xDB72, 0, 0, 0xd1, 0xd1, 0, 0);
}
return true;
}
@@ -286,15 +284,15 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playAnimation(812, 0, true);
playActorAnimation(811);
- Dialog::show(scene, 0x6117, 0, 813, 0xd1, 0xec, 0, 1);
+ Dialog::show(this, scene, 0x6117, 0, 813, 0xd1, 0xec, 0, 1);
loadScene(6, 230, 184);
playMusic(5);
- Dialog::show(scene, 0x626a, 0, 814, 0xd1, 0xec, 0, 1);
+ Dialog::show(this, scene, 0x626a, 0, 814, 0xd1, 0xec, 0, 1);
playSound(4, 14);
playAnimation(815, 0);
setOns(1, 0);
- Dialog::showMono(scene, 0x62dc, 0, 0xd1, 0);
+ Dialog::showMono(this, scene, 0x62dc, 0, 0xd1, 0);
SET_FLAG(0xDBDF, 1);
}
@@ -358,7 +356,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
SET_FLAG(0xdbdd, 3);
scene->getObject(4)->setName("body");
} else {
- if (Dialog::pop(scene, 0xdb5c, 0, 0, 0xd1, 0xd1, 0, 0) != 0x636b) //not 'im getting hungry'
+ if (Dialog::pop(this, scene, 0xdb5c, 0, 0, 0xd1, 0xd1, 0, 0) != 0x636b) //not 'im getting hungry'
return true;
wait(100);
@@ -491,7 +489,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
if (CHECK_FLAG(0xDBE7, 1)) {
moveTo(140, 152, 1);
if (CHECK_FLAG(0xDBE8, 1)) {
- Dialog::showMono(scene, 0x6f20, 0, 0xd1, 0); //aren't you thirsty?
+ Dialog::showMono(this, scene, 0x6f20, 0, 0xd1, 0); //aren't you thirsty?
displayMessage(0x5883, 0xef, 21472);
//reloadLan();
setLan(1, 0);
@@ -510,21 +508,21 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
} else {
if (CHECK_FLAG(0xDBDF, 3)) {
if (CHECK_FLAG(0xDBE3, 1)) {
- Dialog::show(scene, 0x6BD6, 0, 857, 0xd1, 0xef, 0, 1);
+ Dialog::show(this, scene, 0x6BD6, 0, 857, 0xd1, 0xef, 0, 1);
} else {
- Dialog::show(scene, 0x69B5, 0, 857, 0xd1, 0xef, 0, 1); //taking mug
+ Dialog::show(this, scene, 0x69B5, 0, 857, 0xd1, 0xef, 0, 1); //taking mug
playActorAnimation(859, true);
playAnimation(858, 0, true);
waitAnimation();
playSound(75, 6);
playActorAnimation(860);
- Dialog::show(scene, 0x69C2, 0, 857, 0xd1, 0xef, 0, 1);
+ Dialog::show(this, scene, 0x69C2, 0, 857, 0xd1, 0xef, 0, 1);
inventory->add(0x55);
SET_FLAG(0xDBE3, 1);
SET_FLAG(0xDBF0, 0);
}
} else {
- Dialog::pop(scene, 0xDB68, 0, 857, 0xd1, 0xef, 0, 1);
+ Dialog::pop(this, scene, 0xDB68, 0, 857, 0xd1, 0xef, 0, 1);
}
}
return true;
@@ -547,7 +545,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
return true;
case 0x483a:
- Dialog::pop(scene, 0xdb82, 0, 0, 0xd1, 0xd1, 0, 0);
+ Dialog::pop(this, scene, 0xdb82, 0, 0, 0xd1, 0xd1, 0, 0);
return true;
case 0x4844:
@@ -572,7 +570,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
} else if (CHECK_FLAG(0xDBE7, 1)) {
displayMessage(0x5894);
} else {
- Dialog::pop(scene, 0xDB8A, 0, 857, 0xd1, 0xef, 0, 1);
+ Dialog::pop(this, scene, 0xDB8A, 0, 857, 0xd1, 0xef, 0, 1);
}
return true;
@@ -591,17 +589,17 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playSound(55, 1);
playSound(24, 12);
playAnimation(885, 0);
- Dialog::show(scene, 0x67e5, 886, 0, 0xd0, 0xd1, 1, 0);
+ Dialog::show(this, scene, 0x67e5, 886, 0, 0xd0, 0xd1, 1, 0);
playMusic(3);
loadScene(40, 198, 186, 1);
- Dialog::show(scene, 0x7f20, 0, 920, 0xd1, 0xe7, 0, 1);
+ Dialog::show(this, scene, 0x7f20, 0, 920, 0xd1, 0xe7, 0, 1);
inventory->clear();
inventory->add(0x1d);
displayCredits(0xe45c);
loadScene(1, 198, 186);
hideActor();
playActorAnimation(956);
- Dialog::showMono(scene, 0x8bc4, 957, 0xd1, 1);
+ Dialog::showMono(this, scene, 0x8bc4, 957, 0xd1, 1);
waitAnimation();
loadScene(15, 157, 199, 1);
playMusic(6);
@@ -620,9 +618,9 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
case 0x4c70:
if (CHECK_FLAG(0xDBE2, 0)) {
if (CHECK_FLAG(0xDBDA, 1)) { //papers are shown
- Dialog::pop(scene, 0xDB4C, 0, 809, 0xd1, 0xd0, 0, 1);
+ Dialog::pop(this, scene, 0xDB4C, 0, 809, 0xd1, 0xd0, 0, 1);
} else {
- Dialog::pop(scene, 0xDB40, 0, 809, 0xd1, 0xd0, 0, 1);
+ Dialog::pop(this, scene, 0xDB40, 0, 809, 0xd1, 0xd0, 0, 1);
}
} else {
displayMessage(0x5722);
@@ -640,15 +638,15 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
if (CHECK_FLAG(0xdbda, 1)) { //papers are shown
loadScene(5, 124, 199);
} else {
- Dialog::show(scene, 0x5FE9, 0, 809, 0xd1, 0xd0, 0, 1);
+ Dialog::show(this, scene, 0x5FE9, 0, 809, 0xd1, 0xd0, 0, 1);
moveTo(269, 175, 4);
- Dialog::pop(scene, 0xDB56, 0, 809, 0xd1, 0xd0, 0, 1);
+ Dialog::pop(this, scene, 0xDB56, 0, 809, 0xd1, 0xd0, 0, 1);
}
return true;
case 0x4cf1: { //talking with mansion guard
SET_FLAG(0xda96, 1);
- if (Dialog::pop(scene, 0xdaa6, 0, 529, 0xd1, 0xd9, 0, 1) != 0x1b4)
+ if (Dialog::pop(this, scene, 0xdaa6, 0, 529, 0xd1, 0xd9, 0, 1) != 0x1b4)
return true;
Common::Point p = scene->getPosition();
@@ -663,24 +661,24 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
moveTo(p, 2);
inventory->add(0x13);
- Dialog::pop(scene, 0xdaa6, 0, 529, 0xd1, 0xd9, 0, 1);
+ Dialog::pop(this, scene, 0xdaa6, 0, 529, 0xd1, 0xd9, 0, 1);
}
return true;
case 0x4d94: //talking with fatso
- Dialog::show(scene, 0x33bd, 0, 666, 0xd1, 0xd0, 0, 2);
+ Dialog::show(this, scene, 0x33bd, 0, 666, 0xd1, 0xd0, 0, 2);
displayAsyncMessage(0x49ae, /*25060*/ 35000, 1, 10, 0xd0);
playSound(5, 3);
playAnimation(667, 1);
playAnimation(668, 1);
setOns(2, 50);
- Dialog::show(scene, 0x36c7, 0, 666, 0xd1, 0xd0, 0, 2);
+ Dialog::show(this, scene, 0x36c7, 0, 666, 0xd1, 0xd0, 0, 2);
setOns(3, 0);
setFlag(0xDBEC, 0);
reloadLan();
playSound(82, 19);
playAnimation(669, 1);
- Dialog::showMark(scene, 0x3779);
+ Dialog::showMark(this, scene, 0x3779);
enableObject(15);
disableObject(8);
return true;
@@ -799,7 +797,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playSound(17, 5);
playAnimation(545, 0);
- Dialog::show(scene, 0x0917, 0, 546, 0xd1, 0xd9, 0, 1);
+ Dialog::show(this, scene, 0x0917, 0, 546, 0xd1, 0xd9, 0, 1);
SET_FLAG(0xDA96, 1);
SET_FLAG(0xDA97, 0);
return true;
@@ -844,7 +842,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
return true;
case 0x55a8: {
- uint16 d = Dialog::pop(scene, 0xdb08, 0, 0, 0xd1, 0xd1, 0, 0);
+ uint16 d = Dialog::pop(this, scene, 0xdb08, 0, 0, 0xd1, 0xd1, 0, 0);
if (d == 0x2c5d) {
waitLanAnimationFrame(1, 0x23);
setOns(0, 0);
@@ -911,7 +909,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
case 0x5d88:
if (CHECK_FLAG(0xDBA5, 1)) { //dry laundry
SET_FLAG(0xDBA5, 2);
- Dialog::show(scene, 0x1F4F, 0, 523, 0xd1, 0xe5, 0, 1);
+ Dialog::show(this, scene, 0x1F4F, 0, 523, 0xd1, 0xe5, 0, 1);
//waitLanAnimationFrame(1, 1); //another long waiting
playAnimation(604, 0);
@@ -924,9 +922,9 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
setOns(0, 33);
loadScene(23, scene->getPosition());
playAnimation(605, 0);
- Dialog::show(scene, 0x2002, 0, 523, 0xd1, 0xe5, 0, 1);
+ Dialog::show(this, scene, 0x2002, 0, 523, 0xd1, 0xe5, 0, 1);
} else {
- uint16 d = Dialog::pop(scene, 0xdada, 0, 523, 0xd1, 0xe5, 0, 1);
+ uint16 d = Dialog::pop(this, scene, 0xdada, 0, 523, 0xd1, 0xe5, 0, 1);
if (d == 0x1913) {
wait(100);
moveRel(0, 0, 3);
@@ -939,9 +937,9 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
case 0x5ff3: //get duster
if (CHECK_FLAG(0xDB9A, 0)) {
- Dialog::pop(scene, 0xdaf6, 0, 523, 0xd1, 0xe5, 0, 1);
+ Dialog::pop(this, scene, 0xdaf6, 0, 523, 0xd1, 0xe5, 0, 1);
} else {
- Dialog::show(scene, 0x1e1e, 0, 523, 0xd1, 0xe5, 0, 1);
+ Dialog::show(this, scene, 0x1e1e, 0, 523, 0xd1, 0xe5, 0, 1);
wait(50);
inventory->add(12);
disableObject(12);
@@ -994,16 +992,16 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
return true;
case 0x63dc:
- Dialog::showMono(scene, 0x3375, 0, 0xd1, 0);
+ Dialog::showMono(this, scene, 0x3375, 0, 0xd1, 0);
return true;
case 0x646e:
case 0x6475:
- Dialog::showMono(scene, 0x32C1, 0, 0xd1, 0);
+ Dialog::showMono(this, scene, 0x32C1, 0, 0xd1, 0);
return true;
case 0x6479:
- Dialog::showMono(scene, 0x325e, 0, 0xd1, 0);
+ Dialog::showMono(this, scene, 0x325e, 0, 0xd1, 0);
return true;
case 0x6507:
@@ -1091,7 +1089,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
if (CHECK_FLAG(0xDBAF, 1))
return false;
- Dialog::showMono(scene, 0x2193, 0, 0xd1, 0);
+ Dialog::showMono(this, scene, 0x2193, 0, 0xd1, 0);
SET_FLAG(0xDBAF, 1);
return true;
@@ -1198,12 +1196,12 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
wait(200);
playAnimation(0, 1);
setOns(0, 0);
- Dialog::showMono(scene, 0x63a5, 830, 0xd0, 1);
+ Dialog::showMono(this, scene, 0x63a5, 830, 0xd0, 1);
loadScene(7, 130, 195, 2);
playMusic(4);
setLan(1, 1);
wait(100);
- Dialog::show(scene, 0x6406, 0, 832, 0xd1, 0xec, 0, 1);
+ Dialog::show(this, scene, 0x6406, 0, 832, 0xd1, 0xec, 0, 1);
//playAnimation(831, 1);
@@ -1224,14 +1222,14 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
waitAnimation();
setOns(0, 94);
- Dialog::show(scene, 0x65e9, 0, 832, 0xd1, 0xec, 0, 1);
+ Dialog::show(this, scene, 0x65e9, 0, 832, 0xd1, 0xec, 0, 1);
enableObject(12);
SET_FLAG(0xdbe0, 1);
}
return true;
case 0x7e4f: //giving magazine to captain
- Dialog::show(scene, 0x66c0, 0, 856, 0xd1, 0xec, 0, 1);
+ Dialog::show(this, scene, 0x66c0, 0, 856, 0xd1, 0xec, 0, 1);
playSound(5, 3);
playActorAnimation(852, true);
playActorAnimation(853, true);
@@ -1243,7 +1241,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playAnimation(856, 1);
playSound(5, 3);
//playActorAnimation(854);
- Dialog::show(scene, 0x66fe, 0, 856, 0xd1, 0xec, 0, 1);
+ Dialog::show(this, scene, 0x66fe, 0, 856, 0xd1, 0xec, 0, 1);
playAnimation(855, 1);
wait(200);
moveTo(30, 181, 0);
@@ -1263,7 +1261,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playAnimation(877, 1);
playAnimation(880, 1, true);
- Dialog::show(scene, 0x6f0e, 0, 857, 0xd1, 0xef, 0, 1);
+ Dialog::show(this, scene, 0x6f0e, 0, 857, 0xd1, 0xef, 0, 1);
setOns(2, 0x6a);
reloadLan();
playAnimation(878, 0);
@@ -1293,13 +1291,13 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playSound(5, 2);
playSound(5, 18);
playActorAnimation(810);
- Dialog::show(scene, 0x60BF, 0, 809, 0xd1, 0xd0, 0, 1);
+ Dialog::show(this, scene, 0x60BF, 0, 809, 0xd1, 0xd0, 0, 1);
SET_FLAG(0xDBDA, 1);
}
return true;
case 0x80c3: //show kaleydoscope to the guard
- Dialog::show(scene, 0x6811, 0, 809, 0xd1, 0xd0, 0, 1);
+ Dialog::show(this, scene, 0x6811, 0, 809, 0xd1, 0xd0, 0, 1);
playSound(5, 3);
playSound(5, 30);
playSound(26, 14);
@@ -1324,7 +1322,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
SET_FLAG(0xDB99, 1);
playSound(57, 6);
playActorAnimation(536);
- Dialog::showMono(scene, 0x30c3, 0, 0xd1, 0);
+ Dialog::showMono(this, scene, 0x30c3, 0, 0xd1, 0);
inventory->add(0x8);
}
return true;
@@ -1449,7 +1447,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
return true;
case 0x58a2:
- Dialog::pop(scene, 0xdaba, 0, 502, 0xd1, 0xe5, 0, 1);
+ Dialog::pop(this, scene, 0xdaba, 0, 502, 0xd1, 0xe5, 0, 1);
scene->getObject(13)->setName((const char *)res->dseg.ptr(0x92e5));
return true;
@@ -1528,13 +1526,13 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
return true;
case 0x5b3a://Click on dog
- Dialog::popMark(scene, 0xDB14);
+ Dialog::popMark(this, scene, 0xDB14);
return true;
case 0x5b59: //picking up the rope
- Dialog::showMark(scene, 0x2cbd);
+ Dialog::showMark(this, scene, 0x2cbd);
wait(150);
- Dialog::showMark(scene, 0x2dc2);
+ Dialog::showMark(this, scene, 0x2dc2);
moveRel(0, -12, 0);
playSound(34, 5);
playActorAnimation(607);
@@ -1550,7 +1548,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
return true;
case 0x5be1://Talk to grandpa
- Dialog::pop(scene, 0xDAC4, 0, 522, 0xd1, 0xd8, 0, 1);
+ Dialog::pop(this, scene, 0xDAC4, 0, 522, 0xd1, 0xd8, 0, 1);
return true;
case 0x5bee:
@@ -1565,7 +1563,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
displayMessage(0x3bac);
} else {
if (!CHECK_FLAG(0xDB92, 1))
- Dialog::show(scene, 0x15a0, 0, 522, 0xd1, 0xd8, 0, 1); //can I search your drawers?
+ Dialog::show(this, scene, 0x15a0, 0, 522, 0xd1, 0xd8, 0, 1); //can I search your drawers?
playSound(66, 5);
playSound(67, 20);
@@ -1584,7 +1582,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
setOns(0, 0);
playActorAnimation(520);
} else {
- Dialog::pop(scene, 0xDACE, 0, 522, 0xd1, 0xd8, 0, 1);
+ Dialog::pop(this, scene, 0xDACE, 0, 522, 0xd1, 0xd8, 0, 1);
}
return true;
@@ -1602,7 +1600,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
disableObject(13);
inventory->add(7);
} else {
- Dialog::pop(scene, 0xDAD4, 0, 522, 0xd1, 0xd8, 0, 1);
+ Dialog::pop(this, scene, 0xDAD4, 0, 522, 0xd1, 0xd8, 0, 1);
}
return true;
@@ -1611,7 +1609,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
displayMessage(0x3d59);
} else {
moveTo(245, 198, 1);
- Dialog::show(scene, 0x21d7, 0, 524, 0xd1, 0xe5, 0, 2);
+ Dialog::show(this, scene, 0x21d7, 0, 524, 0xd1, 0xe5, 0, 2);
//waitLanAnimationFrame(2, 1); //too long, about 200 frames! seems to be present in original game (sic)
SET_FLAG(0xDB97, 1);
for (byte i = 10; i <= 20; i += 2)
@@ -1633,7 +1631,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playSound(55, 5);
playActorAnimation(527);
wait(50);
- Dialog::show(scene, 0x2219, 0, 524, 0xd1, 0xe5, 0, 2);
+ Dialog::show(this, scene, 0x2219, 0, 524, 0xd1, 0xe5, 0, 2);
scene->getObject(2)->setName((const char *)res->dseg.ptr(0x9820));
}
return true;
@@ -1648,7 +1646,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
if (CHECK_FLAG(0xDBB1, 1)) {
displayMessage(0x4380);
} else {
- Dialog::pop(scene, 0xDAFC, 0, 523, 0xd1, 0xe5, 0, 1);
+ Dialog::pop(this, scene, 0xDAFC, 0, 523, 0xd1, 0xe5, 0, 1);
}
return true;
@@ -1669,12 +1667,12 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
case 0x60b5:
if (CHECK_FLAG(0xDBAE, 1)) {
processCallback(0x60d9);
- Dialog::showMark(scene, 0x2fdd);
+ Dialog::showMark(this, scene, 0x2fdd);
} else {
- Dialog::showMark(scene, 0x2e41);
+ Dialog::showMark(this, scene, 0x2e41);
processCallback(0x60d9);
wait(100);
- Dialog::showMark(scene, 0x2e6d);
+ Dialog::showMark(this, scene, 0x2e6d);
}
return true;
@@ -1717,7 +1715,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
case 0x61e9:
if (CHECK_FLAG(0xDBA4, 1)) {
- Dialog::popMark(scene, 0xdb1e);
+ Dialog::popMark(this, scene, 0xdb1e);
} else
processCallback(0x61fe);
@@ -1902,7 +1900,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
return true;
case 0x70bb:
- Dialog::pop(scene, 0xdb24, 0, 709, 0xd1, 0xef, 0, 1);
+ Dialog::pop(this, scene, 0xdb24, 0, 709, 0xd1, 0xef, 0, 1);
return true;
case 0x71ae:
@@ -1917,7 +1915,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
SET_FLAG(0xDBCE, 1);
}
} else
- Dialog::showMark(scene, 0x3c9d);
+ Dialog::showMark(this, scene, 0x3c9d);
return true;
case 0x70c8:
@@ -2038,7 +2036,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playActorAnimation(698);
setOns(0, 52);
setOns(2, 61);
- Dialog::showMark(scene, 0x38b6);
+ Dialog::showMark(this, scene, 0x38b6);
enableObject(11);
SET_FLAG(0xDBC4, 1);
}
@@ -2049,7 +2047,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
displayMessage(0x4dbb);
} else {
SET_FLAG(0xDBC9, 1);
- Dialog::showMark(scene, 0x3aca);
+ Dialog::showMark(this, scene, 0x3aca);
playSound(61, 5);
playSound(5, 14);
playActorAnimation(705);
@@ -2073,10 +2071,10 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playActorAnimation(979);
loadScene(37, 51, 183);
- Dialog::show(scene, 0x54ea, 768, 769, 0xd9, 0xe5, 1, 2);
+ Dialog::show(this, scene, 0x54ea, 768, 769, 0xd9, 0xe5, 1, 2);
playAnimation(770, 0, true, true, true);
playAnimation(771, 1, true, true, true);
- Dialog::showMono(scene, 0x5523, 0, 0xd1, 0);
+ Dialog::showMono(this, scene, 0x5523, 0, 0xd1, 0);
playAnimation(770, 0, true, true, true);
playAnimation(771, 1, true, true, true);
playSound(5, 3);
@@ -2090,11 +2088,11 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
waitAnimation();
setOns(0, 74);
hideActor();
- Dialog::showMono(scene, 0x5556, 775, 0xd0, 1);
+ Dialog::showMono(this, scene, 0x5556, 775, 0xd0, 1);
playAnimation(771, 1, true, true, true);
playAnimation(776, 0);
- Dialog::show(scene, 0x55f7, 777, 778, 0xd0, 0xe5, 1, 2); //i have to kill you anyway
+ Dialog::show(this, scene, 0x55f7, 777, 778, 0xd0, 0xe5, 1, 2); //i have to kill you anyway
playAnimation(779, 0, true, true, true);
playAnimation(780, 1, true, true, true);
@@ -2151,7 +2149,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
setOns(0, 80);
playAnimation(792, 3, true, true, true);
- Dialog::show(scene, 0x5665, 0, 791, 0xd1, 0xd0, 0, 4);
+ Dialog::show(this, scene, 0x5665, 0, 791, 0xd1, 0xd0, 0, 4);
playAnimation(792, 3, true, true, true);
moveTo(40, 171, 4);
@@ -2170,7 +2168,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
return true;
case 0x783d:
- Dialog::pop(scene, 0xdb36, 0, 797, 0xd1, 0xd0, 0, 1);
+ Dialog::pop(this, scene, 0xdb36, 0, 797, 0xd1, 0xd0, 0, 1);
return true;
case 0x7966:
@@ -2185,7 +2183,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
case 0x7ab9:
if (CHECK_FLAG(0xDBB6, 1))
return false;
- Dialog::showMono(scene, 0x37d0, 0, 0xd1, 0);
+ Dialog::showMono(this, scene, 0x37d0, 0, 0xd1, 0);
SET_FLAG(0xDBB6, 1);
return true;
@@ -2309,18 +2307,18 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
return false;
case 0x8117:
- Dialog::show(scene, 0x0a41, 0, 529, 0xd1, 0xd9, 0, 1);
+ Dialog::show(this, scene, 0x0a41, 0, 529, 0xd1, 0xd9, 0, 1);
playSound(5, 2);
playSound(5, 44);
playAnimation(642, 0, true);
playActorAnimation(641, true);
waitAnimation();
- Dialog::show(scene, 0x0aff, 0, 529, 0xd1, 0xd9, 0, 1);
+ Dialog::show(this, scene, 0x0aff, 0, 529, 0xd1, 0xd9, 0, 1);
wait(170);
- Dialog::show(scene, 0x0ba0, 0, 529, 0xd1, 0xd9, 0, 1);
+ Dialog::show(this, scene, 0x0ba0, 0, 529, 0xd1, 0xd9, 0, 1);
moveRel(0, 1, 0);
wait(100);
- Dialog::show(scene, 0x0c10, 0, 529, 0xd1, 0xd9, 0, 1);
+ Dialog::show(this, scene, 0x0c10, 0, 529, 0xd1, 0xd9, 0, 1);
inventory->remove(50);
processCallback(0x9d45);
return true;
@@ -2387,7 +2385,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
case 0x8312: //hedgehog + plastic apple
- Dialog::showMark(scene, 0x3000);
+ Dialog::showMark(this, scene, 0x3000);
setLan(1, 0);
playSound(5, 24);
playSound(26, 32);
@@ -2509,7 +2507,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
displayMessage(0x3d40);
} else {
SET_FLAG(0xDB92, 1);
- Dialog::show(scene, 0x0fcd, 0, 502, 0xd0, 0xe5, 0, 1);
+ Dialog::show(this, scene, 0x0fcd, 0, 502, 0xd0, 0xe5, 0, 1);
waitLanAnimationFrame(1, 7);
playSound(5, 16);
playSound(1, 25);
@@ -2599,16 +2597,16 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
case 0x88de:
playSound(5, 2);
- Dialog::show(scene, 0x1B5F, 0, 523, 0xd1, 0xe5, 0, 1);
+ Dialog::show(this, scene, 0x1B5F, 0, 523, 0xd1, 0xe5, 0, 1);
playActorAnimation(537, true);
playAnimation(538, 0, true);
waitAnimation();
wait(100);
- Dialog::show(scene, 0x1BE0, 0, 523, 0xd1, 0xe5, 0, 1);
+ Dialog::show(this, scene, 0x1BE0, 0, 523, 0xd1, 0xe5, 0, 1);
return true;
case 0x890b:
- Dialog::pop(scene, 0xDAF0, 0, 523, 0xd1, 0xe5, 0, 1);
+ Dialog::pop(this, scene, 0xDAF0, 0, 523, 0xd1, 0xe5, 0, 1);
return true;
case 0x8918://give flower to old lady
@@ -2630,25 +2628,25 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
return true;
case 0x8942:
- Dialog::show(scene, 0x2293, 0, 524, 0xd1, 0xe5, 0, 2);
+ Dialog::show(this, scene, 0x2293, 0, 524, 0xd1, 0xe5, 0, 2);
playSound(5, 10);
playActorAnimation(540, true);
playAnimation(539, 1, true);
waitAnimation();
wait(100);
- Dialog::show(scene, 0x24b1, 0, 524, 0xd1, 0xe5, 0, 2);
+ Dialog::show(this, scene, 0x24b1, 0, 524, 0xd1, 0xe5, 0, 2);
wait(50);
- Dialog::show(scene, 0x24d7, 0, 524, 0xd1, 0xe5, 0, 2);
- Dialog::show(scene, 0x2514, 0, 524, 0xd1, 0xe5, 0, 2);
+ Dialog::show(this, scene, 0x24d7, 0, 524, 0xd1, 0xe5, 0, 2);
+ Dialog::show(this, scene, 0x2514, 0, 524, 0xd1, 0xe5, 0, 2);
wait(50);
moveRel(0, 1, 0);
- Dialog::show(scene, 0x2570, 0, 524, 0xd1, 0xe5, 0, 2);
+ Dialog::show(this, scene, 0x2570, 0, 524, 0xd1, 0xe5, 0, 2);
moveRel(0, -1, 0);
wait(50);
return true;
case 0x89aa:
- Dialog::pop(scene, 0xdb02, 0, 524, 0xd1, 0xe5, 0, 2);
+ Dialog::pop(this, scene, 0xdb02, 0, 524, 0xd1, 0xe5, 0, 2);
return true;
case 0x89b7:
@@ -2663,14 +2661,14 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
case 0x89cc:
inventory->remove(23);
playSound(5, 6);
- Dialog::show(scene, 0x2634, 0, 524, 0xd1, 0xe5, 0, 2);
+ Dialog::show(this, scene, 0x2634, 0, 524, 0xd1, 0xe5, 0, 2);
playActorAnimation(555, true);
playAnimation(556, 1, true);
waitAnimation();
playActorAnimation(557, true);
playAnimation(558, 1, true);
waitAnimation();
- Dialog::show(scene, 0x2971, 0, 524, 0xd1, 0xe5, 0, 2);
+ Dialog::show(this, scene, 0x2971, 0, 524, 0xd1, 0xe5, 0, 2);
inventory->add(24);
return true;
@@ -2680,21 +2678,21 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
inventory->remove(26);
inventory->add(27);
wait(50);
- Dialog::show(scene, 0x1ecd, 0, 523, 0xd1, 0xe5, 0, 1);
- Dialog::show(scene, 0x1f09, 0, 523, 0xd1, 0xe5, 0, 1);
+ Dialog::show(this, scene, 0x1ecd, 0, 523, 0xd1, 0xe5, 0, 1);
+ Dialog::show(this, scene, 0x1f09, 0, 523, 0xd1, 0xe5, 0, 1);
SET_FLAG(0xDBB1, 1);
return true;
case 0x8a6f: //banknote + ann
if (CHECK_FLAG(0xDBB5, 1)) {
- Dialog::show(scene, 0x2992, 0, 524, 0xd1, 0xe5, 0, 2);
+ Dialog::show(this, scene, 0x2992, 0, 524, 0xd1, 0xe5, 0, 2);
playSound(5, 3);
playSound(5, 20);
playAnimation(671, 1, true);
playActorAnimation(670, true);
waitAnimation();
//playAnimation(672, 1);
- Dialog::show(scene, 0x2a00, 524, 672, 0xd1, 0xe5, 0, 2);
+ Dialog::show(this, scene, 0x2a00, 524, 672, 0xd1, 0xe5, 0, 2);
//playAnimation(672, 1);
playSound(83, 12);
@@ -2866,7 +2864,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
return true;
case 0x8f1d:
- Dialog::showMark(scene, 0x2dd6);
+ Dialog::showMark(this, scene, 0x2dd6);
for (uint i = 16; i <= 30; i += 2)
playSound(56, i);
playSound(2, 64);
@@ -3079,7 +3077,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
}
if (!CHECK_FLAG(0xDBC3, 1)) {
playActorAnimation(695);
- Dialog::showMark(scene, 0x386a);
+ Dialog::showMark(this, scene, 0x386a);
SET_FLAG(0xDBC3, 1);
}
@@ -3222,7 +3220,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
case 0x6c83:
waitLanAnimationFrame(1, 1);
- Dialog::pop(scene, 0xdb2e, 0, 727, 0xd1, 0xef, 0, 1);
+ Dialog::pop(this, scene, 0xdb2e, 0, 727, 0xd1, 0xef, 0, 1);
scene->getObject(1)->setName((const char *)res->dseg.ptr(0xaa94));
SET_FLAG(0xDBD1, 1);
return true;
@@ -3245,49 +3243,49 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
loadScene(11, scene->getPosition());
playAnimation(750, 2);
- Dialog::show(scene, 0x4f50, 751, 529, 0xe5, 0xd9, 2, 1);
+ Dialog::show(this, scene, 0x4f50, 751, 529, 0xe5, 0xd9, 2, 1);
playAnimation(752, 0, true);
playAnimation(753, 1, true);
waitAnimation();
- Dialog::show(scene, 0x5168, 529, 751, 0xd9, 0xe5, 1, 2);
+ Dialog::show(this, scene, 0x5168, 529, 751, 0xd9, 0xe5, 1, 2);
loadScene(30, scene->getPosition());
- Dialog::show(scene, 0x449e, 733, 734, 0xe5, 0xd0, 2, 3);
+ Dialog::show(this, scene, 0x449e, 733, 734, 0xe5, 0xd0, 2, 3);
playSound(75, 13);
playSound(32, 22);
playAnimation(735, 1, true);
playAnimation(736, 2, true);
waitAnimation();
- Dialog::show(scene, 0x46cf, 737, 738, 0xd0, 0xe5, 3, 2);
+ Dialog::show(this, scene, 0x46cf, 737, 738, 0xd0, 0xe5, 3, 2);
playSound(32, 1);
playAnimation(739, 1, true);
playAnimation(740, 2, true);
waitAnimation();
- Dialog::show(scene, 0x4772, 733, 734, 0xe5, 0xd0, 2, 3);
+ Dialog::show(this, scene, 0x4772, 733, 734, 0xe5, 0xd0, 2, 3);
playAnimation(742, 1, true);
playAnimation(741, 2, true);
waitAnimation();
- Dialog::show(scene, 0x481c, 743, 733, 0xd0, 0xe5, 3, 2); //where's my wallet??
+ Dialog::show(this, scene, 0x481c, 743, 733, 0xd0, 0xe5, 3, 2); //where's my wallet??
playAnimation(744, 1, true);
playAnimation(745, 2, true);
waitAnimation();
- Dialog::show(scene, 0x4873, 734, 733, 0xd0, 0xe5, 3, 2);
+ Dialog::show(this, scene, 0x4873, 734, 733, 0xd0, 0xe5, 3, 2);
playAnimation(746, 1, true);
playAnimation(747, 2, true);
waitAnimation();
- Dialog::show(scene, 0x4da5, 734, 734, 0xd0, 0xd0, 3, 3);
- Dialog::show(scene, 0x4eb9, 748, 748, 0xd0, 0xd0, 3, 3);
- Dialog::show(scene, 0x4f15, 749, 749, 0xd0, 0xd0, 3, 3);
- Dialog::show(scene, 0x4f2f, 748, 748, 0xd0, 0xd0, 3, 3);
+ Dialog::show(this, scene, 0x4da5, 734, 734, 0xd0, 0xd0, 3, 3);
+ Dialog::show(this, scene, 0x4eb9, 748, 748, 0xd0, 0xd0, 3, 3);
+ Dialog::show(this, scene, 0x4f15, 749, 749, 0xd0, 0xd0, 3, 3);
+ Dialog::show(this, scene, 0x4f2f, 748, 748, 0xd0, 0xd0, 3, 3);
playMusic(10);
loadScene(32, scene->getPosition());
@@ -3296,15 +3294,15 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playActorAnimation(755);
moveRel(0, 0, 3);
- Dialog::show(scene, 0x51bf, 0, 0, 0xd1, 0xd1, 0, 0);
+ Dialog::show(this, scene, 0x51bf, 0, 0, 0xd1, 0xd1, 0, 0);
hideActor();
loadScene(31, scene->getPosition());
- Dialog::show(scene, 0x539f, 763, 764, 0xd9, 0xd0, 1, 2);
+ Dialog::show(this, scene, 0x539f, 763, 764, 0xd9, 0xd0, 1, 2);
loadScene(32, scene->getPosition());
showActor();
- Dialog::show(scene, 0x52c3, 0, 0, 0xd1, 0xd1, 0, 0); //i have to hide somewhere
+ Dialog::show(this, scene, 0x52c3, 0, 0, 0xd1, 0xd1, 0, 0); //i have to hide somewhere
disableObject(3);
enableObject(7);
@@ -3324,7 +3322,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playActorAnimation(756);
hideActor();
playAnimation(758, 1);
- Dialog::show(scene, 0x52e6, 759, 759, 0xd0, 0xd0, 2, 2); //I have to buy...
+ Dialog::show(this, scene, 0x52e6, 759, 759, 0xd0, 0xd0, 2, 2); //I have to buy...
playSound(40, 5);
playSound(52, 13);
@@ -3340,9 +3338,9 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playSound(58, 12);
playSound(58, 14);
playAnimation(765, 1);
- Dialog::show(scene, 0x5443, 766, 766, 0xd9, 0xd9, 1, 1);
+ Dialog::show(this, scene, 0x5443, 766, 766, 0xd9, 0xd9, 1, 1);
loadScene(32, scene->getPosition());
- Dialog::show(scene, 0x5358, 761, 761, 0xd0, 0xd0, 2, 2);
+ Dialog::show(this, scene, 0x5358, 761, 761, 0xd0, 0xd0, 2, 2);
playAnimation(762, 1);
setOns(2, 0);
showActor();
@@ -3560,7 +3558,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playActorAnimation(728);
waitLanAnimationFrame(1, 1);
- Dialog::show(scene, 0x3d17, 0, 727, 0xd1, 0xef, 0, 1);
+ Dialog::show(this, scene, 0x3d17, 0, 727, 0xd1, 0xef, 0, 1);
SET_FLAG(0xDBD2, 1);
processCallback(0x9175);
return true;
@@ -3581,7 +3579,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playActorAnimation(729);
waitLanAnimationFrame(1, 1);
- Dialog::show(scene, 0x3d70, 0, 727, 0xd1, 0xef, 0, 1);
+ Dialog::show(this, scene, 0x3d70, 0, 727, 0xd1, 0xef, 0, 1);
SET_FLAG(0xDBD3, 1);
processCallback(0x9175);
return true;
@@ -3602,7 +3600,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playActorAnimation(730);
waitLanAnimationFrame(1, 1);
- Dialog::show(scene, 0x3dd6, 0, 727, 0xd1, 0xef, 0, 1);
+ Dialog::show(this, scene, 0x3dd6, 0, 727, 0xd1, 0xef, 0, 1);
SET_FLAG(0xDBD4, 1);
processCallback(0x9175);
return true;
@@ -3613,7 +3611,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playSound(52, 10);
playActorAnimation(711);
moveRel(0, 0, 4);
- Dialog::show(scene, 0x3b21, 0, 709, 0xd1, 0xef, 0, 1);
+ Dialog::show(this, scene, 0x3b21, 0, 709, 0xd1, 0xef, 0, 1);
moveTo(300, 190, 4);
inventory->remove(64);
disableObject(8);
@@ -3623,7 +3621,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playSound(15, 28);
playSound(16, 37);
playAnimation(713, 0);
- Dialog::show(scene, 0x3c0d, 0, 709, 0xd1, 0xef, 0, 1);
+ Dialog::show(this, scene, 0x3c0d, 0, 709, 0xd1, 0xef, 0, 1);
playSound(85, 2);
playAnimation(714, 0);
setLan(1, 0);
@@ -3745,7 +3743,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
SET_FLAG(0xDBC6, 1);
reloadLan();
if (!CHECK_FLAG(0xDBC7, 1)) {
- Dialog::show(scene, 0x392c, 0, 702, 0xd1, 0xd0, 0, 1);
+ Dialog::show(this, scene, 0x392c, 0, 702, 0xd1, 0xd0, 0, 1);
SET_FLAG(0xDBC7, 1);
}
} else
@@ -3816,7 +3814,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playMusic(3);
loadScene(11, 105, 157, 4);
- Dialog::show(scene, 0x8409, 0, 938, 0xd1, 0xec, 0, 1);
+ Dialog::show(this, scene, 0x8409, 0, 938, 0xd1, 0xec, 0, 1);
playAnimation(939, 0, true, true);
playActorAnimation(942, true);
@@ -3837,9 +3835,9 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playActorAnimation(945, true);
waitAnimation();
- Dialog::show(scene, 0x844f, 0, 938, 0xd1, 0xec, 0, 1);
+ Dialog::show(this, scene, 0x844f, 0, 938, 0xd1, 0xec, 0, 1);
playAnimation(946, 0);
- Dialog::show(scene, 0x87c7, 0, 938, 0xd1, 0xec, 0, 1);
+ Dialog::show(this, scene, 0x87c7, 0, 938, 0xd1, 0xec, 0, 1);
playSound(24, 7);
playAnimation(948, 0, true);
@@ -3847,16 +3845,16 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
waitAnimation();
loadScene(40, 198, 186, 1);
- Dialog::show(scene, 0x8890, 0, 920, 0xd1, 0xe7, 0, 1);
- Dialog::show(scene, 0x8a2f, 0, 921, 0xd1, 0xe7, 0, 1);
+ Dialog::show(this, scene, 0x8890, 0, 920, 0xd1, 0xe7, 0, 1);
+ Dialog::show(this, scene, 0x8a2f, 0, 921, 0xd1, 0xe7, 0, 1);
playAnimation(923, 0);
- Dialog::show(scene, 0x8aa7, 0, 920, 0xd1, 0xe7, 0, 1);
+ Dialog::show(this, scene, 0x8aa7, 0, 920, 0xd1, 0xe7, 0, 1);
moveTo(237, 186, 0);
moveTo(237, 177, 0);
moveTo(192, 177, 4);
playAnimation(949, 0);
- Dialog::showMono(scene, 0x8af6, 950, 0xe7, 1);
+ Dialog::showMono(this, scene, 0x8af6, 950, 0xe7, 1);
playSound(32, 5);
playSound(40, 14);
@@ -3869,10 +3867,10 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
displayCredits();
loadScene(39, 192, 177, 0);
hideActor();
- Dialog::showMono(scene, 0x8b4d, 953, 0xe3, 1); //well...
+ Dialog::showMono(this, scene, 0x8b4d, 953, 0xe3, 1); //well...
playSound(5, 15);
playAnimation(954, 0);
- Dialog::showMono(scene, 0x8b7a, 955, 0xe3, 1); //that's all folks
+ Dialog::showMono(this, scene, 0x8b7a, 955, 0xe3, 1); //that's all folks
playMusic(2);
displayCredits(0xe47c, 4500); //3 minutes (infinite until key pressed in original)
scene->push(SceneEvent(SceneEvent::kQuit));
@@ -4025,7 +4023,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
}
setLan(1, 0xff);
- Dialog::showMark(scene, 0x58a9);
+ Dialog::showMark(this, scene, 0x58a9);
Object *obj = scene->getObject(1);
obj->actor_rect.left = obj->actor_rect.right = 270;
@@ -4069,7 +4067,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playAnimation(986, 0, true);
playAnimation(987, 1, true);
waitAnimation();
- Dialog::show(scene, 0x6f60, 988, 989, 0xd9, 0xd0, 1, 2);
+ Dialog::show(this, scene, 0x6f60, 988, 989, 0xd9, 0xd0, 1, 2);
playAnimation(990, 0, true);
playAnimation(991, 1, true);
waitAnimation();
@@ -4082,12 +4080,12 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playAnimation(887, 1);
playAnimation(888, 2, true, true, true);
//waitAnimation();
- Dialog::showMono(scene, 0x6fb8, 889, 0xd9, 2);
+ Dialog::showMono(this, scene, 0x6fb8, 889, 0xd9, 2);
playSound(26, 3);
playAnimation(891, 1, true, true, true);
playAnimation(892, 2);
waitAnimation();
- Dialog::show(scene, 0x6ff0, 890, 889, 0xd0, 0xd9, 3, 2);
+ Dialog::show(this, scene, 0x6ff0, 890, 889, 0xd0, 0xd9, 3, 2);
showActor();
return true;
@@ -4097,11 +4095,11 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playAnimation(894, 1, true, true, true);
playAnimation(893, 2, true);
waitAnimation();
- Dialog::showMono(scene, 0x706e, 895, 0xd9, 3);
+ Dialog::showMono(this, scene, 0x706e, 895, 0xd9, 3);
playSound(75, 9);
playAnimation(898, 1, true);
playAnimation(897, 2, true);
- Dialog::show(scene, 0x7096, 896, 895, 0xd0, 0xd9, 2, 3);
+ Dialog::show(this, scene, 0x7096, 896, 895, 0xd0, 0xd9, 2, 3);
showActor();
return true;
@@ -4111,13 +4109,13 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playActorAnimation(901, true);
playAnimation(900, 1, true);
waitAnimation();
- Dialog::show(scene, 0x7161, 903, 902, 0xd0, 0xd9, 2, 3);
+ Dialog::show(this, scene, 0x7161, 903, 902, 0xd0, 0xd9, 2, 3);
for (byte i = 3; i <= 9; i += 2)
playSound(56, i);
playActorAnimation(905, true);
playAnimation(904, 1, true);
- Dialog::show(scene, 0x71c6, 903, 902, 0xd0, 0xd9, 2, 3);
+ Dialog::show(this, scene, 0x71c6, 903, 902, 0xd0, 0xd9, 2, 3);
showActor();
return true;
@@ -4127,8 +4125,8 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
playAnimation(907, 2, true);
playAnimation(906, 3, true);
waitAnimation();
- Dialog::show(scene, 0x7243, 908, 909, 0xd9, 0xd0, 2, 3);
- Dialog::show(scene, 0x7318, 910, 908, 0xd0, 0xd9, 3, 2);
+ Dialog::show(this, scene, 0x7243, 908, 909, 0xd9, 0xd0, 2, 3);
+ Dialog::show(this, scene, 0x7318, 910, 908, 0xd0, 0xd9, 3, 2);
loadScene(11, scene->getPosition());
showActor();
setOns(3, 51);
diff --git a/engines/teenagent/dialog.cpp b/engines/teenagent/dialog.cpp
index 400bd7cec2..29d8b62cff 100644
--- a/engines/teenagent/dialog.cpp
+++ b/engines/teenagent/dialog.cpp
@@ -22,12 +22,12 @@
#include "teenagent/dialog.h"
#include "teenagent/resources.h"
#include "teenagent/scene.h"
+#include "teenagent/teenagent.h"
namespace TeenAgent {
-void Dialog::show(Scene *scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2, byte slot1, byte slot2) {
+void Dialog::show(TeenAgentEngine *vm, Scene *scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2, byte slot1, byte slot2) {
debug(0, "Dialog::show(%04x, %u:%u, %u:%u)", addr, slot1, animation1, slot2, animation2);
- Resources *res = Resources::instance();
int n = 0;
Common::String message;
byte color = color1;
@@ -47,7 +47,7 @@ void Dialog::show(Scene *scene, uint16 addr, uint16 animation1, uint16 animation
}
while (n < 4) {
- byte c = res->eseg.get_byte(addr++);
+ byte c = vm->res->eseg.get_byte(addr++);
//debug(0, "%02x: %c", c, c > 0x20? c: '.');
switch (c) {
@@ -128,18 +128,17 @@ void Dialog::show(Scene *scene, uint16 addr, uint16 animation1, uint16 animation
scene->push(e);
}
-uint16 Dialog::pop(Scene *scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2, byte slot1, byte slot2) {
+uint16 Dialog::pop(TeenAgentEngine *vm, Scene *scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2, byte slot1, byte slot2) {
debug(0, "Dialog::pop(%04x, %u:%u, %u:%u)", addr, slot1, animation1, slot2, animation2);
- Resources *res = Resources::instance();
uint16 next;
do {
- next = res->dseg.get_word(addr);
+ next = vm->res->dseg.get_word(addr);
addr += 2;
} while (next == 0);
- uint16 next2 = res->dseg.get_word(addr);
+ uint16 next2 = vm->res->dseg.get_word(addr);
if (next2 != 0xffff)
- res->dseg.set_word(addr - 2, 0);
- show(scene, next, animation1, animation2, color1, color2, slot1, slot2);
+ vm->res->dseg.set_word(addr - 2, 0);
+ show(vm, scene, next, animation1, animation2, color1, color2, slot1, slot2);
return next;
}
diff --git a/engines/teenagent/dialog.h b/engines/teenagent/dialog.h
index 3bb7d818c1..a995565fa7 100644
--- a/engines/teenagent/dialog.h
+++ b/engines/teenagent/dialog.h
@@ -28,18 +28,24 @@
namespace TeenAgent {
class Scene;
+class TeenAgentEngine;
+
class Dialog {
public:
- static uint16 pop(Scene *scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2, byte slot1, byte slot2);
- static uint16 popMark(Scene *scene, uint16 addr) {
- return pop(scene, addr, 0, 0, 0xd1, 0xd1, 0, 0);
+ static uint16 pop(TeenAgentEngine *vm, Scene *scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2, byte slot1, byte slot2);
+
+ static uint16 popMark(TeenAgentEngine *vm, Scene *scene, uint16 addr) {
+ return pop(vm, scene, addr, 0, 0, 0xd1, 0xd1, 0, 0);
}
- static void show(Scene *scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2, byte slot1, byte slot2);
- static void showMono(Scene *scene, uint16 addr, uint16 animation, byte color, byte slot) {
- show(scene, addr, animation, animation, color, color, slot, slot);
+
+ static void show(TeenAgentEngine *vm, Scene *scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2, byte slot1, byte slot2);
+
+ static void showMono(TeenAgentEngine *vm, Scene *scene, uint16 addr, uint16 animation, byte color, byte slot) {
+ show(vm, scene, addr, animation, animation, color, color, slot, slot);
}
- static void showMark(Scene *scene, uint16 addr) {
- show(scene, addr, 0, 0, 0xd1, 0xd1, 0, 0);
+
+ static void showMark(TeenAgentEngine *vm, Scene *scene, uint16 addr) {
+ show(vm, scene, addr, 0, 0, 0xd1, 0xd1, 0, 0);
}
};
diff --git a/engines/teenagent/inventory.cpp b/engines/teenagent/inventory.cpp
index 59dd44baa3..8673a94ad7 100644
--- a/engines/teenagent/inventory.cpp
+++ b/engines/teenagent/inventory.cpp
@@ -31,20 +31,17 @@
namespace TeenAgent {
-Inventory::Inventory(TeenAgentEngine *engine) {
- _engine = engine;
+Inventory::Inventory(TeenAgentEngine *vm) : _vm(vm) {
_active = false;
FilePack varia;
varia.open("varia.res");
- {
- Common::ScopedPtr<Common::SeekableReadStream> s(varia.getStream(3));
- if (!s)
- error("no inventory background");
- debug(0, "loading inventory background...");
- _background.load(*s, Surface::kTypeOns);
- }
+ Common::ScopedPtr<Common::SeekableReadStream> s(varia.getStream(3));
+ if (!s)
+ error("no inventory background");
+ debug(0, "loading inventory background...");
+ _background.load(*s, Surface::kTypeOns);
uint32 items_size = varia.getSize(4);
if (items_size == 0)
@@ -60,16 +57,15 @@ Inventory::Inventory(TeenAgentEngine *engine) {
}
_offset[92] = items_size;
- Resources *res = Resources::instance();
for (byte i = 0; i <= 92; ++i) {
InventoryObject io;
- uint16 obj_addr = res->dseg.get_word(0xc4a4 + i * 2);
+ uint16 obj_addr = vm->res->dseg.get_word(0xc4a4 + i * 2);
if (obj_addr != 0)
- io.load(res->dseg.ptr(obj_addr));
+ io.load(vm->res->dseg.ptr(obj_addr));
_objects.push_back(io);
}
- _inventory = res->dseg.ptr(0xc48d);
+ _inventory = vm->res->dseg.ptr(0xc48d);
for (int y = 0; y < 4; ++y)
for (int x = 0; x < 6; ++x) {
@@ -145,11 +141,11 @@ void Inventory::add(byte item) {
bool Inventory::tryObjectCallback(InventoryObject *obj) {
byte id = obj->id;
uint i = 0;
- for (byte *table = Resources::instance()->dseg.ptr(0xBB6F + 3); table[0] != 0 && i < 7; table += 3, ++i) {
+ for (byte *table = _vm->res->dseg.ptr(0xBB6F + 3); table[0] != 0 && i < 7; table += 3, ++i) {
if (table[0] == id) {
resetSelectedObject();
activate(false);
- if (_engine->processCallback(READ_LE_UINT16(table + 1)))
+ if (_vm->processCallback(READ_LE_UINT16(table + 1)))
return true;
}
}
@@ -157,8 +153,6 @@ bool Inventory::tryObjectCallback(InventoryObject *obj) {
}
bool Inventory::processEvent(const Common::Event &event) {
- Resources *res = Resources::instance();
-
switch (event.type) {
case Common::EVENT_MOUSEMOVE:
@@ -203,8 +197,8 @@ bool Inventory::processEvent(const Common::Event &event) {
if (tryObjectCallback(_hoveredObj))
return true;
//activate(false);
- int w = res->font7.render(NULL, 0, 0, _hoveredObj->description, 0xd1);
- _engine->scene->displayMessage(_hoveredObj->description, 0xd1, Common::Point((320 - w) / 2, 162));
+ int w = _vm->res->font7.render(NULL, 0, 0, _hoveredObj->description, 0xd1);
+ _vm->scene->displayMessage(_hoveredObj->description, 0xd1, Common::Point((320 - w) / 2, 162));
return true;
}
@@ -214,7 +208,7 @@ bool Inventory::processEvent(const Common::Event &event) {
return true;
debug(0, "combine(%u, %u)!", id1, id2);
- byte *table = res->dseg.ptr(0xC335);
+ byte *table = _vm->res->dseg.ptr(0xC335);
while (table[0] != 0 && table[1] != 0) {
if (
(id1 == table[0] && id2 == table[1]) ||
@@ -226,17 +220,17 @@ bool Inventory::processEvent(const Common::Event &event) {
remove(id2);
debug(0, "adding object %u", new_obj);
add(new_obj);
- _engine->playSoundNow(69);
+ _vm->playSoundNow(69);
}
uint16 msg = READ_LE_UINT16(table + 3);
- _engine->displayMessage(msg);
+ _vm->displayMessage(msg);
activate(false);
resetSelectedObject();
return true;
}
table += 5;
}
- _engine->displayMessage(0xc3e2);
+ _vm->displayMessage(0xc3e2);
activate(false);
resetSelectedObject();
return true;
@@ -313,7 +307,6 @@ void Inventory::Item::load(Inventory *inventory, uint item_id) {
void Inventory::Item::render(Inventory *inventory, uint item_id, Graphics::Surface *dst, int delta) {
InventoryObject *obj = &inventory->_objects[item_id];
- Resources *res = Resources::instance();
backgroundEffect(dst);
_rect.render(dst, _hovered ? 233 : 234);
@@ -342,9 +335,9 @@ void Inventory::Item::render(Inventory *inventory, uint item_id, Graphics::Surfa
if (inventory->_selectedObj != inventory->_hoveredObj)
name += obj->name;
- if (_hovered && inventory->_engine->scene->getMessage().empty()) {
- int w = res->font7.render(NULL, 0, 0, name, 0xd1, true);
- res->font7.render(dst, (320 - w) / 2, 180, name, 0xd1, true);
+ if (_hovered && inventory->_vm->scene->getMessage().empty()) {
+ int w = inventory->_vm->res->font7.render(NULL, 0, 0, name, 0xd1, true);
+ inventory->_vm->res->font7.render(dst, (320 - w) / 2, 180, name, 0xd1, true);
}
}
diff --git a/engines/teenagent/inventory.h b/engines/teenagent/inventory.h
index 61e5364542..c5ec52dbd9 100644
--- a/engines/teenagent/inventory.h
+++ b/engines/teenagent/inventory.h
@@ -35,7 +35,7 @@ class TeenAgentEngine;
class Inventory {
public:
- Inventory(TeenAgentEngine *engine);
+ Inventory(TeenAgentEngine *vm);
~Inventory();
void render(Graphics::Surface *surface, int delta);
@@ -55,7 +55,7 @@ public:
void resetSelectedObject() { _selectedObj = NULL; }
private:
- TeenAgentEngine *_engine;
+ TeenAgentEngine *_vm;
Surface _background;
byte *_items;
uint _offset[93];
diff --git a/engines/teenagent/music.cpp b/engines/teenagent/music.cpp
index 1f44e9cfcb..bbfcab19b2 100644
--- a/engines/teenagent/music.cpp
+++ b/engines/teenagent/music.cpp
@@ -22,6 +22,8 @@
#include "teenagent/music.h"
#include "teenagent/resources.h"
+#include "teenagent/teenagent.h"
+
#include "common/debug.h"
#include "common/ptr.h"
#include "common/textconsole.h"
@@ -34,16 +36,14 @@ static const uint32 noteToPeriod[3][12] = {
{214, 201, 189, 179, 170, 160, 151, 143, 135, 127, 120, 113}
};
-MusicPlayer::MusicPlayer() : Paula(false, 44100, 5000), _id(0) {
+MusicPlayer::MusicPlayer(TeenAgentEngine *vm) : Paula(false, 44100, 5000), _vm(vm), _id(0) {
}
MusicPlayer::~MusicPlayer() {
}
bool MusicPlayer::load(int id) {
- Resources *res = Resources::instance();
-
- Common::ScopedPtr<Common::SeekableReadStream> stream(res->mmm.getStream(id));
+ Common::ScopedPtr<Common::SeekableReadStream> stream(_vm->res->mmm.getStream(id));
if (!stream)
return false;
@@ -63,7 +63,7 @@ bool MusicPlayer::load(int id) {
// Load the sample data
byte sampleResource = ((sample >> 4) & 0x0F) * 10 + (sample & 0x0F);
debug(0, "currSample = %d, sample = 0x%02x, resource: %d", currSample, sample, sampleResource);
- uint32 sampleSize = res->sam_mmm.getSize(sampleResource);
+ uint32 sampleSize = _vm->res->sam_mmm.getSize(sampleResource);
if (sampleSize == 0) {
warning("load: invalid sample %d (0x%02x)", sample, sample);
_samples[sample].clear();
@@ -71,7 +71,7 @@ bool MusicPlayer::load(int id) {
}
_samples[sample].resize(sampleSize);
- res->sam_mmm.read(sampleResource, _samples[sample].data, sampleSize);
+ _vm->res->sam_mmm.read(sampleResource, _samples[sample].data, sampleSize);
}
// Load the music data
diff --git a/engines/teenagent/music.h b/engines/teenagent/music.h
index 22b4fa5e8e..408436cf3a 100644
--- a/engines/teenagent/music.h
+++ b/engines/teenagent/music.h
@@ -28,10 +28,11 @@
namespace TeenAgent {
+class TeenAgentEngine;
+
class MusicPlayer : public Audio::Paula {
public:
-
- MusicPlayer();
+ MusicPlayer(TeenAgentEngine *vm);
~MusicPlayer();
bool load(int id);
@@ -41,6 +42,8 @@ public:
void stop();
private:
+ TeenAgentEngine *_vm;
+
int _id;
struct Row {
diff --git a/engines/teenagent/resources.cpp b/engines/teenagent/resources.cpp
index f8efb63379..623b44c81b 100644
--- a/engines/teenagent/resources.cpp
+++ b/engines/teenagent/resources.cpp
@@ -26,13 +26,6 @@
namespace TeenAgent {
-Resources::Resources() {}
-
-Resources *Resources::instance() {
- static Resources i;
- return &i;
-}
-
void Resources::deinit() {
off.close();
on.close();
@@ -80,16 +73,14 @@ bool Resources::loadArchives(const ADGameDescription *gd) {
delete dat;
- {
- FilePack varia;
- varia.open("varia.res");
- font7.load(varia, 7);
- font7.width_pack = 1;
- font7.height = 11;
- font8.load(varia, 8);
- font8.height = 31;
- varia.close();
- }
+ FilePack varia;
+ varia.open("varia.res");
+ font7.load(varia, 7);
+ font7.width_pack = 1;
+ font7.height = 11;
+ font8.load(varia, 8);
+ font8.height = 31;
+ varia.close();
off.open("off.res");
on.open("on.res");
diff --git a/engines/teenagent/resources.h b/engines/teenagent/resources.h
index 5c08a46489..88bc3ea94d 100644
--- a/engines/teenagent/resources.h
+++ b/engines/teenagent/resources.h
@@ -32,17 +32,13 @@ struct ADGameDescription;
namespace TeenAgent {
class Resources {
-protected:
- Resources();
public:
- static Resources *instance();
- bool loadArchives(const ADGameDescription *gd);
void deinit();
+ bool loadArchives(const ADGameDescription *gd);
+
void loadOff(Graphics::Surface &surface, byte *palette, int id);
Common::SeekableReadStream *loadLan(uint32 id) const;
Common::SeekableReadStream *loadLan000(uint32 id) const;
- //void loadOn(Graphics::Surface &surface, int id, uint16 &dst, uint16 *flags);
- //void loadOns(Graphics::Surface &surface, int id, uint16 &dst);
/*
* PSP (as the other sony playstation consoles - to be confirmed and 'ifdef'ed here too)
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index 038c8ea05e..c5943d4dbc 100644
--- a/engines/teenagent/scene.cpp
+++ b/engines/teenagent/scene.cpp
@@ -32,16 +32,14 @@
#include "teenagent/surface.h"
#include "teenagent/objects.h"
#include "teenagent/teenagent.h"
-#include "teenagent/dialog.h"
#include "teenagent/music.h"
namespace TeenAgent {
-Scene::Scene(TeenAgentEngine *engine, OSystem *system) : intro(false), _id(0), ons(0),
- orientation(kActorRight), actor_talking(false),
+Scene::Scene(TeenAgentEngine *vm, OSystem *system) : _vm(vm), intro(false), _id(0), ons(0),
+ orientation(kActorRight), actor_talking(false), teenagent(vm), teenagent_idle(vm),
message_timer(0), message_first_frame(0), message_last_frame(0), message_animation(NULL),
current_event(SceneEvent::kNone), hide_actor(false), callback(0), callback_timer(0), _idle_timer(0) {
- _engine = engine;
_system = system;
_fade_timer = 0;
@@ -229,7 +227,7 @@ void Scene::moveTo(const Common::Point &_point, byte orient, bool validate) {
}
if (!findPath(path, position, point)) {
- _engine->cancel();
+ _vm->cancel();
return;
}
@@ -237,8 +235,6 @@ void Scene::moveTo(const Common::Point &_point, byte orient, bool validate) {
}
void Scene::loadObjectData() {
- Resources *res = Resources::instance();
-
//loading objects & walkboxes
objects.resize(42);
walkboxes.resize(42);
@@ -248,18 +244,18 @@ void Scene::loadObjectData() {
Common::Array<Object> &scene_objects = objects[i];
scene_objects.clear();
- uint16 scene_table = res->dseg.get_word(0x7254 + i * 2);
+ uint16 scene_table = _vm->res->dseg.get_word(0x7254 + i * 2);
uint16 object_addr;
- while ((object_addr = res->dseg.get_word(scene_table)) != 0) {
+ while ((object_addr = _vm->res->dseg.get_word(scene_table)) != 0) {
Object obj;
- obj.load(res->dseg.ptr(object_addr));
+ obj.load(_vm->res->dseg.ptr(object_addr));
//obj.dump();
scene_objects.push_back(obj);
scene_table += 2;
}
debug(0, "scene[%u] has %u object(s)", i + 1, scene_objects.size());
- byte *walkboxes_base = res->dseg.ptr(READ_LE_UINT16(res->dseg.ptr(0x6746 + i * 2)));
+ byte *walkboxes_base = _vm->res->dseg.ptr(READ_LE_UINT16(_vm->res->dseg.ptr(0x6746 + i * 2)));
byte walkboxes_n = *walkboxes_base++;
debug(0, "scene[%u] has %u walkboxes", i + 1, walkboxes_n);
@@ -277,7 +273,7 @@ void Scene::loadObjectData() {
scene_walkboxes.push_back(w);
}
- byte *fade_table = res->dseg.ptr(res->dseg.get_word(0x663e + i * 2));
+ byte *fade_table = _vm->res->dseg.ptr(_vm->res->dseg.get_word(0x663e + i * 2));
Common::Array<FadeType> &scene_fades = fades[i];
while (READ_LE_UINT16(fade_table) != 0xffff) {
FadeType fade;
@@ -304,26 +300,23 @@ Object *Scene::findObject(const Common::Point &point) {
}
byte *Scene::getOns(int id) {
- Resources *res = Resources::instance();
- return res->dseg.ptr(res->dseg.get_word(0xb4f5 + (id - 1) * 2));
+ return _vm->res->dseg.ptr(_vm->res->dseg.get_word(0xb4f5 + (id - 1) * 2));
}
byte *Scene::getLans(int id) {
- Resources *res = Resources::instance();
- return res->dseg.ptr(0xd89e + (id - 1) * 4);
+ return _vm->res->dseg.ptr(0xd89e + (id - 1) * 4);
}
void Scene::loadOns() {
debug(0, "loading ons animation");
- Resources *res = Resources::instance();
- uint16 addr = res->dseg.get_word(0xb4f5 + (_id - 1) * 2);
+ uint16 addr = _vm->res->dseg.get_word(0xb4f5 + (_id - 1) * 2);
//debug(0, "ons index: %04x", addr);
ons_count = 0;
byte b;
byte on_id[16];
- while ((b = res->dseg.get_byte(addr)) != 0xff) {
+ while ((b = _vm->res->dseg.get_byte(addr)) != 0xff) {
debug(0, "on: %04x = %02x", addr, b);
++addr;
if (b == 0)
@@ -338,7 +331,7 @@ void Scene::loadOns() {
if (ons_count > 0) {
ons = new Surface[ons_count];
for (uint32 i = 0; i < ons_count; ++i) {
- Common::ScopedPtr<Common::SeekableReadStream> s(res->ons.getStream(on_id[i]));
+ Common::ScopedPtr<Common::SeekableReadStream> s(_vm->res->ons.getStream(on_id[i]));
if (s) {
ons[i].load(*s, Surface::kTypeOns);
}
@@ -348,20 +341,19 @@ void Scene::loadOns() {
void Scene::loadLans() {
debug(0, "loading lans animation");
- Resources *res = Resources::instance();
//load lan000
for (byte i = 0; i < 4; ++i) {
animation[i].free();
uint16 bx = 0xd89e + (_id - 1) * 4 + i;
- byte bxv = res->dseg.get_byte(bx);
+ byte bxv = _vm->res->dseg.get_byte(bx);
uint16 res_id = 4 * (_id - 1) + i + 1;
debug(0, "lan[%u]@%04x = %02x, resource id: %u", i, bx, bxv, res_id);
if (bxv == 0)
continue;
- Common::ScopedPtr<Common::SeekableReadStream> s(res->loadLan000(res_id));
+ Common::ScopedPtr<Common::SeekableReadStream> s(_vm->res->loadLan000(res_id));
if (s) {
animation[i].load(*s, Animation::kTypeLan);
if (bxv != 0 && bxv != 0xff)
@@ -383,11 +375,10 @@ void Scene::init(int id, const Common::Point &pos) {
warp(pos);
- Resources *res = Resources::instance();
- res->loadOff(background, palette, id);
+ _vm->res->loadOff(background, palette, id);
if (id == 24) {
//dark scene
- if (res->dseg.get_byte(0xDBA4) != 1) {
+ if (_vm->res->dseg.get_byte(0xDBA4) != 1) {
//dim down palette
uint i;
for (i = 0; i < 624; ++i) {
@@ -399,10 +390,10 @@ void Scene::init(int id, const Common::Point &pos) {
}
}
- Common::ScopedPtr<Common::SeekableReadStream> stream(res->on.getStream(id));
+ Common::ScopedPtr<Common::SeekableReadStream> stream(_vm->res->on.getStream(id));
int sub_hack = 0;
if (id == 7) { //something patched in the captains room
- switch (res->dseg.get_byte(0xdbe6)) {
+ switch (_vm->res->dseg.get_byte(0xdbe6)) {
case 2:
break;
case 1:
@@ -418,10 +409,10 @@ void Scene::init(int id, const Common::Point &pos) {
loadLans();
//check music
- int now_playing = _engine->music->getId();
+ int now_playing = _vm->music->getId();
- if (now_playing != res->dseg.get_byte(0xDB90))
- _engine->music->load(res->dseg.get_byte(0xDB90));
+ if (now_playing != _vm->res->dseg.get_byte(0xDB90))
+ _vm->music->load(_vm->res->dseg.get_byte(0xDB90));
_system->copyRectToScreen(background.pixels, background.pitch, 0, 0, background.w, background.h);
setPalette(0);
@@ -430,7 +421,7 @@ void Scene::init(int id, const Common::Point &pos) {
void Scene::playAnimation(byte idx, uint id, bool loop, bool paused, bool ignore) {
debug(0, "playAnimation(%u, %u, loop:%s, paused:%s, ignore:%s)", idx, id, loop ? "true" : "false", paused ? "true" : "false", ignore ? "true" : "false");
assert(idx < 4);
- Common::ScopedPtr<Common::SeekableReadStream> s(Resources::instance()->loadLan(id + 1));
+ Common::ScopedPtr<Common::SeekableReadStream> s(_vm->res->loadLan(id + 1));
if (!s)
error("playing animation %u failed", id);
@@ -442,7 +433,7 @@ void Scene::playAnimation(byte idx, uint id, bool loop, bool paused, bool ignore
void Scene::playActorAnimation(uint id, bool loop, bool ignore) {
debug(0, "playActorAnimation(%u, loop:%s, ignore:%s)", id, loop ? "true" : "false", ignore ? "true" : "false");
- Common::ScopedPtr<Common::SeekableReadStream> s(Resources::instance()->loadLan(id + 1));
+ Common::ScopedPtr<Common::SeekableReadStream> s(_vm->res->loadLan(id + 1));
if (!s)
error("playing animation %u failed", id);
@@ -463,7 +454,7 @@ byte Scene::peekFlagEvent(uint16 addr) const {
if (e.type == SceneEvent::kSetFlag && e.callback == addr)
return e.color;
}
- return Resources::instance()->dseg.get_byte(addr);
+ return _vm->res->dseg.get_byte(addr);
}
void Scene::push(const SceneEvent &event) {
@@ -509,8 +500,8 @@ bool Scene::processEvent(const Common::Event &event) {
message_color = 0xd1;
for (int i = 0; i < 4; ++i)
custom_animation[i].free();
- _engine->playMusic(4);
- _engine->loadScene(10, Common::Point(136, 153));
+ _vm->playMusic(4);
+ _vm->loadScene(10, Common::Point(136, 153));
return true;
}
@@ -556,8 +547,7 @@ struct ZOrderCmp {
};
int Scene::lookupZoom(uint y) const {
- Resources *res = Resources::instance();
- for (byte *zoom_table = res->dseg.ptr(res->dseg.get_word(0x70f4 + (_id - 1) * 2));
+ for (byte *zoom_table = _vm->res->dseg.ptr(_vm->res->dseg.get_word(0x70f4 + (_id - 1) * 2));
zoom_table[0] != 0xff && zoom_table[1] != 0xff;
zoom_table += 2) {
//debug(0, "%d %d->%d", y, zoom_table[0], zoom_table[1]);
@@ -571,8 +561,7 @@ int Scene::lookupZoom(uint y) const {
void Scene::paletteEffect(byte step) {
- Resources *res = Resources::instance();
- byte *src = res->dseg.ptr(0x6609);
+ byte *src = _vm->res->dseg.ptr(0x6609);
byte *dst = palette + 3 * 0xf2;
for (byte i = 0; i < 0xd; ++i) {
for (byte c = 0; c < 3; ++c, ++src)
@@ -595,7 +584,6 @@ byte Scene::findFade() const {
}
bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) {
- Resources *res = Resources::instance();
bool busy;
bool restart;
uint32 game_delta = tick_game ? 1 : 0;
@@ -620,7 +608,7 @@ bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) {
_system->fillScreen(0);
///\todo: optimize me
Graphics::Surface *surface = _system->lockScreen();
- res->font7.render(surface, current_event.dst.x, current_event.dst.y -= game_delta, current_event.message, current_event.color);
+ _vm->res->font7.render(surface, current_event.dst.x, current_event.dst.y -= game_delta, current_event.message, current_event.color);
_system->unlockScreen();
if (current_event.dst.y < -(int)current_event.timer)
@@ -644,10 +632,10 @@ bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) {
_system->fillScreen(0);
Graphics::Surface *surface = _system->lockScreen();
if (current_event.lan == 8) {
- res->font8.shadow_color = current_event.orientation;
- res->font8.render(surface, current_event.dst.x, current_event.dst.y, message, current_event.color);
+ _vm->res->font8.shadow_color = current_event.orientation;
+ _vm->res->font8.render(surface, current_event.dst.x, current_event.dst.y, message, current_event.color);
} else {
- res->font7.render(surface, current_event.dst.x, current_event.dst.y, message, 0xd1);
+ _vm->res->font7.render(surface, current_event.dst.x, current_event.dst.y, message, 0xd1);
}
_system->unlockScreen();
return true;
@@ -803,7 +791,7 @@ bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) {
if (_idle_timer < 50)
actor_animation_position = teenagent.render(surface, position, orientation, 0, actor_talking, zoom);
else
- actor_animation_position = teenagent_idle.renderIdle(surface, position, orientation, mark_delta, zoom, _engine->_rnd);
+ actor_animation_position = teenagent_idle.renderIdle(surface, position, orientation, mark_delta, zoom, _vm->_rnd);
}
}
@@ -837,16 +825,16 @@ bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) {
}
if (visible) {
- res->font7.render(surface, message_pos.x, message_pos.y, message, message_color);
+ _vm->res->font7.render(surface, message_pos.x, message_pos.y, message, message_color);
busy = true;
}
}
if (!busy && !restart && tick_game && callback_timer) {
if (--callback_timer == 0) {
- if (_engine->inventory->active())
- _engine->inventory->activate(false);
- _engine->processCallback(callback);
+ if (_vm->inventory->active())
+ _vm->inventory->activate(false);
+ _vm->processCallback(callback);
}
//debug(0, "callback timer = %u", callback_timer);
}
@@ -901,7 +889,7 @@ bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) {
Sound &sound = *i;
if (sound.delay == 0) {
debug(1, "sound %u started", sound.id);
- _engine->playSoundNow(sound.id);
+ _vm->playSoundNow(sound.id);
i = sounds.erase(i);
} else {
sound.delay -= game_delta;
@@ -1079,8 +1067,8 @@ bool Scene::processEventQueue() {
case SceneEvent::kPlayMusic:
debug(0, "setting music %u", current_event.music);
- _engine->setMusic(current_event.music);
- Resources::instance()->dseg.set_byte(0xDB90, current_event.music);
+ _vm->setMusic(current_event.music);
+ _vm->res->dseg.set_byte(0xDB90, current_event.music);
current_event.clear();
break;
@@ -1154,12 +1142,12 @@ bool Scene::processEventQueue() {
case SceneEvent::kQuit:
debug(0, "quit!");
- _engine->quitGame();
+ _vm->quitGame();
break;
case SceneEvent::kSetFlag:
debug(0, "async set_flag(%04x, %d)", current_event.callback, current_event.color);
- Resources::instance()->dseg.set_byte(current_event.callback, current_event.color);
+ _vm->res->dseg.set_byte(current_event.callback, current_event.color);
current_event.clear();
break;
@@ -1203,14 +1191,13 @@ Object *Scene::getObject(int id, int scene_id) {
}
Common::Point Scene::messagePosition(const Common::String &str, Common::Point message_position) {
- Resources *res = Resources::instance();
int lines = 1;
for (uint i = 0; i < str.size(); ++i)
if (str[i] == '\n')
++lines;
- uint w = res->font7.render(NULL, 0, 0, str, 0);
- uint h = res->font7.height * lines + 3;
+ uint w = _vm->res->font7.render(NULL, 0, 0, str, 0);
+ uint h = _vm->res->font7.height * lines + 3;
message_position.x -= w / 2;
message_position.y -= h;
diff --git a/engines/teenagent/scene.h b/engines/teenagent/scene.h
index 32e784bb60..f3c211d63f 100644
--- a/engines/teenagent/scene.h
+++ b/engines/teenagent/scene.h
@@ -39,7 +39,6 @@ struct Event;
namespace TeenAgent {
class TeenAgentEngine;
-class Dialog;
struct SceneEvent {
enum Type {
@@ -177,8 +176,8 @@ private:
void paletteEffect(byte step);
byte findFade() const;
- static Common::Point messagePosition(const Common::String &str, Common::Point position);
- static uint messageDuration(const Common::String &str);
+ Common::Point messagePosition(const Common::String &str, Common::Point position);
+ uint messageDuration(const Common::String &str);
bool processEventQueue();
inline bool nextEvent() {
@@ -187,7 +186,7 @@ private:
}
void clearMessage();
- TeenAgentEngine *_engine;
+ TeenAgentEngine *_vm;
OSystem *_system;
int _id;
diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp
index f06de6f803..3ac830061a 100644
--- a/engines/teenagent/teenagent.cpp
+++ b/engines/teenagent/teenagent.cpp
@@ -50,13 +50,16 @@ namespace TeenAgent {
TeenAgentEngine::TeenAgentEngine(OSystem *system, const ADGameDescription *gd)
: Engine(system), action(kActionNone), _gameDescription(gd),
_rnd("teenagent") {
- music = new MusicPlayer();
-
+ music = new MusicPlayer(this);
+ res = new Resources();
+
console = 0;
}
TeenAgentEngine::~TeenAgentEngine() {
delete music;
+ res->deinit();
+ delete res;
delete console;
}
@@ -66,7 +69,6 @@ bool TeenAgentEngine::trySelectedObject() {
if (inv == NULL)
return false;
- Resources *res = Resources::instance();
debug(0, "checking active object %u on %u", inv->id, dst_object->id);
//mouse time challenge hack:
@@ -102,7 +104,6 @@ void TeenAgentEngine::processObject() {
if (dst_object == NULL)
return;
- Resources *res = Resources::instance();
switch (action) {
case kActionExamine: {
if (trySelectedObject())
@@ -174,7 +175,6 @@ void TeenAgentEngine::init() {
_mark_delay = 80;
_game_delay = 110;
- Resources *res = Resources::instance();
use_hotspots.resize(42);
byte *scene_hotspots = res->dseg.ptr(0xbb87);
for (byte i = 0; i < 42; ++i) {
@@ -198,7 +198,7 @@ void TeenAgentEngine::deinit() {
//delete music;
//music = NULL;
use_hotspots.clear();
- Resources::instance()->deinit();
+ res->deinit();
CursorMan.popCursor();
}
@@ -211,8 +211,6 @@ Common::Error TeenAgentEngine::loadGameState(int slot) {
if (!in)
return Common::kReadPermissionDenied;
- Resources *res = Resources::instance();
-
const uint dataSize = 0x777a;
assert(res->dseg.size() >= 0x6478 + dataSize);
@@ -234,7 +232,7 @@ Common::Error TeenAgentEngine::loadGameState(int slot) {
inventory->activate(false);
inventory->reload();
- setMusic(Resources::instance()->dseg.get_byte(0xDB90));
+ setMusic(res->dseg.get_byte(0xDB90));
int id = res->dseg.get_byte(0xB4F3);
uint16 x = res->dseg.get_word(0x64AF), y = res->dseg.get_word(0x64B1);
@@ -251,7 +249,6 @@ Common::Error TeenAgentEngine::saveGameState(int slot, const Common::String &des
if (!out)
return Common::kWritingFailed;
- Resources *res = Resources::instance();
res->dseg.set_byte(0xB4F3, scene->getId());
Common::Point pos = scene->getPosition();
res->dseg.set_word(0x64AF, pos.x);
@@ -517,7 +514,6 @@ bool TeenAgentEngine::showMetropolis() {
}
Common::Error TeenAgentEngine::run() {
- Resources *res = Resources::instance();
if (!res->loadArchives(_gameDescription))
return Common::kUnknownError;
@@ -697,7 +693,7 @@ Common::Error TeenAgentEngine::run() {
Common::String TeenAgentEngine::parseMessage(uint16 addr) {
Common::String message;
for (
- const char *str = (const char *)Resources::instance()->dseg.ptr(addr);
+ const char *str = (const char *)res->dseg.ptr(addr);
str[0] != 0 || str[1] != 0;
++str) {
char c = str[0];
@@ -771,7 +767,7 @@ void TeenAgentEngine::displayAsyncMessageInSlot(uint16 addr, byte slot, uint16 f
void TeenAgentEngine::displayCredits(uint16 addr, uint16 timer) {
SceneEvent event(SceneEvent::kCreditsMessage);
- const byte *src = Resources::instance()->dseg.ptr(addr);
+ const byte *src = res->dseg.ptr(addr);
event.orientation = *src++;
event.color = *src++;
event.lan = 8;
@@ -786,7 +782,7 @@ void TeenAgentEngine::displayCredits(uint16 addr, uint16 timer) {
break;
event.message += "\n";
}
- int w = Resources::instance()->font8.render(NULL, 0, 0, event.message, 0xd1);
+ int w = res->font8.render(NULL, 0, 0, event.message, 0xd1);
event.dst.x = (320 - w) / 2;
event.timer = timer;
scene->push(event);
@@ -801,7 +797,7 @@ void TeenAgentEngine::displayCredits() {
for (uint i = 0; i < event.message.size(); ++i)
if (event.message[i] == '\n')
++lines;
- event.dst.x = (320 - Resources::instance()->font7.render(NULL, 0, 0, event.message, 0xd1)) / 2;
+ event.dst.x = (320 - res->font7.render(NULL, 0, 0, event.message, 0xd1)) / 2;
event.timer = 11 * lines - event.dst.y + 22;
//debug(0, "credits = %s", event.message.c_str());
scene->push(event);
@@ -1016,7 +1012,6 @@ void TeenAgentEngine::wait(uint16 frames) {
}
void TeenAgentEngine::playSoundNow(byte id) {
- Resources *res = Resources::instance();
uint size = res->sam_sam.getSize(id);
if (size == 0) {
warning("skipping invalid sound %u", id);
@@ -1034,7 +1029,6 @@ void TeenAgentEngine::playSoundNow(byte id) {
void TeenAgentEngine::setMusic(byte id) {
debug(0, "starting music %u", id);
- Resources *res = Resources::instance();
if (id != 1) //intro music
*res->dseg.ptr(0xDB90) = id;
diff --git a/engines/teenagent/teenagent.h b/engines/teenagent/teenagent.h
index 737f07ba85..f34490c2ba 100644
--- a/engines/teenagent/teenagent.h
+++ b/engines/teenagent/teenagent.h
@@ -76,7 +76,7 @@ public:
bool showMetropolis();
int skipEvents() const;
- static Common::String parseMessage(uint16 addr);
+ Common::String parseMessage(uint16 addr);
//event driven:
void displayMessage(uint16 addr, byte color = 0xd1, uint16 position = 0);
@@ -119,6 +119,7 @@ public:
Common::RandomSource _rnd;
+ Resources *res;
Scene *scene;
Inventory *inventory;
MusicPlayer *music;