aboutsummaryrefslogtreecommitdiff
path: root/sword2/driver/render.cpp
diff options
context:
space:
mode:
authorTorbjörn Andersson2003-08-26 06:53:00 +0000
committerTorbjörn Andersson2003-08-26 06:53:00 +0000
commit8277c6cb798552de5ef315311db18f91a25e42fc (patch)
tree18606d41b4db06dda28acc075af1141c750fbcff /sword2/driver/render.cpp
parentf3675261a970ca1c76870f3ebbf3774771d22270 (diff)
downloadscummvm-rg350-8277c6cb798552de5ef315311db18f91a25e42fc.tar.gz
scummvm-rg350-8277c6cb798552de5ef315311db18f91a25e42fc.tar.bz2
scummvm-rg350-8277c6cb798552de5ef315311db18f91a25e42fc.zip
The graphics detail settings partially work now. They only affect how
sprites are drawn, but I think that's how it should be. 1: No bells or whistles. 2: This setting adds sprite blending, e.g. the smoke at the docks or the display cases at the Glease Gallery. 3: This setting adds light map support, e.g. when walking under the shack at the docks. 4: This setting adds better scaling algorithms. The first three settings should work fine now. In fact, the third setting is what we used to implement. The fourth setting still needs work and testing. I've added code for downscaling case, but frankly I'm not convinced the result is any better than with the simpler scaler. I usually can't even tell the difference. Of course, my translation of the original code could very well be buggy. svn-id: r9867
Diffstat (limited to 'sword2/driver/render.cpp')
-rw-r--r--sword2/driver/render.cpp64
1 files changed, 54 insertions, 10 deletions
diff --git a/sword2/driver/render.cpp b/sword2/driver/render.cpp
index 1d9749e3f8..3bdc306f97 100644
--- a/sword2/driver/render.cpp
+++ b/sword2/driver/render.cpp
@@ -349,15 +349,16 @@ void UploadRect(ScummVM::Rect *r) {
static uint16 xScale[SCALE_MAXWIDTH];
static uint16 yScale[SCALE_MAXHEIGHT];
-// This is based on the "line doubling" scaler in the original sprite renderer.
-// I've made it into two separate functions because there were cases from
+// I've made the scaling two separate functions because there were cases from
// DrawSprite() where it wasn't obvious if the sprite should grow or shrink,
// which caused crashes.
//
-// The functions can probably be merged later, if/when we implement a better
-// scale function for it.
+// Maybe the functions can be merged later?
+//
+// The code is based on the original DrawSprite() code, so apart from not
+// knowing if I got it right, I don't know how good the original really is.
-void SquashImage(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 dstHeight,byte *src, uint16 srcPitch, uint16 srcWidth, uint16 srcHeight) {
+void SquashImage(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth, uint16 srcHeight, byte *backbuf) {
int32 ince, incne, d;
int16 x, y;
@@ -403,15 +404,56 @@ void SquashImage(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 dstHeight,b
// Copy the image
- for (y = 0; y < dstHeight; y++) {
- for (x = 0; x < dstWidth; x++) {
- dst[x] = src[yScale[y] * srcPitch + xScale[x]];
+ if (backbuf) {
+ for (y = 0; y < dstHeight; y++) {
+ for (x = 0; x < dstWidth; x++) {
+ uint8 p;
+ uint8 p1 = 0;
+ int count = 0;
+ int spriteCount = 0;
+ int red = 0;
+ int green = 0;
+ int blue = 0;
+ int i, j;
+
+ for (j = yScale[y]; j < yScale[y + 1]; j++) {
+ for (i = xScale[x]; i < xScale[x + 1]; i++) {
+ p = src[j * srcPitch + i];
+ if (p) {
+ red += palCopy[p][0];
+ green += palCopy[p][1];
+ blue += palCopy[p][2];
+ p1 = p;
+ spriteCount++;
+ } else {
+ red += palCopy[backbuf[x]][0];
+ green += palCopy[backbuf[x]][1];
+ blue += palCopy[backbuf[x]][2];
+ }
+ count++;
+ }
+ }
+ if (spriteCount == 0)
+ dst[x] = 0;
+ else if (spriteCount == 1)
+ dst[x] = p1;
+ else
+ dst[x] = QuickMatch((uint8) (red / count), (uint8) (green / count), (uint8) (blue / count));
+ }
+ dst += dstPitch;
+ backbuf += lpBackBuffer->_width;
+ }
+ } else {
+ for (y = 0; y < dstHeight; y++) {
+ for (x = 0; x < dstWidth; x++) {
+ dst[x] = src[yScale[y] * srcPitch + xScale[x]];
+ }
+ dst += dstPitch;
}
- dst += dstPitch;
}
}
-void StretchImage(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 dstHeight,byte *src, uint16 srcPitch, uint16 srcWidth, uint16 srcHeight) {
+void StretchImage(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth, uint16 srcHeight, byte *backbuf) {
int32 ince, incne, d;
int16 x, y, i, j, k;
@@ -456,6 +498,8 @@ void StretchImage(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 dstHeight,
// Copy the image
+ // FIXME: If backbuf != NULL the image should be anti-aliased
+
for (y = 0; y < srcHeight; y++) {
for (j = yScale[y]; j < yScale[y + 1]; j++) {
k = 0;