[Scummvm-git-logs] scummvm master -> 5eda2befbb29eaacb3ebfafd3a486f25821f053b
yinsimei
roseline.yin at gmail.com
Tue Aug 15 07:59:22 CEST 2017
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
302a14677d SLUDGE: Fix sprite darkness bug and refactor
5eda2befbb SLUDGE: Add debug channel
Commit: 302a14677d5fcaa89410d248b4dae1b51854051b
https://github.com/scummvm/scummvm/commit/302a14677d5fcaa89410d248b4dae1b51854051b
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-08-15T07:47:56+02:00
Commit Message:
SLUDGE: Fix sprite darkness bug and refactor
Changed paths:
engines/sludge/graphics.h
engines/sludge/sprites.cpp
diff --git a/engines/sludge/graphics.h b/engines/sludge/graphics.h
index 16bf714..c5914c7 100644
--- a/engines/sludge/graphics.h
+++ b/engines/sludge/graphics.h
@@ -205,7 +205,9 @@ private:
// Sprites
SpriteLayers *_spriteLayers;
void fontSprite(bool flip, int x, int y, Sprite &single, const SpritePalette &fontPal);
- uint32 getDrawColor(OnScreenPerson *thisPerson, byte *curLight);
+ Graphics::Surface *duplicateSurface(Graphics::Surface *surface);
+ void blendColor(Graphics::Surface * surface, uint32 color, Graphics::TSpriteBlendMode mode);
+ Graphics::Surface *applyLightmapToSprite(Graphics::Surface *&blitted, OnScreenPerson *thisPerson, bool mirror, int x, int y, int x1, int y1, int diffX, int diffY);
// Sprite banks
LoadedSpriteBanks _allLoadedBanks;
diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp
index d956535..98d88a8 100644
--- a/engines/sludge/sprites.cpp
+++ b/engines/sludge/sprites.cpp
@@ -313,7 +313,60 @@ void GraphicsManager::flipFontSprite(int x, int y, Sprite &single, const SpriteP
fontSprite(true, x, y, single, fontPal);
}
-uint32 GraphicsManager::getDrawColor(OnScreenPerson *thisPerson, byte *curLight) {
+Graphics::Surface *GraphicsManager::duplicateSurface(Graphics::Surface *surface) {
+ Graphics::Surface *res = new Graphics::Surface();
+ res->copyFrom(*surface);
+ return res;
+}
+
+void GraphicsManager::blendColor(Graphics::Surface *blitted, uint32 color, Graphics::TSpriteBlendMode mode) {
+ Graphics::TransparentSurface tmp;
+ tmp.create(blitted->w, blitted->h, blitted->format);
+ tmp.fillRect(Common::Rect(0, 0, tmp.w, tmp.h), color);
+ tmp.blit(*blitted, 0, 0, Graphics::FLIP_NONE, nullptr, TS_ARGB(255, 255, 255, 255), blitted->w, blitted->h, mode);
+ tmp.free();
+}
+
+Graphics::Surface *GraphicsManager::applyLightmapToSprite(Graphics::Surface *&blitted, OnScreenPerson *thisPerson, bool mirror, int x, int y, int x1, int y1, int diffX, int diffY) {
+ Graphics::Surface * toDetele = nullptr;
+
+ // if light map is used
+ bool light = !(thisPerson->extra & EXTRA_NOLITE);
+
+ // apply light map and set light map color
+ byte curLight[3];
+ 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;
+
+ toDetele = blitted = duplicateSurface(blitted);
+
+ // apply light map texture
+ Graphics::TransparentSurface tmp(_lightMap, false);
+ Common::Rect rect_none(x1, y1, x1 + diffX, y1 + diffY);
+ Common::Rect rect_h(_sceneWidth - x1 - diffX, y1, _sceneWidth - x1, y1 + diffY);
+ tmp.blit(*blitted, 0, 0,
+ (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE),
+ (mirror ? &rect_h : &rect_none),
+ TS_ARGB(255, 255, 255, 255),
+ blitted->w, blitted->h, Graphics::BLEND_MULTIPLY);
+ }
+ } else {
+ curLight[0] = curLight[1] = curLight[2] = 255;
+ }
+
+ // calculate light map color
float fr, fg, fb;
fr = fg = fb = 0.f;
if (thisPerson->colourmix) {
@@ -322,10 +375,29 @@ uint32 GraphicsManager::getDrawColor(OnScreenPerson *thisPerson, byte *curLight)
fb = curLight[2]*thisPerson->b * thisPerson->colourmix / 65025 / 255.f;
}
- return TS_ARGB((uint8)(255 - thisPerson->transparency),
+ uint32 primaryColor = TS_ARGB((uint8)(255 - thisPerson->transparency),
(uint8)(fr + curLight[0] * (255 - thisPerson->colourmix) / 255.f),
(uint8)(fg + curLight[1] * (255 - thisPerson->colourmix) / 255.f),
(uint8)(fb + curLight[2] * (255 - thisPerson->colourmix) / 255.f));
+
+ uint32 secondaryColor = TS_ARGB(0, (uint8)(fr * 255), (uint8)(fg * 255), (uint8)(fb * 255));
+
+ // apply primary color
+ if (primaryColor != (uint32)TS_ARGB(255, 255, 255, 255)) {
+ if (!toDetele) {
+ toDetele = blitted = duplicateSurface(blitted);
+ blendColor(blitted, primaryColor, Graphics::BLEND_MULTIPLY);
+ }
+ }
+
+ // apply secondary light map color
+ if (secondaryColor != 0x0) {
+ if (!toDetele) {
+ toDetele = blitted = duplicateSurface(blitted);
+ }
+ blendColor(blitted, secondaryColor, Graphics::BLEND_ADDITIVE);
+ }
+ return toDetele;
}
bool GraphicsManager::scaleSprite(Sprite &single, const SpritePalette &fontPal, OnScreenPerson *thisPerson, bool mirror) {
@@ -334,7 +406,6 @@ bool GraphicsManager::scaleSprite(Sprite &single, const SpritePalette &fontPal,
float scale = thisPerson->scale;
bool useZB = !(thisPerson->extra & EXTRA_NOZB);
- bool light = !(thisPerson->extra & EXTRA_NOLITE);
if (scale <= 0.05)
return false;
@@ -366,50 +437,8 @@ bool GraphicsManager::scaleSprite(Sprite &single, const SpritePalette &fontPal,
y2 = y1 + diffY;
}
- Graphics::Surface *ptr = nullptr;
Graphics::Surface *blitted = &single.surface;
-
- // apply light map and set light map color
- byte curLight[3];
- 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;
- ptr = blitted = new Graphics::Surface();
- blitted->copyFrom(single.surface);
- Graphics::TransparentSurface tmp(_lightMap, false);
- Common::Rect rect_none(x1, y1, x1 + diffX, y1 + diffY);
- Common::Rect rect_h(_sceneWidth - x1 - diffX, y1, _sceneWidth - x1, y1 + diffY);
- tmp.blit(*blitted, 0, 0,
- (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE),
- (mirror ? &rect_h : &rect_none),
- TS_ARGB(255, 255, 255, 255),
- blitted->w, blitted->h, Graphics::BLEND_MULTIPLY);
- }
- } else {
- curLight[0] = curLight[1] = curLight[2] = 255;
- }
-
- // apply light map color
- uint32 spriteColor = getDrawColor(thisPerson, curLight);
- if (spriteColor != (uint32)TS_ARGB(255, 255, 255, 255)) {
- if (!ptr) {
- ptr = blitted = new Graphics::Surface();
- blitted->copyFrom(single.surface);
- }
- Graphics::TransparentSurface tmp(*blitted, false);
- tmp.blit(*blitted, 0, 0, Graphics::FLIP_NONE, nullptr, spriteColor, blitted->w, blitted->h, Graphics::BLEND_MULTIPLY);
- }
+ Graphics::Surface *ptr = applyLightmapToSprite(blitted, thisPerson, mirror, x, y, x1, y1, diffX, diffY);
// Use Transparent surface to scale and blit
if (!_zBuffer->numPanels) {
@@ -503,7 +532,6 @@ void GraphicsManager::fixScaleSprite(int x, int y, Sprite &single, const SpriteP
float scale = thisPerson->scale;
bool useZB = !(thisPerson->extra & EXTRA_NOZB);
- bool light = !(thisPerson->extra & EXTRA_NOLITE);
if (scale <= 0.05)
return;
@@ -517,50 +545,8 @@ void GraphicsManager::fixScaleSprite(int x, int y, Sprite &single, const SpriteP
x1 = x - (int)((mirror ? (float)(single.surface.w - (single.xhot + 1)) : (float)single.xhot) * scale);
int y1 = y - (int)((single.yhot - thisPerson->floaty) * scale);
- Graphics::Surface *ptr = nullptr;
Graphics::Surface *blitted = &single.surface;
-
- // set light map color
- byte curLight[3];
- 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;
- ptr = blitted = new Graphics::Surface();
- blitted->copyFrom(single.surface);
- Graphics::TransparentSurface tmp(_lightMap, false);
- Common::Rect rect_none(x1, y1, x1 + diffX, y1 + diffY);
- Common::Rect rect_h(_sceneWidth - x1 - diffX, y1, _sceneWidth - x1, y1 + diffY);
- tmp.blit(*blitted, 0, 0,
- (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE),
- (mirror ? &rect_h : &rect_none),
- TS_ARGB(255, 255, 255, 255),
- blitted->w, blitted->h, Graphics::BLEND_MULTIPLY);
- }
- } else {
- curLight[0] = curLight[1] = curLight[2] = 255;
- }
-
- // apply light map color
- uint32 spriteColor = getDrawColor(thisPerson, curLight);
- if (spriteColor != (uint32)TS_ARGB(255, 255, 255, 255)) {
- if (!ptr) {
- ptr = blitted = new Graphics::Surface();
- blitted->copyFrom(single.surface);
- }
- Graphics::TransparentSurface tmp(*blitted, false);
- tmp.blit(*blitted, 0, 0, Graphics::FLIP_NONE, nullptr, spriteColor, blitted->w, blitted->h, Graphics::BLEND_MULTIPLY);
- }
+ Graphics::Surface *ptr = applyLightmapToSprite(blitted, thisPerson, mirror, x, y, x1, y1, diffX, diffY);
// draw backdrop
drawBackDrop();
Commit: 5eda2befbb29eaacb3ebfafd3a486f25821f053b
https://github.com/scummvm/scummvm/commit/5eda2befbb29eaacb3ebfafd3a486f25821f053b
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-08-15T07:47:56+02:00
Commit Message:
SLUDGE: Add debug channel
Changed paths:
engines/sludge/imgloader.cpp
engines/sludge/moreio.cpp
engines/sludge/sludge.cpp
engines/sludge/sludge.h
engines/sludge/sludger.cpp
engines/sludge/sprbanks.cpp
diff --git a/engines/sludge/imgloader.cpp b/engines/sludge/imgloader.cpp
index 86f6b2f..64c8d78 100644
--- a/engines/sludge/imgloader.cpp
+++ b/engines/sludge/imgloader.cpp
@@ -33,7 +33,7 @@
namespace Sludge {
bool ImgLoader::loadImage(Common::SeekableReadStream *stream, Graphics::Surface *dest, int reserve) {
- debugC(2, kSludgeDebugDataLoad, "Loading image at position: %i", stream->pos());
+ debugC(3, kSludgeDebugDataLoad, "Loading image at position: %i", stream->pos());
int32 start_ptr = stream->pos();
if (!loadPNGImage(stream, dest)) {
stream->seek(start_ptr);
diff --git a/engines/sludge/moreio.cpp b/engines/sludge/moreio.cpp
index a5c7318..4a57000 100644
--- a/engines/sludge/moreio.cpp
+++ b/engines/sludge/moreio.cpp
@@ -46,7 +46,7 @@ Common::String readString(Common::SeekableReadStream *stream) {
for (int a = 0; a < len; a++) {
res += (char)(stream->readByte() - 1);
}
- debugC(2, kSludgeDebugDataLoad, "Read string of length %i: %s", len, res.c_str());
+ debugC(3, kSludgeDebugDataLoad, "Read string of length %i: %s", len, res.c_str());
return res;
}
diff --git a/engines/sludge/sludge.cpp b/engines/sludge/sludge.cpp
index aeb6253..9976652 100644
--- a/engines/sludge/sludge.cpp
+++ b/engines/sludge/sludge.cpp
@@ -53,9 +53,9 @@ SludgeEngine::SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc)
DebugMan.addDebugChannel(kSludgeDebugBuiltin, "Built-in", "Built-in debug level");
DebugMan.addDebugChannel(kSludgeDebugGraphics, "Graphics", "Graphics debug level");
DebugMan.addDebugChannel(kSludgeDebugZBuffer, "ZBuffer", "ZBuffer debug level");
+ DebugMan.addDebugChannel(kSludgeDebugSound, "Sound", "Sound debug level");
- DebugMan.enableDebugChannel("Built-in");
- DebugMan.enableDebugChannel("Stack Machine");
+ DebugMan.enableDebugChannel("Sound");
// init graphics
_origFormat = new Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
diff --git a/engines/sludge/sludge.h b/engines/sludge/sludge.h
index ada139a..d868754 100644
--- a/engines/sludge/sludge.h
+++ b/engines/sludge/sludge.h
@@ -55,7 +55,8 @@ enum {
kSludgeDebugStackMachine = 1 << 2,
kSludgeDebugBuiltin = 1 << 3,
kSludgeDebugGraphics = 1 << 4,
- kSludgeDebugZBuffer = 1 << 5
+ kSludgeDebugZBuffer = 1 << 5,
+ kSludgeDebugSound = 1 << 6
};
class SludgeEngine: public Engine {
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index 8f7bfb8..8e49b32 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -178,6 +178,7 @@ bool initSludge(const Common::String &filename) {
for (int fn = 0; fn < numResourceNames; fn++) {
allResourceNames[fn].clear();
allResourceNames[fn] = readString(fp);
+ debugC(2, kSludgeDebugDataLoad, "Resource %i: %s", fn, allResourceNames[fn].c_str());
}
}
}
@@ -918,16 +919,16 @@ bool loadFunctionCode(LoadedFunction *newFunc) {
if (!g_sludge->_resMan->openSubSlice(newFunc->originalNumber))
return false;
- debugC(2, kSludgeDebugDataLoad, "Load function code");
+ debugC(3, kSludgeDebugDataLoad, "Load function code");
Common::SeekableReadStream *readStream = g_sludge->_resMan->getData();
newFunc->unfreezable = readStream->readByte();
numLines = readStream->readUint16BE();
- debugC(2, kSludgeDebugDataLoad, "numLines: %i", numLines);
+ debugC(3, kSludgeDebugDataLoad, "numLines: %i", numLines);
newFunc->numArgs = readStream->readUint16BE();
- debugC(2, kSludgeDebugDataLoad, "numArgs: %i", newFunc->numArgs);
+ debugC(3, kSludgeDebugDataLoad, "numArgs: %i", newFunc->numArgs);
newFunc->numLocals = readStream->readUint16BE();
- debugC(2, kSludgeDebugDataLoad, "numLocals: %i", newFunc->numLocals);
+ debugC(3, kSludgeDebugDataLoad, "numLocals: %i", newFunc->numLocals);
newFunc->compiledLines = new LineOfCode[numLines];
if (!checkNew(newFunc->compiledLines))
return false;
@@ -935,7 +936,7 @@ bool loadFunctionCode(LoadedFunction *newFunc) {
for (numLinesRead = 0; numLinesRead < numLines; numLinesRead++) {
newFunc->compiledLines[numLinesRead].theCommand = (sludgeCommand)readStream->readByte();
newFunc->compiledLines[numLinesRead].param = readStream->readUint16BE();
- debugC(2, kSludgeDebugDataLoad, "command line %i: %i", numLinesRead,
+ debugC(3, kSludgeDebugDataLoad, "command line %i: %i", numLinesRead,
newFunc->compiledLines[numLinesRead].theCommand);
}
g_sludge->_resMan->finishAccess();
diff --git a/engines/sludge/sprbanks.cpp b/engines/sludge/sprbanks.cpp
index 265257c..5bc5de2 100644
--- a/engines/sludge/sprbanks.cpp
+++ b/engines/sludge/sprbanks.cpp
@@ -46,11 +46,11 @@ LoadedSpriteBank *GraphicsManager::loadBankForAnim(int ID) {
returnMe->ID = ID;
if (loadSpriteBank(ID, returnMe->bank, false)) {
returnMe->timesUsed = 0;
- debugC(2, kSludgeDebugDataLoad, "loadBankForAnim: New sprite bank created OK");
+ debugC(3, kSludgeDebugDataLoad, "loadBankForAnim: New sprite bank created OK");
_allLoadedBanks.push_back(returnMe);
return returnMe;
} else {
- debugC(2, kSludgeDebugDataLoad, "loadBankForAnim: I guess I couldn't load the sprites...");
+ debugC(3, kSludgeDebugDataLoad, "loadBankForAnim: I guess I couldn't load the sprites...");
return nullptr;
}
} else
More information about the Scummvm-git-logs
mailing list