aboutsummaryrefslogtreecommitdiff
path: root/graphics/surface.cpp
diff options
context:
space:
mode:
authorFlorian Kagerer2010-10-01 19:24:52 +0000
committerFlorian Kagerer2010-10-01 19:24:52 +0000
commit0d8f4a22ae51d5943014a4c5f3ba610686039a24 (patch)
tree4f2ba902f2681c10f1f9949efc9424bcc93e14c1 /graphics/surface.cpp
parentbe1d196da5dbbabaef0bfa835b51e9c82c407645 (diff)
downloadscummvm-rg350-0d8f4a22ae51d5943014a4c5f3ba610686039a24.tar.gz
scummvm-rg350-0d8f4a22ae51d5943014a4c5f3ba610686039a24.tar.bz2
scummvm-rg350-0d8f4a22ae51d5943014a4c5f3ba610686039a24.zip
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891. The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1). Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame. This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode). Japanese font drawing hasn’t been improved much yet. This will be a separate task. svn-id: r52966
Diffstat (limited to 'graphics/surface.cpp')
-rw-r--r--graphics/surface.cpp52
1 files changed, 31 insertions, 21 deletions
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index 137ef29a4e..73fff26dbd 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -24,6 +24,7 @@
#include "common/algorithm.h"
#include "common/util.h"
+#include "common/endian.h"
#include "graphics/primitives.h"
#include "graphics/surface.h"
@@ -185,9 +186,6 @@ void Surface::frameRect(const Common::Rect &r, uint32 color) {
// to support 16bpp (or marked as just working for 8bpp
// surfaces).
void Surface::move(int dx, int dy, int height) {
- // This function currently just works with 8bpp surfaces
- assert(bytesPerPixel == 1);
-
// Short circuit check - do we have to do anything anyway?
if ((dx == 0 && dy == 0) || height <= 0)
return;
@@ -198,46 +196,58 @@ void Surface::move(int dx, int dy, int height) {
// vertical movement
if (dy > 0) {
// move down - copy from bottom to top
- dst = (byte *)pixels + (height - 1) * w;
- src = dst - dy * w;
+ dst = (byte *)pixels + (height - 1) * pitch;
+ src = dst - dy * pitch;
for (y = dy; y < height; y++) {
- memcpy(dst, src, w);
- src -= w;
- dst -= w;
+ memcpy(dst, src, pitch);
+ src -= pitch;
+ dst -= pitch;
}
} else if (dy < 0) {
// move up - copy from top to bottom
dst = (byte *)pixels;
- src = dst - dy * w;
+ src = dst - dy * pitch;
for (y = -dy; y < height; y++) {
- memcpy(dst, src, w);
- src += w;
- dst += w;
+ memcpy(dst, src, pitch);
+ src += pitch;
+ dst += pitch;
}
}
// horizontal movement
if (dx > 0) {
// move right - copy from right to left
- dst = (byte *)pixels + (w - 1);
- src = dst - dx;
+ dst = (byte *)pixels + (pitch - bytesPerPixel);
+ src = dst - (dx * bytesPerPixel);
for (y = 0; y < height; y++) {
for (x = dx; x < w; x++) {
- *dst-- = *src--;
+ if (bytesPerPixel == 1) {
+ *dst-- = *src--;
+ } else if (bytesPerPixel == 2) {
+ WRITE_LE_UINT16(dst, READ_LE_UINT16(src));
+ src -= 2;
+ dst -= 2;
+ }
}
- src += w + (w - dx);
- dst += w + (w - dx);
+ src += pitch + (pitch - dx * bytesPerPixel);
+ dst += pitch + (pitch - dx * bytesPerPixel);
}
} else if (dx < 0) {
// move left - copy from left to right
dst = (byte *)pixels;
- src = dst - dx;
+ src = dst - (dx * bytesPerPixel);
for (y = 0; y < height; y++) {
for (x = -dx; x < w; x++) {
- *dst++ = *src++;
+ if (bytesPerPixel == 1) {
+ *dst++ = *src++;
+ } else if (bytesPerPixel == 2) {
+ WRITE_LE_UINT16(dst, READ_LE_UINT16(src));
+ src += 2;
+ dst += 2;
+ }
}
- src += w - (w + dx);
- dst += w - (w + dx);
+ src += pitch - (pitch + dx * bytesPerPixel);
+ dst += pitch - (pitch + dx * bytesPerPixel);
}
}
}