[Scummvm-git-logs] scummvm master -> b789c1ef4a6a47508b222e61818be00e35718ba5
yinsimei
roseline.yin at gmail.com
Sun Jul 16 14:40:12 CEST 2017
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1a86e7e4cd SLUDGE: Correct fallback detection with custom description
b21a3ba783 SLUDGE: Load game icon/logo
ebd36a8df2 SLUDGE: Complete burnSpriteToBackdrop
17dd32f3db SLUDGE: Complete pasteCharacter to backdrop
b789c1ef4a SLUDGE: Add sprite display color
Commit: 1a86e7e4cd26cd0b7059f456921ee8b3c058820a
https://github.com/scummvm/scummvm/commit/1a86e7e4cd26cd0b7059f456921ee8b3c058820a
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-16T14:39:31+02:00
Commit Message:
SLUDGE: Correct fallback detection with custom description
Changed paths:
engines/sludge/detection.cpp
diff --git a/engines/sludge/detection.cpp b/engines/sludge/detection.cpp
index b0c3ef2..d6da811 100644
--- a/engines/sludge/detection.cpp
+++ b/engines/sludge/detection.cpp
@@ -51,18 +51,23 @@ static const PlainGameDescriptor sludgeGames[] = {
{ 0, 0 }
};
-static ADGameDescription s_fallbackDesc = {
- "",
- "",
- AD_ENTRY1(0, 0), // This should always be AD_ENTRY1(0, 0) in the fallback descriptor
- Common::UNK_LANG,
- Common::kPlatformWindows,
- ADGF_NO_FLAGS,
- GUIO0()
+#include "sludge/detection_tables.h"
+
+static Sludge::SludgeGameDescription s_fallbackDesc =
+{
+ {
+ "",
+ "",
+ AD_ENTRY1(0, 0), // This should always be AD_ENTRY1(0, 0) in the fallback descriptor
+ Common::UNK_LANG,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ GUIO0()
+ },
+ 0
};
-static char s_fallbackFileNameBuffer[51];
-#include "sludge/detection_tables.h"
+static char s_fallbackFileNameBuffer[51];
class SludgeMetaEngine : public AdvancedMetaEngine {
public:
@@ -93,12 +98,13 @@ public:
const ADGameDescription *SludgeMetaEngine::fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
// reset fallback description
- s_fallbackDesc.gameId = "sludge";
- s_fallbackDesc.extra = "";
- s_fallbackDesc.language = Common::EN_ANY;
- s_fallbackDesc.flags = ADGF_UNSTABLE;
- s_fallbackDesc.platform = Common::kPlatformUnknown;
- s_fallbackDesc.guiOptions = GUIO0();
+ s_fallbackDesc.desc.gameId = "sludge";
+ s_fallbackDesc.desc.extra = "";
+ s_fallbackDesc.desc.language = Common::EN_ANY;
+ s_fallbackDesc.desc.flags = ADGF_UNSTABLE;
+ s_fallbackDesc.desc.platform = Common::kPlatformUnknown;
+ s_fallbackDesc.desc.guiOptions = GUIO0();
+ s_fallbackDesc.languageID = 0;
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
if (file->isDirectory())
@@ -136,9 +142,9 @@ const ADGameDescription *SludgeMetaEngine::fallbackDetect(const FileMap &allFile
strncpy(s_fallbackFileNameBuffer, fileName.c_str(), 50);
s_fallbackFileNameBuffer[50] = '\0';
- s_fallbackDesc.filesDescriptions[0].fileName = s_fallbackFileNameBuffer;
+ s_fallbackDesc.desc.filesDescriptions[0].fileName = s_fallbackFileNameBuffer;
- return &s_fallbackDesc;;
+ return (const ADGameDescription *)&s_fallbackDesc;;
}
return 0;
}
Commit: b21a3ba7830e0e9dbc50df463fa530e37e94ce67
https://github.com/scummvm/scummvm/commit/b21a3ba7830e0e9dbc50df463fa530e37e94ce67
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-16T14:39:31+02:00
Commit Message:
SLUDGE: Load game icon/logo
Changed paths:
engines/sludge/sludger.cpp
engines/sludge/sludger.h
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index ff1e1f8..e577102 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -49,6 +49,7 @@
#include "sludge/sludge.h"
#include "sludge/specialsettings.h"
#include "sludge/version.h"
+#include "sludge/imgloader.h"
namespace Sludge {
@@ -67,12 +68,6 @@ Common::String *allResourceNames = NULL;
int selectedLanguage = 0;
int languageNum = -1;
-byte *gameIcon = NULL;
-int iconW = 0, iconH = 0;
-
-byte *gameLogo = NULL;
-int logoW = 0, logoH = 0;
-
int gameVersion;
int specialSettings;
FILETIME fileTime;
@@ -264,221 +259,21 @@ bool initSludge(const Common::String &filename) {
// There is an icon - read it!
debug(kSludgeDebugDataLoad, "There is an icon - read it!");
-#if 0
- int n;
- long file_pointer = ftell(fp);
-
- png_structp png_ptr;
- png_infop info_ptr, end_info;
-
- int fileIsPNG = true;
-
- // Is this a PNG file?
-
- char tmp[10];
- bytes_read = fread(tmp, 1, 8, fp);
- if (bytes_read != 8 && ferror(fp)) {
- debugOut("Reading error in initSludge.\n");
- }
- if (png_sig_cmp((png_byte *) tmp, 0, 8)) {
- // No, it's old-school HSI
- fileIsPNG = false;
- fseek(fp, file_pointer, SEEK_SET);
-
- iconW = fp->readUint16BE();
- iconH = fp->readUint16BE();
- } else {
- // Read the PNG header
-
- png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (!png_ptr) {
- return false;
- }
-
- info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr) {
- png_destroy_read_struct(&png_ptr, (png_infopp) NULL, (png_infopp) NULL);
- return false;
- }
-
- end_info = png_create_info_struct(png_ptr);
- if (!end_info) {
- png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
- return false;
- }
- png_init_io(png_ptr, fp); // Tell libpng which file to read
- png_set_sig_bytes(png_ptr, 8);// 8 bytes already read
-
- png_read_info(png_ptr, info_ptr);
-
- png_uint_32 width, height;
- int bit_depth, color_type, interlace_type, compression_type, filter_method;
- png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, &compression_type, &filter_method);
-
- iconW = width;
- iconH = height;
-
- if (bit_depth < 8) png_set_packing(png_ptr);
- png_set_expand(png_ptr);
- if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) png_set_gray_to_rgb(png_ptr);
- if (bit_depth == 16) png_set_strip_16(png_ptr);
-
- png_set_add_alpha(png_ptr, 0xff, PNG_FILLER_AFTER);
-
- png_read_update_info(png_ptr, info_ptr);
- png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, &compression_type, &filter_method);
-
- }
-
- gameIcon = new byte [iconW * iconH * 4];
- if (!gameIcon) return fatal("Can't reserve memory for game icon.");
-
- int32 transCol = 63519;
- Uint8 *p = (Uint8 *) gameIcon;
-
- if (fileIsPNG) {
- byte *row_pointers[iconH];
- for (int i = 0; i < iconH; i++)
- row_pointers[i] = p + 4 * i * iconW;
-
- png_read_image(png_ptr, (png_byte **) row_pointers);
- png_read_end(png_ptr, NULL);
- png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
- } else {
-
- for (int t2 = 0; t2 < iconH; t2 ++) {
- int t1 = 0;
- while (t1 < iconW) {
- uint16 c = (uint16) fp->readUint16BE();
- if (c & 32) {
- n = fgetc(fp) + 1;
- c -= 32;
- } else {
- n = 1;
- }
- while (n --) {
- *p++ = (Uint8) redValue(c);
- *p++ = (Uint8) greenValue(c);
- *p++ = (Uint8) blueValue(c);
- *p++ = (Uint8)(c == transCol) ? 0 : 255;
+ // read game icon
+ Graphics::Surface gameIcon;
+ if (!ImgLoader::loadImage(fp, &gameIcon, false))
+ return false;
- t1++;
- }
- }
- }
- }
-#endif
}
if (customIconLogo & 2) {
// There is an logo - read it!
debug(kSludgeDebugDataLoad, "There is an logo - read it!");
-#if 0
- int n;
- long file_pointer = ftell(fp);
- png_structp png_ptr;
- png_infop info_ptr, end_info;
-
- int fileIsPNG = true;
-
- // Is this a PNG file?
-
- char tmp[10];
- bytes_read = fread(tmp, 1, 8, fp);
- if (bytes_read != 8 && ferror(fp)) {
- debugOut("Reading error in initSludge.");
- }
- if (png_sig_cmp((png_byte *) tmp, 0, 8)) {
- // No, it's old-school HSI
- fileIsPNG = false;
- fseek(fp, file_pointer, SEEK_SET);
-
- logoW = fp->readUint16BE();
- logoH = fp->readUint16BE();
- } else {
- // Read the PNG header
-
- png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (!png_ptr) {
- return false;
- }
-
- info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr) {
- png_destroy_read_struct(&png_ptr, (png_infopp) NULL, (png_infopp) NULL);
- return false;
- }
-
- end_info = png_create_info_struct(png_ptr);
- if (!end_info) {
- png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
- return false;
- }
- png_init_io(png_ptr, fp); // Tell libpng which file to read
- png_set_sig_bytes(png_ptr, 8);// 8 bytes already read
-
- png_read_info(png_ptr, info_ptr);
-
- png_uint_32 width, height;
- int bit_depth, color_type, interlace_type, compression_type, filter_method;
- png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, &compression_type, &filter_method);
-
- logoW = width;
- logoH = height;
-
- if (bit_depth < 8) png_set_packing(png_ptr);
- png_set_expand(png_ptr);
- if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) png_set_gray_to_rgb(png_ptr);
- if (bit_depth == 16) png_set_strip_16(png_ptr);
-
- png_set_add_alpha(png_ptr, 0xff, PNG_FILLER_AFTER);
-
- png_read_update_info(png_ptr, info_ptr);
- png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, &compression_type, &filter_method);
-
- }
-
- if ((logoW != 310) || (logoH != 88)) return fatal("Game logo have wrong dimensions. (Should be 310x88)");
-
- gameLogo = new byte [logoW * logoH * 4];
- if (!gameLogo) return fatal("Can't reserve memory for game logo.");
-
- // int32 transCol = 63519;
- Uint8 *p = (Uint8 *) gameLogo;
-
- if (fileIsPNG) {
- byte *row_pointers[logoH];
- for (int i = 0; i < logoH; i++)
- row_pointers[i] = p + 4 * i * logoW;
-
- png_read_image(png_ptr, (png_byte **) row_pointers);
- png_read_end(png_ptr, NULL);
- png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
- } else {
-
- for (int t2 = 0; t2 < logoH; t2 ++) {
- int t1 = 0;
- while (t1 < logoW) {
- uint16 c = (uint16) fp->readUint16BE();
- if (c & 32) {
- n = fgetc(fp) + 1;
- c -= 32;
- } else {
- n = 1;
- }
- while (n --) {
- *p++ = (Uint8) redValue(c);
- *p++ = (Uint8) greenValue(c);
- *p++ = (Uint8) blueValue(c);
- *p++ = (Uint8) /*(c == transCol) ? 0 :*/255;
-
- t1++;
- }
- }
- }
- }
-#endif
+ // read game logo
+ Graphics::Surface gameLogo;
+ if (!ImgLoader::loadImage(fp, &gameLogo))
+ return false;
}
numGlobals = fp->readUint16BE();
diff --git a/engines/sludge/sludger.h b/engines/sludge/sludger.h
index 19340f4..fe5d9b8 100644
--- a/engines/sludge/sludger.h
+++ b/engines/sludge/sludger.h
@@ -73,9 +73,6 @@ struct inputType {
int mouseX, mouseY, keyPressed;
};
-extern byte *gameIcon;
-extern int iconW, iconH;
-
bool initSludge(const Common::String &);
void displayBase();
void sludgeDisplay();
Commit: ebd36a8df25d8ef8fcd58603a1b89aec61ce02a8
https://github.com/scummvm/scummvm/commit/ebd36a8df25d8ef8fcd58603a1b89aec61ce02a8
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-16T14:39:31+02:00
Commit Message:
SLUDGE: Complete burnSpriteToBackdrop
Changed paths:
engines/sludge/sprites.cpp
diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp
index 735db7d..c35b2a3 100644
--- a/engines/sludge/sprites.cpp
+++ b/engines/sludge/sprites.cpp
@@ -296,7 +296,9 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
return true;
}
+// pasteSpriteToBackDrop uses the colour specified by the setPasteColour (or setPasteColor)
void pasteSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &fontPal) {
+ //TODO: shader: useLightTexture
x1 -= single.xhot;
y1 -= single.yhot;
Graphics::TransparentSurface tmp(single.surface, false);
@@ -304,108 +306,15 @@ void pasteSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &
TS_RGB(fontPal.originalRed, fontPal.originalGreen, fontPal.originalBlue));
}
+// burnSpriteToBackDrop adds text in the colour specified by setBurnColour
+// using the differing brightness levels of the font to achieve an anti-aliasing effect.
void burnSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &fontPal) {
-#if 0
- float tx1 = (float)(single.tex_x - 0.5) / fontPal.tex_w[single.texNum];
- float ty1 = 0.0;
- float tx2 = (float)(single.tex_x + single.width + 0.5) / fontPal.tex_w[single.texNum];
- float ty2 = (float)(single.height + 2) / fontPal.tex_h[single.texNum];
-
- const GLfloat spriteTexCoords[] = {
- tx1, ty1,
- tx2, ty1,
- tx1, ty2,
- tx2, ty2
- };
-
+ //TODO: shader: useLightTexture
x1 -= single.xhot;
y1 -= single.yhot - 1;
-
- float bx1 = (float)x1 * backdropTexW / sceneWidth;
- float by1 = (float)y1 * backdropTexH / sceneHeight;
- float bx2 = (float)(x1 + single.width - 1) * backdropTexW / sceneWidth;
- float by2 = (float)(y1 + single.height - 1) * backdropTexH / sceneHeight;
-
- const GLfloat backdropTexCoords[] = {
- bx1, by1,
- bx2, by1,
- bx1, by2,
- bx2, by2
- };
-
- const GLfloat backdropTexCoords2[] = {
- 0.0f, 0.0f,
- backdropTexW, 0.0f,
- 0.0f, backdropTexH,
- backdropTexW, backdropTexH
- };
-
- int diffX = single.width + 1;
- int diffY = single.height + 2;
-
- if (x1 < 0) diffX += x1;
- if (y1 < 0) diffY += y1;
- if (x1 + diffX > sceneWidth) diffX = sceneWidth - x1;
- if (y1 + diffY > sceneHeight) diffY = sceneHeight - y1;
- if (diffX < 0) return;
- if (diffY < 0) return;
-
- setPixelCoords(true);
- setPrimaryColor(currentBurnR / 255.f, currentBurnG / 255.f, currentBurnB / 255.f, 1.0f);
-
- GLfloat xoffset = 0.0f;
- while (xoffset < diffX) {
- int w = (diffX - xoffset < viewportWidth) ? diffX - xoffset : viewportWidth;
-
- GLfloat yoffset = 0.0f;
- while (yoffset < diffY) {
- int h = (diffY - yoffset < viewportHeight) ? diffY - yoffset : viewportHeight;
-
- const GLfloat backdropVertices[] = {
- -x1 - xoffset, -y1 + yoffset, 0.0f,
- sceneWidth - 1.0f - x1 - xoffset, -y1 + yoffset, 0.0f,
- -x1 - xoffset, sceneHeight - 1.0f - y1 + yoffset, 0.0f,
- sceneWidth - 1.0f - x1 - xoffset, sceneHeight - 1.0f - y1 + yoffset, 0.0f
- };
-
- const GLfloat spriteVertices[] = {
- -xoffset, -yoffset, 0.0f,
- single.width - 1 - xoffset, -yoffset, 0.0f,
- -xoffset, single.height - 1 - yoffset, 0.0f,
- single.width - 1 - xoffset, single.height - 1 - yoffset, 0.0f
- };
-
- glBindTexture(GL_TEXTURE_2D, backdropTextureName);
- glUseProgram(shader.texture);
- setPMVMatrix(shader.texture);
-
- drawQuad(shader.texture, backdropVertices, 1, backdropTexCoords2);
-
- glActiveTexture(GL_TEXTURE2);
- glBindTexture(GL_TEXTURE_2D, backdropTextureName);
- glActiveTexture(GL_TEXTURE0);
-
- glUseProgram(shader.paste);
- GLint uniform = glGetUniformLocation(shader.paste, "useLightTexture");
- if (uniform >= 0) glUniform1i(uniform, 0); // No lighting
-
- setPMVMatrix(shader.paste);
-
- glBindTexture(GL_TEXTURE_2D, fontPal.burnTex_names[single.texNum]);
-
-//FIXME: Test this some more. Also pasting the backdrop again is not strictly necessary but allows using the paste shader.
- drawQuad(shader.paste, spriteVertices, 3, spriteTexCoords, NULL, backdropTexCoords);
- glUseProgram(0);
-
- // Copy Our ViewPort To The Texture
- copyTexSubImage2D(GL_TEXTURE_2D, 0, (x1 < 0) ? xoffset : x1 + xoffset, (y1 < 0) ? yoffset : y1 + yoffset, viewportOffsetX, viewportOffsetY, w, h, backdropTextureName);
-
- yoffset += viewportHeight;
- }
- xoffset += viewportWidth;
- }
- setPixelCoords(false);
-#endif
+ Graphics::TransparentSurface tmp(single.surface, false);
+ tmp.blit(backdropSurface, x1, y1, Graphics::FLIP_NONE, nullptr,
+ TS_RGB(currentBurnR, currentBurnG, currentBurnB));
}
void fontSprite(bool flip, int x, int y, sprite &single, const spritePalette &fontPal) {
Commit: 17dd32f3db3f138bb8689dc489dbf05b484a8a10
https://github.com/scummvm/scummvm/commit/17dd32f3db3f138bb8689dc489dbf05b484a8a10
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-16T14:39:31+02:00
Commit Message:
SLUDGE: Complete pasteCharacter to backdrop
Changed paths:
engines/sludge/sprites.cpp
diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp
index c35b2a3..798514d 100644
--- a/engines/sludge/sprites.cpp
+++ b/engines/sludge/sprites.cpp
@@ -390,6 +390,8 @@ bool scaleSprite(sprite &single, const spritePalette &fontPal, onScreenPerson *t
y2 = y1 + diffY;
}
+ // TODO: lightmap
+
// Use Transparent surface to scale and blit
if (!zBuffer.numPanels) {
Graphics::TransparentSurface tmp(single.surface, false);
@@ -458,202 +460,52 @@ void killSpriteLayers() {
// Paste a scaled sprite onto the backdrop
void fixScaleSprite(int x, int y, sprite &single, const spritePalette &fontPal, onScreenPerson *thisPerson, int camX, int camY, bool mirror) {
-#if 0
- float scale = thisPerson-> scale;
- bool useZB = !(thisPerson->extra & EXTRA_NOZB);
- bool light = !(thisPerson->extra & EXTRA_NOLITE);
- if (scale <= 0.05) return;
+ float scale = thisPerson->scale;
+ bool useZB = !(thisPerson->extra & EXTRA_NOZB);
+ //bool light = !(thisPerson->extra & EXTRA_NOLITE);
- float tx1 = (float)(single.tex_x) / fontPal.tex_w[single.texNum];
- float ty1 = (float) 1.0 / fontPal.tex_h[single.texNum]; //0.0;
- float tx2 = (float)(single.tex_x + single.width) / fontPal.tex_w[single.texNum];
- float ty2 = (float)(single.height + 1) / fontPal.tex_h[single.texNum];
+ if (scale <= 0.05)
+ return;
- int diffX = (int)(((float)single.width) * scale);
- int diffY = (int)(((float)single.height) * scale);
+ int diffX = (int)(((float)single.surface.w) * scale);
+ int diffY = (int)(((float)single.surface.h) * scale);
int x1;
if (single.xhot < 0)
- x1 = x - (int)((mirror ? (float)(single.width - single.xhot) : (float)(single.xhot + 1)) * scale);
+ x1 = x - (int)((mirror ? (float)(single.surface.w - single.xhot) : (float)(single.xhot + 1)) * scale);
else
- x1 = x - (int)((mirror ? (float)(single.width - (single.xhot + 1)) : (float)single.xhot) * scale);
+ x1 = x - (int)((mirror ? (float)(single.surface.w - (single.xhot + 1)) : (float)single.xhot) * scale);
int y1 = y - (int)((single.yhot - thisPerson->floaty) * scale);
- float spriteWidth = diffX;
- float spriteHeight = diffY;
- if (x1 < 0) diffX += x1;
- if (y1 < 0) diffY += y1;
- if (x1 + diffX > sceneWidth) diffX = sceneWidth - x1;
- if (y1 + diffY > sceneHeight) diffY = sceneHeight - y1;
- if (diffX < 0) return;
- if (diffY < 0) return;
-
- GLfloat z;
-
- if (useZB && zBuffer.numPanels) {
- int i;
- for (i = 1; i < zBuffer.numPanels; i++) {
- if (zBuffer.panel[i] >= y + cameraY) {
- i--;
- break;
- }
- }
- z = 0.999 - (double) i * (1.0 / 128.0);
- } else {
- z = -0.5;
- }
+ // TODO: lightmap
- float ltx1, btx1;
- float ltx2, btx2;
- float lty1, bty1;
- float lty2, bty2;
- if (! NPOT_textures) {
- ltx1 = lightMap.texW * x1 / sceneWidth;
- ltx2 = lightMap.texW * (x1 + spriteWidth) / sceneWidth;
- lty1 = lightMap.texH * y1 / sceneHeight;
- lty2 = lightMap.texH * (y1 + spriteHeight) / sceneHeight;
- btx1 = backdropTexW * x1 / sceneWidth;
- btx2 = backdropTexW * (x1 + spriteWidth) / sceneWidth;
- bty1 = backdropTexH * y1 / sceneHeight;
- bty2 = backdropTexH * (y1 + spriteHeight) / sceneHeight;
- } else {
- btx1 = ltx1 = (float) x1 / sceneWidth;
- btx2 = ltx2 = (float)(x1 + spriteWidth) / sceneWidth;
- bty1 = lty1 = (float) y1 / sceneHeight;
- bty2 = lty2 = (float)(y1 + spriteHeight) / sceneHeight;
- }
+ // draw backdrop
+ drawBackDrop();
- const GLfloat ltexCoords[] = {
- ltx1, lty1,
- ltx2, lty1,
- ltx1, lty2,
- ltx2, lty2
- };
-
- const GLfloat btexCoords[] = {
- btx1, bty1,
- btx2, bty1,
- btx1, bty2,
- btx2, bty2
- };
-
- if (light && lightMap.data) {
- if (lightMapMode == LIGHTMAPMODE_HOTSPOT) {
- int lx = x + cameraX;
- int ly = y + cameraY;
- if (lx < 0 || ly < 0 || lx >= sceneWidth || ly >= sceneHeight) {
- curLight[0] = curLight[1] = curLight[2] = 255;
- } else {
- GLubyte *target = lightMap.data + (ly * sceneWidth + lx) * 4;
- curLight[0] = target[0];
- curLight[1] = target[1];
- curLight[2] = target[2];
- }
- } else if (lightMapMode == LIGHTMAPMODE_PIXEL) {
- curLight[0] = curLight[1] = curLight[2] = 255;
-
- glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, lightMap.name);
+ // draw zBuffer
+ if (zBuffer.numPanels) {
+ drawZBuffer((int)(x1 + camX), (int)(y1 + camY), false);
+ }
- }
+ // draw sprite
+ if (!zBuffer.numPanels) {
+ Graphics::TransparentSurface tmp(single.surface, false);
+ tmp.blit(renderSurface, x1, y1, (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE), nullptr, TS_ARGB(255, 255, 255, 255), diffX, diffY);
} else {
- curLight[0] = curLight[1] = curLight[2] = 255;
+ int d = useZB ? y + cameraY : sceneHeight + 1;
+ addSpriteDepth(&single.surface, d, x1, y1, (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE), diffX, diffY);
}
- glActiveTexture(GL_TEXTURE2);
- glBindTexture(GL_TEXTURE_2D, backdropTextureName);
- glActiveTexture(GL_TEXTURE0);
-
- setPixelCoords(true);
- GLfloat xoffset = 0.0f;
- while (xoffset < diffX) {
- int w = (diffX - xoffset < viewportWidth) ? (int)(diffX - xoffset) : viewportWidth;
-
- GLfloat yoffset = 0.0f;
- while (yoffset < diffY) {
-
- int h = (diffY - yoffset < viewportHeight) ? (int)(diffY - yoffset) : viewportHeight;
-
- // Render the scene - first the old backdrop (so that it'll show through when the z-buffer is active
- //glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glBindTexture(GL_TEXTURE_2D, backdropTextureName);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
- const GLfloat vertices[] = {
- -x1 - xoffset, -y1 - yoffset, 0.0f,
- sceneWidth - x1 - xoffset, -y1 - yoffset, 0.0f,
- -x1 - xoffset, sceneHeight - y1 - yoffset, 0.0f,
- sceneWidth - x1 - xoffset, sceneHeight - y1 - yoffset, 0.0f
- };
-
- const GLfloat texCoords[] = {
- 0.0f, 0.0f,
- backdropTexW, 0.0f,
- 0.0f, backdropTexH,
- backdropTexW, backdropTexH
- };
-
- glUseProgram(shader.texture);
- setPMVMatrix(shader.texture);
-
- drawQuad(shader.texture, vertices, 1, texCoords);
-
- // The z-buffer
- if (useZB) {
- glDepthMask(GL_TRUE);
- glClear(GL_DEPTH_BUFFER_BIT);
- drawZBuffer((int)(x1 + xoffset + camX), (int)(y1 + yoffset + camY), false);
-
- glDepthMask(GL_FALSE);
- glEnable(GL_DEPTH_TEST);
- }
+ // draw all
+ displaySpriteLayers();
- // Then the sprite
- glUseProgram(shader.paste);
- GLint uniform = glGetUniformLocation(shader.paste, "useLightTexture");
- if (uniform >= 0) glUniform1i(uniform, light && lightMapMode == LIGHTMAPMODE_PIXEL && lightMap.data);
- setPMVMatrix(shader.paste);
+ // copy screen to backdrop
+ backdropSurface.copyFrom(renderSurface);
- setDrawMode(thisPerson);
-
- glBindTexture(GL_TEXTURE_2D, fontPal.tex_names[single.texNum]);
-
- const GLfloat vertices2[] = {
- -xoffset, -yoffset, z,
- spriteWidth - xoffset, -yoffset, z,
- -xoffset, spriteHeight - yoffset, z,
- spriteWidth - xoffset, spriteHeight - yoffset, z
- };
-
- if (! mirror) {
- GLfloat tx3 = tx1;
- tx1 = tx2;
- tx2 = tx3;
- }
- const GLfloat texCoords2[] = {
- tx2, ty1,
- tx1, ty1,
- tx2, ty2,
- tx1, ty2
- };
-
- drawQuad(shader.paste, vertices2, 3, texCoords2, ltexCoords, btexCoords);
-
- setSecondaryColor(0., 0., 0., 1.);
- //glDisable(GL_COLOR_SUM); FIXME: replace line?
- // Copy Our ViewPort To The Texture
- glUseProgram(0);
- copyTexSubImage2D(GL_TEXTURE_2D, 0, (int)((x1 < 0) ? xoffset : x1 + xoffset), (int)((y1 < 0) ? yoffset : y1 + yoffset), (int)((x1 < 0) ? viewportOffsetX - x1 : viewportOffsetX), (int)((y1 < 0) ? viewportOffsetY - y1 : viewportOffsetY), w, h, backdropTextureName);
-
- yoffset += viewportHeight;
- }
- xoffset += viewportWidth;
+ // reset zBuffer with the new backdrop
+ if (zBuffer.numPanels) {
+ setZBuffer(zBuffer.originalNum);
}
-
- setPixelCoords(false);
- glUseProgram(0);
-#endif
}
} // End of namespace Sludge
Commit: b789c1ef4a6a47508b222e61818be00e35718ba5
https://github.com/scummvm/scummvm/commit/b789c1ef4a6a47508b222e61818be00e35718ba5
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-16T14:39:31+02:00
Commit Message:
SLUDGE: Add sprite display color
Changed paths:
engines/sludge/sprites.cpp
engines/sludge/sprites.h
diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp
index 798514d..c0fe9e3 100644
--- a/engines/sludge/sprites.cpp
+++ b/engines/sludge/sprites.cpp
@@ -41,11 +41,12 @@ namespace Sludge {
struct SpriteDisplay {
int x, y;
int width, height;
+ uint32 color;
Graphics::FLIP_FLAGS flip;
Graphics::Surface *surface;
- SpriteDisplay(int xpos, int ypos, Graphics::FLIP_FLAGS f, Graphics::Surface *ptr, int w = -1, int h = 1) :
- x(xpos), y(ypos), flip(f), surface(ptr), width(w), height(h) {
+ SpriteDisplay(int xpos, int ypos, Graphics::FLIP_FLAGS f, Graphics::Surface *ptr, int w = -1, int h = 1, uint32 c = TS_ARGB(255, 255, 255, 255)) :
+ x(xpos), y(ypos), flip(f), surface(ptr), width(w), height(h), color(c) {
}
};
@@ -342,16 +343,19 @@ void flipFontSprite(int x, int y, sprite &single, const spritePalette &fontPal)
byte curLight[3];
-void setDrawMode(onScreenPerson *thisPerson) {
+uint32 getDrawColor(onScreenPerson *thisPerson) {
+//TODO: how to mix secondary color
#if 0
if (thisPerson->colourmix) {
//glEnable(GL_COLOR_SUM); FIXME: replace line?
setSecondaryColor(curLight[0]*thisPerson->r * thisPerson->colourmix / 65025 / 255.f, curLight[1]*thisPerson->g * thisPerson->colourmix / 65025 / 255.f, curLight[2]*thisPerson->b * thisPerson->colourmix / 65025 / 255.f, 1.0f);
}
-
- //glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- setPrimaryColor(curLight[0] * (255 - thisPerson->colourmix) / 65025.f, curLight[1] * (255 - thisPerson->colourmix) / 65025.f, curLight[2] * (255 - thisPerson->colourmix) / 65025.f, 1.0f - thisPerson->transparency / 255.f);
#endif
+
+ return TS_ARGB((uint8)(255 - thisPerson->transparency),
+ (uint8)(curLight[0] * (255 - thisPerson->colourmix) / 255.f),
+ (uint8)(curLight[1] * (255 - thisPerson->colourmix) / 255.f),
+ (uint8)(curLight[2] * (255 - thisPerson->colourmix) / 255.f));
}
bool scaleSprite(sprite &single, const spritePalette &fontPal, onScreenPerson *thisPerson, bool mirror) {
@@ -359,6 +363,7 @@ bool scaleSprite(sprite &single, const spritePalette &fontPal, onScreenPerson *t
float y = thisPerson->y;
float scale = thisPerson->scale;
+ bool light = !(thisPerson->extra & EXTRA_NOLITE);
if (scale <= 0.05)
return false;
@@ -390,15 +395,34 @@ bool scaleSprite(sprite &single, const spritePalette &fontPal, onScreenPerson *t
y2 = y1 + diffY;
}
- // TODO: lightmap
+ // set light map color
+ if (light && lightMap.getPixels()) {
+ if (lightMapMode == LIGHTMAPMODE_HOTSPOT) {
+ int lx = x + cameraX;
+ int ly = y + cameraY;
+ if (lx < 0 || ly < 0 || lx >= (int)sceneWidth || ly >= (int)sceneHeight) {
+ curLight[0] = curLight[1] = curLight[2] = 255;
+ } else {
+ byte *target = (byte *)lightMap.getBasePtr(lx, ly);
+ curLight[0] = target[3];
+ curLight[1] = target[2];
+ curLight[2] = target[1];
+ }
+ } else if (lightMapMode == LIGHTMAPMODE_PIXEL) {
+ curLight[0] = curLight[1] = curLight[2] = 255;
+ }
+ } else {
+ curLight[0] = curLight[1] = curLight[2] = 255;
+ }
// Use Transparent surface to scale and blit
+ uint32 spriteColor = getDrawColor(thisPerson);
if (!zBuffer.numPanels) {
Graphics::TransparentSurface tmp(single.surface, false);
- tmp.blit(renderSurface, x1, y1, (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE), nullptr, TS_ARGB(255, 255, 255, 255), diffX, diffY);
+ tmp.blit(renderSurface, x1, y1, (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE), nullptr, spriteColor, diffX, diffY);
} else {
int d = ((!(thisPerson->extra & EXTRA_NOZB)) && zBuffer.numPanels) ? y + cameraY : sceneHeight + 1;
- addSpriteDepth(&single.surface, d, x1, y1, (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE), diffX, diffY);
+ addSpriteDepth(&single.surface, d, x1, y1, (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE), diffX, diffY, spriteColor);
}
// Are we pointing at the sprite?
@@ -428,7 +452,7 @@ void resetSpriteLayers(zBufferData *pz, int x, int y, bool upsidedown) {
}
}
-void addSpriteDepth(Graphics::Surface *ptr, int depth, int x, int y, Graphics::FLIP_FLAGS flip, int width, int height) {
+void addSpriteDepth(Graphics::Surface *ptr, int depth, int x, int y, Graphics::FLIP_FLAGS flip, int width, int height, uint32 color) {
int i;
for (i = 1; i < zBuffer.numPanels; ++i) {
if (zBuffer.panel[i] >= depth) {
@@ -436,7 +460,7 @@ void addSpriteDepth(Graphics::Surface *ptr, int depth, int x, int y, Graphics::F
}
}
--i;
- SpriteDisplay node(x, y, flip, ptr, width, height);
+ SpriteDisplay node(x, y, flip, ptr, width, height, color);
spriteLayers.layer[i].push_back(node);
}
@@ -445,7 +469,7 @@ void displaySpriteLayers() {
Common::List<SpriteDisplay>::iterator it;
for (it = spriteLayers.layer[i].begin(); it != spriteLayers.layer[i].end(); ++it) {
Graphics::TransparentSurface tmp(*it->surface, false);
- tmp.blit(renderSurface, it->x, it->y, it->flip, nullptr, TS_ARGB(255, 255, 255, 255), it->width, it->height);
+ tmp.blit(renderSurface, it->x, it->y, it->flip, nullptr, it->color, it->width, it->height);
}
}
killSpriteLayers();
@@ -463,7 +487,7 @@ void fixScaleSprite(int x, int y, sprite &single, const spritePalette &fontPal,
float scale = thisPerson->scale;
bool useZB = !(thisPerson->extra & EXTRA_NOZB);
- //bool light = !(thisPerson->extra & EXTRA_NOLITE);
+ bool light = !(thisPerson->extra & EXTRA_NOLITE);
if (scale <= 0.05)
return;
@@ -477,7 +501,25 @@ void fixScaleSprite(int x, int y, sprite &single, const spritePalette &fontPal,
x1 = x - (int)((mirror ? (float)(single.surface.w - (single.xhot + 1)) : (float)single.xhot) * scale);
int y1 = y - (int)((single.yhot - thisPerson->floaty) * scale);
- // TODO: lightmap
+ // set light map color
+ if (light && lightMap.getPixels()) {
+ if (lightMapMode == LIGHTMAPMODE_HOTSPOT) {
+ int lx = x + cameraX;
+ int ly = y + cameraY;
+ if (lx < 0 || ly < 0 || lx >= (int)sceneWidth || ly >= (int)sceneHeight) {
+ curLight[0] = curLight[1] = curLight[2] = 255;
+ } else {
+ byte *target = (byte *)lightMap.getBasePtr(lx, ly);
+ curLight[0] = target[3];
+ curLight[1] = target[2];
+ curLight[2] = target[1];
+ }
+ } else if (lightMapMode == LIGHTMAPMODE_PIXEL) {
+ curLight[0] = curLight[1] = curLight[2] = 255;
+ }
+ } else {
+ curLight[0] = curLight[1] = curLight[2] = 255;
+ }
// draw backdrop
drawBackDrop();
@@ -488,12 +530,13 @@ void fixScaleSprite(int x, int y, sprite &single, const spritePalette &fontPal,
}
// draw sprite
+ uint32 spriteColor = getDrawColor(thisPerson);
if (!zBuffer.numPanels) {
Graphics::TransparentSurface tmp(single.surface, false);
- tmp.blit(renderSurface, x1, y1, (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE), nullptr, TS_ARGB(255, 255, 255, 255), diffX, diffY);
+ tmp.blit(renderSurface, x1, y1, (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE), nullptr, spriteColor, diffX, diffY);
} else {
int d = useZB ? y + cameraY : sceneHeight + 1;
- addSpriteDepth(&single.surface, d, x1, y1, (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE), diffX, diffY);
+ addSpriteDepth(&single.surface, d, x1, y1, (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE), diffX, diffY, spriteColor);
}
// draw all
diff --git a/engines/sludge/sprites.h b/engines/sludge/sprites.h
index 80a3493..e0ea21a 100644
--- a/engines/sludge/sprites.h
+++ b/engines/sludge/sprites.h
@@ -78,7 +78,7 @@ void fixScaleSprite(int x1, int y1, sprite &single, const spritePalette &fontPal
void burnSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &fontPal);
void resetSpriteLayers(zBufferData *ptrZBuffer, int x, int y, bool upsidedown);
-void addSpriteDepth(Graphics::Surface *ptr, int depth, int x, int y, Graphics::FLIP_FLAGS flip, int width = -1, int height = -1);
+void addSpriteDepth(Graphics::Surface *ptr, int depth, int x, int y, Graphics::FLIP_FLAGS flip, int width = -1, int height = -1, uint32 color = TS_ARGB(255, 255, 255, 255));
void displaySpriteLayers();
void killSpriteLayers();
More information about the Scummvm-git-logs
mailing list