ULTIMA1: Rendering VGA background without U6 scroll area

This commit is contained in:
Paul Gilbert 2020-01-18 19:47:21 -08:00 committed by Paul Gilbert
parent 233d19ed0a
commit e8440ac096
4 changed files with 54 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);