aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction
diff options
context:
space:
mode:
Diffstat (limited to 'engines/parallaction')
-rw-r--r--engines/parallaction/debug.cpp11
-rw-r--r--engines/parallaction/debug.h2
-rw-r--r--engines/parallaction/graphics.cpp79
-rw-r--r--engines/parallaction/graphics.h10
-rw-r--r--engines/parallaction/parallaction.cpp4
5 files changed, 103 insertions, 3 deletions
diff --git a/engines/parallaction/debug.cpp b/engines/parallaction/debug.cpp
index 9f1c868318..c39f0e4d47 100644
--- a/engines/parallaction/debug.cpp
+++ b/engines/parallaction/debug.cpp
@@ -45,6 +45,7 @@ Debugger::Debugger(Parallaction *vm)
DCmd_Register("localflags", WRAP_METHOD(Debugger, Cmd_LocalFlags));
DCmd_Register("locations", WRAP_METHOD(Debugger, Cmd_Locations));
DCmd_Register("gfxobjects", WRAP_METHOD(Debugger, Cmd_GfxObjects));
+ DCmd_Register("set", WRAP_METHOD(Debugger, Cmd_Set));
}
@@ -204,5 +205,15 @@ bool Debugger::Cmd_GfxObjects(int argc, const char **argv) {
return true;
}
+bool Debugger::Cmd_Set(int argc, const char** argv) {
+
+ if (argc < 3) {
+ DebugPrintf("set <var name> <value>\n");
+ } else {
+ _vm->_gfx->setVar(Common::String(argv[1]), atoi(argv[2]));
+ }
+
+ return true;
+}
} // namespace Parallaction
diff --git a/engines/parallaction/debug.h b/engines/parallaction/debug.h
index c8d0cd1d1c..cc47735e4c 100644
--- a/engines/parallaction/debug.h
+++ b/engines/parallaction/debug.h
@@ -28,6 +28,8 @@ protected:
bool Cmd_GlobalFlags(int argc, const char **argv);
bool Cmd_Locations(int argc, const char **argv);
bool Cmd_GfxObjects(int argc, const char **argv);
+ bool Cmd_GfxFeature(int argc, const char** argv);
+ bool Cmd_Set(int argc, const char** argv);
};
} // End of namespace Parallaction
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index e90cc54c9e..5654eddffb 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -32,6 +32,40 @@
namespace Parallaction {
+
+typedef Common::HashMap<Common::String, int32, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> VarMap;
+VarMap _vars;
+
+void Gfx::registerVar(const Common::String &name, int32 initialValue) {
+ if (_vars.contains(name)) {
+ warning("Variable '%s' already registered, ignoring initial value.\n", name.c_str());
+ } else {
+ _vars.setVal(name, initialValue);
+ }
+}
+
+void Gfx::setVar(const Common::String &name, int32 value) {
+ if (!_vars.contains(name)) {
+ warning("Variable '%s' doesn't exist, skipping assignment.\n", name.c_str());
+ } else {
+ _vars.setVal(name, value);
+ }
+}
+
+int32 Gfx::getVar(const Common::String &name) {
+ int32 v = 0;
+
+ if (!_vars.contains(name)) {
+ warning("Variable '%s' doesn't exist, returning default value.\n", name.c_str());
+ } else {
+ v = _vars.getVal(name);
+ }
+
+ return v;
+}
+
+
+
#define LABEL_TRANSPARENT_COLOR 0xFF
#define BALLOON_TRANSPARENT_COLOR 2
@@ -348,14 +382,51 @@ void Gfx::clearScreen() {
g_system->clearScreen();
}
+void Gfx::beginFrame() {
+
+ int32 oldBackgroundMode = _varBackgroundMode;
+ _varBackgroundMode = getVar("background_mode");
+
+ if (oldBackgroundMode != _varBackgroundMode) {
+ switch (_varBackgroundMode) {
+ case 1:
+ _bitmapMask.free();
+ break;
+ case 2:
+ _bitmapMask.create(_backgroundInfo.width, _backgroundInfo.height, 1);
+ byte *data = (byte*)_bitmapMask.pixels;
+ for (uint y = 0; y < _bitmapMask.h; y++) {
+ for (uint x = 0; x < _bitmapMask.w; x++) {
+ *data++ = _backgroundInfo.mask.getValue(x, y);
+ }
+ }
+ break;
+ }
+ }
+
+
+}
+
void Gfx::updateScreen() {
// background may not cover the whole screen, so adjust bulk update size
uint w = MIN(_vm->_screenWidth, (int32)_backgroundInfo.width);
uint h = MIN(_vm->_screenHeight, (int32)_backgroundInfo.height);
- // TODO: add displacement to source to handle scrolling in BRA
- g_system->copyRectToScreen((const byte*)_backgroundInfo.bg.pixels, _backgroundInfo.bg.pitch, _backgroundInfo.x, _backgroundInfo.y, w, h);
+ byte *backgroundData;
+ uint16 backgroundPitch;
+ switch (_varBackgroundMode) {
+ case 1:
+ backgroundData = (byte*)_backgroundInfo.bg.pixels;
+ backgroundPitch = _backgroundInfo.bg.pitch;
+ break;
+ case 2:
+ backgroundData = (byte*)_bitmapMask.pixels;
+ backgroundPitch = _bitmapMask.pitch;
+ break;
+ }
+ g_system->copyRectToScreen(backgroundData, backgroundPitch, _backgroundInfo.x, _backgroundInfo.y, w, h);
+
// TODO: transform objects coordinates to be drawn with scrolling
Graphics::Surface *surf = g_system->lockScreen();
@@ -785,6 +856,9 @@ Gfx::Gfx(Parallaction* vm) :
_font = NULL;
+ registerVar("background_mode", 1);
+ _varBackgroundMode = 1;
+
return;
}
@@ -1035,5 +1109,4 @@ void Gfx::setBackground(uint type, const char* name, const char* mask, const cha
}
-
} // namespace Parallaction
diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h
index 3eb8f88a01..7a036a8da8 100644
--- a/engines/parallaction/graphics.h
+++ b/engines/parallaction/graphics.h
@@ -512,6 +512,11 @@ public:
Gfx(Parallaction* vm);
virtual ~Gfx();
+ void beginFrame();
+
+ void registerVar(const Common::String &name, int32 initialValue);
+ void setVar(const Common::String &name, int32 value);
+ int32 getVar(const Common::String &name);
void clearScreen();
void updateScreen();
@@ -530,6 +535,10 @@ protected:
Common::Point _hbCirclePos;
int _hbCircleRadius;
+ // frame data stored in programmable variables
+ int32 _varBackgroundMode;
+ Graphics::Surface _bitmapMask;
+
protected:
static int16 _dialogueBalloonX[5];
@@ -594,3 +603,4 @@ protected:
+
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index be81bdc4e1..dcacf900be 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -253,12 +253,16 @@ void Parallaction::runGame() {
changeLocation(_location._name);
}
+
+ _gfx->beginFrame();
+
if (_inputMode == kInputModeGame) {
runScripts();
walk();
drawAnimations();
}
+ // change this to endFrame?
updateView();
}