aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/pegasus/graphics.cpp138
-rw-r--r--engines/pegasus/graphics.h23
2 files changed, 0 insertions, 161 deletions
diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index a25dd673ef..e37150e75a 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -39,13 +39,6 @@ GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
if (_vm->_system->getScreenFormat().bytesPerPixel == 1)
error("No true color mode available");
- // Old
- _pictDecoder = new Graphics::PictDecoder(_vm->_system->getScreenFormat());
-
- for (int i = 0; i < kImageCacheSize; i++)
- _cache[i].surface = 0;
-
- // New
_backLayer = kMinAvailableOrder;
_frontLayer = kMaxAvailableOrder;
_firstDisplayElement = _lastDisplayElement = 0;
@@ -54,140 +47,9 @@ GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
}
GraphicsManager::~GraphicsManager() {
- // Old
- delete _pictDecoder;
-
- for (int i = 0; i < kImageCacheSize; i++) {
- if (_cache[i].surface) {
- _cache[i].surface->free();
- delete _cache[i].surface;
- }
- }
-
- // New
_workArea.free();
}
-Graphics::Surface *GraphicsManager::decodeImage(const Common::String &filename) {
- int imageSlot = getImageSlot(filename);
-
- if (_cache[imageSlot].surface)
- return _cache[imageSlot].surface;
-
- Common::File file;
- if (!file.open(filename))
- error("Could not open \'%s\'", filename.c_str());
-
- byte palette[256 * 3];
- Graphics::Surface *image = _pictDecoder->decodeImage(&file, palette);
-
- // For <= 8bpp, we need to convert
- if (image->format.bytesPerPixel == 1) {
- Graphics::PixelFormat format = _vm->_system->getScreenFormat();
- Graphics::Surface *output = new Graphics::Surface();
- output->create(image->w, image->h, format);
-
- for (uint16 y = 0; y < image->h; y++) {
- for (uint16 x = 0; x < image->w; x++) {
- byte c = *((byte *)image->getBasePtr(x, y));
- byte r = palette[c * 3];
- byte g = palette[c * 3 + 1];
- byte b = palette[c * 3 + 2];
-
- if (format.bytesPerPixel == 2) {
- uint16 color = format.RGBToColor(r, g, b);
- memcpy(output->getBasePtr(x, y), &color, 2);
- } else if (format.bytesPerPixel == 4) {
- uint32 color = format.RGBToColor(r, g, b);
- memcpy(output->getBasePtr(x, y), &color, 4);
- }
- }
- }
-
- image->free();
- delete image;
- image = output;
- }
-
- _cache[imageSlot].surface = image;
- return image;
-}
-
-void GraphicsManager::drawPict(Common::String filename, int x, int y, bool updateScreen) {
- Graphics::Surface *surface = decodeImage(filename);
-
- _vm->_system->copyRectToScreen((byte *)surface->pixels, surface->pitch, x, y, surface->w, surface->h);
-
- if (updateScreen)
- _vm->_system->updateScreen();
-}
-
-void GraphicsManager::drawPictTransparent(Common::String filename, int x, int y, uint32 transparency, bool updateScreen) {
- if (_vm->_system->getScreenFormat().bytesPerPixel == 2)
- transparency &= 0xffff;
-
- Graphics::Surface *surface = decodeImage(filename);
- Graphics::Surface *screen = _vm->_system->lockScreen();
-
- for (uint16 i = 0; i < surface->h; i++) {
- for (uint16 j = 0; j < surface->w; j++) {
- if (_vm->_system->getScreenFormat().bytesPerPixel == 2) {
- uint16 color = *((uint16 *)surface->getBasePtr(j, i));
- if (color != transparency)
- memcpy(screen->getBasePtr(j + x, i + y), &color, 2);
- } else if (_vm->_system->getScreenFormat().bytesPerPixel == 4) {
- uint32 color = *((uint32 *)surface->getBasePtr(j, i));
- if (color != transparency)
- memcpy(screen->getBasePtr(j + x, i + y), &color, 4);
- }
- }
- }
-
- _vm->_system->unlockScreen();
-
- if (updateScreen)
- _vm->_system->updateScreen();
-}
-
-uint32 GraphicsManager::getColor(byte r, byte g, byte b) {
- return _vm->_system->getScreenFormat().RGBToColor(r, g, b);
-}
-
-int GraphicsManager::getImageSlot(const Common::String &filename) {
- // Let's find a match, an open slot, or the oldest image slot
- uint32 oldestAge = 0xffffffff;
- int slot = 0;
-
- for (int i = 0; i < kImageCacheSize; i++) {
- if (_cache[i].filename.equalsIgnoreCase(filename)) {
- //warning("Found image %s at slot %d", filename.c_str(), i);
- _cache[i].lastUsed = _vm->_system->getMillis();
- return i;
- }
-
- if (!_cache[i].surface) {
- //warning("Putting image %s in empty slot %d", filename.c_str(), i);
- _cache[i].filename = filename;
- _cache[i].lastUsed = _vm->_system->getMillis();
- return i;
- }
-
- if (_cache[i].lastUsed < oldestAge) {
- oldestAge = _cache[i].lastUsed;
- slot = i;
- }
- }
-
- // Let's make sure that's cleaned out
- //warning("Replacing old image %s with %s in slot %d", _cache[slot].filename.c_str(), filename.c_str(), slot);
- _cache[slot].filename = filename;
- _cache[slot].surface->free();
- delete _cache[slot].surface;
- _cache[slot].surface = 0;
- _cache[slot].lastUsed = _vm->_system->getMillis();
- return slot;
-}
-
void GraphicsManager::invalRect(const Common::Rect &rect) {
// We're using a simpler algorithm for dirty rect handling than the original
// The original was way too overcomplicated for what we need here now.
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index b72137bf1e..ebaaeb2c6c 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -37,16 +37,6 @@
namespace Pegasus {
-enum {
- kImageCacheSize = 10
-};
-
-struct ImageCache {
- Common::String filename;
- Graphics::Surface *surface;
- uint32 lastUsed;
-};
-
class DisplayElement;
class PegasusEngine;
@@ -55,12 +45,6 @@ public:
GraphicsManager(PegasusEngine *vm);
~GraphicsManager();
- // Older "temporary" API
- void drawPict(Common::String filename, int x, int y, bool updateScreen = true);
- void drawPictTransparent(Common::String filename, int x, int y, uint32 transparency, bool updateScreen = true);
- uint32 getColor(byte r, byte g, byte b);
-
- // Newer "to-be-used" API
void addDisplayElement(DisplayElement *element);
void removeDisplayElement(DisplayElement *element);
void invalRect(const Common::Rect &rect);
@@ -72,13 +56,6 @@ public:
private:
PegasusEngine *_vm;
- // Older "temporary" API
- Graphics::PictDecoder *_pictDecoder;
- Graphics::Surface *decodeImage(const Common::String &filename);
- ImageCache _cache[kImageCacheSize];
- int getImageSlot(const Common::String &filename);
-
- // Newer "to-be-used" API
Common::Rect _dirtyRect;
tDisplayOrder _backLayer, _frontLayer;
DisplayElement *_firstDisplayElement, *_lastDisplayElement;