aboutsummaryrefslogtreecommitdiff
path: root/engines/sword2/layers.cpp
diff options
context:
space:
mode:
authorFabio Battaglia2009-04-07 19:52:46 +0000
committerFabio Battaglia2009-04-07 19:52:46 +0000
commitdc9c538a62d64b40c3a39a673d2f680fa9422f41 (patch)
treeda10a2ff6b6804e714fb124aac805445fe204058 /engines/sword2/layers.cpp
parentb80abe318d65679d5c0cd8a94a8c106534d240ea (diff)
downloadscummvm-rg350-dc9c538a62d64b40c3a39a673d2f680fa9422f41.tar.gz
scummvm-rg350-dc9c538a62d64b40c3a39a673d2f680fa9422f41.tar.bz2
scummvm-rg350-dc9c538a62d64b40c3a39a673d2f680fa9422f41.zip
Sword2: PSX version support, and GMM loading/saving
svn-id: r39896
Diffstat (limited to 'engines/sword2/layers.cpp')
-rw-r--r--engines/sword2/layers.cpp98
1 files changed, 95 insertions, 3 deletions
diff --git a/engines/sword2/layers.cpp b/engines/sword2/layers.cpp
index ba59889acb..c54003920f 100644
--- a/engines/sword2/layers.cpp
+++ b/engines/sword2/layers.cpp
@@ -179,7 +179,7 @@ void Screen::initBackground(int32 res, int32 new_palette) {
}
// Background parallax layers
-
+
for (i = 0; i < 2; i++) {
if (screenLayerTable.bg_parallax[i])
initialiseBackgroundLayer(_vm->fetchBackgroundParallaxLayer(file, i));
@@ -188,11 +188,11 @@ void Screen::initBackground(int32 res, int32 new_palette) {
}
// Normal backround layer
-
+
initialiseBackgroundLayer(_vm->fetchBackgroundLayer(file));
// Foreground parallax layers
-
+
for (i = 0; i < 2; i++) {
if (screenLayerTable.fg_parallax[i])
initialiseBackgroundLayer(_vm->fetchForegroundParallaxLayer(file, i));
@@ -203,4 +203,96 @@ void Screen::initBackground(int32 res, int32 new_palette) {
_vm->_resman->closeResource(_thisScreen.background_layer_id);
}
+/**
+ * This function is called when entering a new room, PSX edition
+ * @param res resource id of the normal background layer
+ * @param new_palette 1 for new palette, otherwise 0
+ */
+
+void Screen::initPsxBackground(int32 res, int32 new_palette) {
+ int i;
+
+ assert(res);
+
+ _vm->_sound->clearFxQueue(false);
+ waitForFade();
+
+ debug(1, "CHANGED TO LOCATION \"%s\"", _vm->_resman->fetchName(res));
+
+ _vm->_logic->writeVar(EXIT_CLICK_ID, 0);
+
+ // Close the previous screen, if one is open
+ if (_thisScreen.background_layer_id)
+ closeBackgroundLayer();
+
+ _thisScreen.background_layer_id = res;
+ _thisScreen.new_palette = new_palette;
+
+ // ok, now read the resource and pull out all the normal sort layer
+ // info/and set them up at the beginning of the sort list - why do it
+ // each cycle
+
+ byte *file = _vm->_resman->openResource(_thisScreen.background_layer_id);
+ ScreenHeader screen_head;
+
+ screen_head.read(_vm->fetchScreenHeader(file));
+ screen_head.height *= 2;
+
+ // set number of special sort layers
+ _thisScreen.number_of_layers = screen_head.noLayers;
+ _thisScreen.screen_wide = screen_head.width;
+ _thisScreen.screen_deep = screen_head.height;
+
+ debug(2, "layers=%d width=%d depth=%d", screen_head.noLayers, screen_head.width, screen_head.height);
+
+ // initialise the driver back buffer
+ setLocationMetrics(screen_head.width, screen_head.height);
+
+ for (i = 0; i < screen_head.noLayers; i++) {
+ debug(3, "init layer %d", i);
+
+ LayerHeader layer;
+
+ layer.read(_vm->fetchLayerHeader(file, i));
+ _sortList[i].layer_number = i + 1;
+ _sortList[i].sort_y = layer.y + layer.height;
+ }
+
+ // reset scroll offsets
+ _thisScreen.scroll_offset_x = 0;
+ _thisScreen.scroll_offset_y = 0;
+
+ if (screen_head.width > _screenWide || screen_head.height > _screenDeep) {
+ _thisScreen.scroll_flag = 2;
+
+ _thisScreen.max_scroll_offset_x = screen_head.width - _screenWide;
+ _thisScreen.max_scroll_offset_y = screen_head.height - (_screenDeep - (MENUDEEP * 2));
+ } else {
+ // The later fits on the phyiscal screen. Switch off scrolling.
+ _thisScreen.scroll_flag = 0;
+ }
+
+ resetRenderEngine();
+
+ // These are the physical screen coords where the system will try to
+ // maintain George's actual feet coords.
+
+ _thisScreen.feet_x = 320;
+ _thisScreen.feet_y = 340;
+
+ // Background parallax layers
+ initialisePsxParallaxLayer(_vm->fetchBackgroundParallaxLayer(file, 0));
+ initialisePsxParallaxLayer(NULL);
+
+ // Normal backround layer
+ initialisePsxBackgroundLayer(_vm->fetchBackgroundLayer(file));
+
+ // Foreground parallax layers
+ initialisePsxParallaxLayer(_vm->fetchForegroundParallaxLayer(file, 1));
+ initialisePsxParallaxLayer(NULL);
+
+ _vm->_resman->closeResource(_thisScreen.background_layer_id);
+
+}
+
} // End of namespace Sword2