diff --git a/engines/ultima/shared/gfx/bitmap.cpp b/engines/ultima/shared/gfx/bitmap.cpp index 5f8a89b83a9..6deb49b1045 100644 --- a/engines/ultima/shared/gfx/bitmap.cpp +++ b/engines/ultima/shared/gfx/bitmap.cpp @@ -50,6 +50,18 @@ void Bitmap::load(const Common::String &filename) { } } +void Bitmap::flipHorizontally() { + Graphics::Surface s = getSubArea(Common::Rect(0, 0, this->w, this->h)); + + for (int y = 0; y < h; ++y) { + byte *lineStart = (byte *)s.getBasePtr(0, y); + byte *lineEnd = (byte *)s.getBasePtr(this->w - 1, y); + + for (int x = 0; x < (this->w - 1) / 2; ++x, ++lineStart, --lineEnd) + SWAP(*lineStart, *lineEnd); + } +} + } // End of namespace Gfx } // End of namespace Shared } // End of namespace Ultima diff --git a/engines/ultima/shared/gfx/bitmap.h b/engines/ultima/shared/gfx/bitmap.h index 1187fd1afca..af3563f6c02 100644 --- a/engines/ultima/shared/gfx/bitmap.h +++ b/engines/ultima/shared/gfx/bitmap.h @@ -37,6 +37,11 @@ public: * Loads an Ultima 6 bitmap */ void load(const Common::String &filename); + + /** + * Flips a bitmap horizontally + */ + void flipHorizontally(); }; } // End of namespace Gfx diff --git a/engines/ultima/ultima1/u6gfx/game_view.cpp b/engines/ultima/ultima1/u6gfx/game_view.cpp index e5895d3b691..294d6d0405a 100644 --- a/engines/ultima/ultima1/u6gfx/game_view.cpp +++ b/engines/ultima/ultima1/u6gfx/game_view.cpp @@ -21,8 +21,6 @@ */ #include "ultima/ultima1/u6gfx/game_view.h" -#include "ultima/shared/core/map.h" -#include "ultima/shared/gfx/info.h" #include "ultima/ultima1/game.h" #include "ultima/ultima1/gfx/drawing_support.h" #include "ultima/ultima1/gfx/status.h" @@ -32,6 +30,9 @@ #include "ultima/ultima1/actions/climb.h" #include "ultima/ultima1/actions/enter.h" #include "ultima/ultima1/core/resources.h" +#include "ultima/shared/gfx/bitmap.h" +#include "ultima/shared/core/map.h" +#include "ultima/shared/gfx/info.h" #include "ultima/shared/engine/messages.h" namespace Ultima { @@ -44,10 +45,10 @@ END_MESSAGE_MAP() GameView::GameView(TreeItem *parent) : Shared::Gfx::VisualContainer("GameView", Rect(0, 0, 320, 200), parent) { _info = nullptr; - _background.load("paper.bmp"); _actions[0] = new Actions::Move(this); _actions[1] = new Actions::Climb(this); _actions[2] = new Actions::Enter(this); + loadBackground(); } GameView::~GameView() { @@ -56,6 +57,32 @@ GameView::~GameView() { delete _actions[idx]; } +void GameView::loadBackground() { + // Load in the Ultima 6 background + Shared::Gfx::Bitmap pic; + pic.load("paper.bmp"); + _background.copyFrom(pic); + + // The scroll area in Ultima 6 is too big for the Ultima 1 status area, so we first have to remove it + // Erase bottom edge of scroll + _background.blitFrom(_background, Common::Rect(8, 190, 160, 200), Common::Point(168, 190)); + + // Erase right edge of scroll + pic.create(8, 86); + pic.blitFrom(_background, Common::Rect(312, 16, 320, 102), Common::Point(0, 0)); + _background.blitFrom(pic, Common::Point(312, 105)); + + // Erase bottom right-corner of scroll + pic.create(8, 12); + pic.blitFrom(_background, Common::Rect(0, 188, 8, 200), Common::Point(0, 0)); + pic.flipHorizontally(); + _background.blitFrom(pic, Common::Point(312, 188)); + + // Clear off the rest of the scroll + byte bgColor = *(const byte *)_background.getBasePtr(8, 8); + _background.fillRect(Common::Rect(8, 8, 312, 192), bgColor); +} + void GameView::draw() { Shared::Gfx::VisualSurface s = getSurface(); s.blitFrom(_background); diff --git a/engines/ultima/ultima1/u6gfx/game_view.h b/engines/ultima/ultima1/u6gfx/game_view.h index f5a44e26991..d5d65d31825 100644 --- a/engines/ultima/ultima1/u6gfx/game_view.h +++ b/engines/ultima/ultima1/u6gfx/game_view.h @@ -24,7 +24,6 @@ #define ULTIMA_ULTIMA1_U6GFX_GAME_VIEW_H #include "ultima/shared/gfx/visual_container.h" -#include "ultima/shared/gfx/bitmap.h" namespace Ultima { @@ -53,7 +52,13 @@ private: Shared::Info *_info; Shared::ViewportDungeon *_viewportDungeon; Actions::Action *_actions[3]; - Shared::Gfx::Bitmap _background; + Graphics::ManagedSurface _background; +private: + /** + * Sets up the background for the screen by adapting the Ultima 6 game background to fit the + * asthetics needed for Ultima 1 + */ + void loadBackground(); public: CLASSDEF; GameView(TreeItem *parent = nullptr);