diff options
Diffstat (limited to 'sword2/layers.cpp')
-rw-r--r-- | sword2/layers.cpp | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/sword2/layers.cpp b/sword2/layers.cpp index 86debbd8c3..79b8cd9743 100644 --- a/sword2/layers.cpp +++ b/sword2/layers.cpp @@ -28,11 +28,9 @@ #include "common/stdafx.h" #include "sword2/sword2.h" -#include "sword2/interpreter.h" #include "sword2/logic.h" #include "sword2/resman.h" #include "sword2/sound.h" -#include "sword2/driver/d_draw.h" namespace Sword2 { @@ -42,30 +40,30 @@ namespace Sword2 { * @param new_palette 1 for new palette, otherwise 0 */ -int32 Sword2Engine::initBackground(int32 res, int32 new_palette) { +void Screen::initBackground(int32 res, int32 new_palette) { byte buf[NAME_LEN]; int i; assert(res); // The resources age every time a new room is entered. - _resman->passTime(); - _resman->expireOldResources(); + _vm->_resman->passTime(); + _vm->_resman->expireOldResources(); - _sound->clearFxQueue(); - _graphics->waitForFade(); + _vm->_sound->clearFxQueue(); + waitForFade(); - debug(1, "CHANGED TO LOCATION \"%s\"", fetchObjectName(res, buf)); + debug(1, "CHANGED TO LOCATION \"%s\"", _vm->fetchObjectName(res, buf)); // if last screen was using a shading mask (see below) if (_thisScreen.mask_flag) { - if (_graphics->closeLightMask() != RD_OK) + if (closeLightMask() != RD_OK) error("Could not close light mask"); } // Close the previous screen, if one is open if (_thisScreen.background_layer_id) - _graphics->closeBackgroundLayer(); + closeBackgroundLayer(); _thisScreen.background_layer_id = res; _thisScreen.new_palette = new_palette; @@ -74,8 +72,8 @@ int32 Sword2Engine::initBackground(int32 res, int32 new_palette) { // info/and set them up at the beginning of the sort list - why do it // each cycle - byte *file = _resman->openResource(_thisScreen.background_layer_id); - ScreenHeader *screen_head = fetchScreenHeader(file); + byte *file = _vm->_resman->openResource(_thisScreen.background_layer_id); + ScreenHeader *screen_head = _vm->fetchScreenHeader(file); // set number of special sort layers _thisScreen.number_of_layers = screen_head->noLayers; @@ -85,12 +83,12 @@ int32 Sword2Engine::initBackground(int32 res, int32 new_palette) { debug(2, "layers=%d width=%d depth=%d", screen_head->noLayers, screen_head->width, screen_head->height); // initialise the driver back buffer - _graphics->setLocationMetrics(screen_head->width, screen_head->height); + setLocationMetrics(screen_head->width, screen_head->height); for (i = 0; i < screen_head->noLayers; i++) { debug(3, "init layer %d", i); - LayerHeader *layer = fetchLayerHeader(file, i); + LayerHeader *layer = _vm->fetchLayerHeader(file, i); // Add the layer to the sort list. We only provide just enough // information so that it's clear that it's a layer, and where @@ -104,7 +102,7 @@ int32 Sword2Engine::initBackground(int32 res, int32 new_palette) { _thisScreen.scroll_offset_x = 0; _thisScreen.scroll_offset_y = 0; - if (screen_head->width > _graphics->_screenWide || screen_head->height > _graphics->_screenDeep) { + if (screen_head->width > _screenWide || screen_head->height > _screenDeep) { // The layer is larger than the physical screen. Switch on // scrolling. (2 means first time on screen) _thisScreen.scroll_flag = 2; @@ -115,14 +113,14 @@ int32 Sword2Engine::initBackground(int32 res, int32 new_palette) { // Calculate the maximum scroll offsets to prevent scrolling // off the edge. The minimum offsets are both 0. - _thisScreen.max_scroll_offset_x = screen_head->width - _graphics->_screenWide; - _thisScreen.max_scroll_offset_y = screen_head->height - (_graphics->_screenDeep - (RDMENU_MENUDEEP * 2)); + _thisScreen.max_scroll_offset_x = screen_head->width - _screenWide; + _thisScreen.max_scroll_offset_y = screen_head->height - (_screenDeep - (RDMENU_MENUDEEP * 2)); } else { // The later fits on the phyiscal screen. Switch off scrolling. _thisScreen.scroll_flag = 0; } - _graphics->resetRenderEngine(); + resetRenderEngine(); // These are the physical screen coords where the system will try to // maintain George's actual feet coords. @@ -146,10 +144,10 @@ int32 Sword2Engine::initBackground(int32 res, int32 new_palette) { spriteInfo.scaledHeight = 0; spriteInfo.type = 0; spriteInfo.blend = 0; - spriteInfo.data = fetchShadingMask(file); + spriteInfo.data = _vm->fetchShadingMask(file); spriteInfo.colourTable = 0; - if (_graphics->openLightMask(&spriteInfo) != RD_OK) + if (openLightMask(&spriteInfo) != RD_OK) error("Could not open light mask"); // so we know to close it later! (see above) @@ -163,26 +161,25 @@ int32 Sword2Engine::initBackground(int32 res, int32 new_palette) { for (i = 0; i < 2; i++) { if (screenLayerTable->bg_parallax[i]) - _graphics->initialiseBackgroundLayer(fetchBackgroundParallaxLayer(file, i)); + initialiseBackgroundLayer(_vm->fetchBackgroundParallaxLayer(file, i)); else - _graphics->initialiseBackgroundLayer(NULL); + initialiseBackgroundLayer(NULL); } // Normal backround layer - _graphics->initialiseBackgroundLayer(fetchBackgroundLayer(file)); + initialiseBackgroundLayer(_vm->fetchBackgroundLayer(file)); // Foreground parallax layers for (i = 0; i < 2; i++) { if (screenLayerTable->fg_parallax[i]) - _graphics->initialiseBackgroundLayer(fetchForegroundParallaxLayer(file, i)); + initialiseBackgroundLayer(_vm->fetchForegroundParallaxLayer(file, i)); else - _graphics->initialiseBackgroundLayer(NULL); + initialiseBackgroundLayer(NULL); } - _resman->closeResource(_thisScreen.background_layer_id); - return IR_CONT; + _vm->_resman->closeResource(_thisScreen.background_layer_id); } } // End of namespace Sword2 |