[Scummvm-git-logs] scummvm master -> a751ad5530b991b92d36c04adff14410156c907a
yinsimei
roseline.yin at gmail.com
Tue Aug 8 14:08:56 CEST 2017
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
cd00521552 SLUDGE: Fix default sprite depth
c9e3747114 SLUDGE: Change debug channels
cff1308ed1 SLUDGE: Implement fileExists built-in function
a751ad5530 SLUDGE: Add thumbnail for save&load interface
Commit: cd0052155275f8cdb667f0ddfa6c66aaac66d318
https://github.com/scummvm/scummvm/commit/cd0052155275f8cdb667f0ddfa6c66aaac66d318
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-08-08T14:08:29+02:00
Commit Message:
SLUDGE: Fix default sprite depth
Changed paths:
engines/sludge/sprites.cpp
diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp
index ed5691e..613a2e0 100644
--- a/engines/sludge/sprites.cpp
+++ b/engines/sludge/sprites.cpp
@@ -390,7 +390,7 @@ bool GraphicsManager::scaleSprite(Sprite &single, const SpritePalette &fontPal,
Graphics::TransparentSurface tmp(single.surface, false);
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;
+ int d = ((!(thisPerson->extra & EXTRA_NOZB)) && _zBuffer->numPanels) ? y + _cameraY : 0;
addSpriteDepth(&single.surface, d, x1, y1, (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE), diffX, diffY, spriteColor);
}
Commit: c9e3747114a3fa583ea397ff1d76b88965e63f67
https://github.com/scummvm/scummvm/commit/c9e3747114a3fa583ea397ff1d76b88965e63f67
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-08-08T14:08:29+02:00
Commit Message:
SLUDGE: Change debug channels
Changed paths:
engines/sludge/builtin.cpp
engines/sludge/sludge.cpp
engines/sludge/sludger.cpp
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index d5d549f..ce66443 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -2584,6 +2584,8 @@ BuiltReturn callBuiltIn(int whichFunc, int numParams, LoadedFunction *fun) {
}
if (builtInFunctionArray[whichFunc].func) {
+ debugC(1, kSludgeDebugBuiltin, "Run built-in function : %s",
+ (whichFunc < numBIFNames) ? allBIFNames[whichFunc].c_str() : "Unknown");
return builtInFunctionArray[whichFunc].func(numParams, fun);
}
}
diff --git a/engines/sludge/sludge.cpp b/engines/sludge/sludge.cpp
index 18d0e3a..aeb6253 100644
--- a/engines/sludge/sludge.cpp
+++ b/engines/sludge/sludge.cpp
@@ -54,8 +54,8 @@ SludgeEngine::SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc)
DebugMan.addDebugChannel(kSludgeDebugGraphics, "Graphics", "Graphics debug level");
DebugMan.addDebugChannel(kSludgeDebugZBuffer, "ZBuffer", "ZBuffer debug level");
- DebugMan.enableDebugChannel("Graphics");
- DebugMan.enableDebugChannel("ZBuffer");
+ DebugMan.enableDebugChannel("Built-in");
+ DebugMan.enableDebugChannel("Stack Machine");
// init graphics
_origFormat = new Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index 930c26d..8f7bfb8 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -412,7 +412,7 @@ bool continueFunction(LoadedFunction *fun) {
while (keepLooping) {
advanceNow = true;
- debugC(2, kSludgeDebugStackMachine, "Executing command line %i : ", fun->runThisLine);
+ debugC(1, kSludgeDebugStackMachine, "Executing command line %i : ", fun->runThisLine);
param = fun->compiledLines[fun->runThisLine].param;
com = fun->compiledLines[fun->runThisLine].theCommand;
// fprintf (stderr, "com: %d param: %d (%s)\n", com, param,
@@ -464,7 +464,7 @@ bool continueFunction(LoadedFunction *fun) {
break;
case SVT_BUILT: {
- debugC(2, kSludgeDebugStackMachine, "Built-in init value: %i",
+ debugC(1, kSludgeDebugStackMachine, "Built-in init value: %i",
fun->reg.varData.intValue);
BuiltReturn br = callBuiltIn(fun->reg.varData.intValue, param,
fun);
Commit: cff1308ed1abecb70f5d2789cf813af25d24c372
https://github.com/scummvm/scummvm/commit/cff1308ed1abecb70f5d2789cf813af25d24c372
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-08-08T14:08:29+02:00
Commit Message:
SLUDGE: Implement fileExists built-in function
Changed paths:
engines/sludge/builtin.cpp
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index ce66443..a092518 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -283,32 +283,26 @@ builtIn(fileExists) {
trimStack(fun->stack);
Common::String aaaaa = encodeFilename(g_sludge->loadNow);
g_sludge->loadNow.clear();
+
if (failSecurityCheck(aaaaa))
return BR_ERROR;
-#if 0
- FILE *fp = fopen(aaaaa, "rb");
- if (!fp) {
- char currentDir[1000];
- if (!getcwd(currentDir, 998)) {
- debugOut("Can't get current directory.\n");
- }
- if (chdir(gamePath)) {
- debugOut("Error: Failed changing to directory %s\n", gamePath);
- }
- fp = fopen(aaaaa, "rb");
- if (chdir(currentDir)) {
- debugOut("Error: Failed changing to directory %s\n", currentDir);
+ bool exist = false;
+
+ Common::File fd;
+ if (fd.open(aaaaa)) {
+ exist = true;
+ fd.close();
+ } else {
+ Common::InSaveFile *fp = g_system->getSavefileManager()->openForLoading(aaaaa);
+ if (fp) {
+ exist = true;
+ delete fp;
}
}
-#endif
+
// Return value
- setVariable(fun->reg, SVT_INT, 0/*(fp != NULL)*/); //TODO:false value
-#if 0
- if (fp) fclose(fp);
- delete[] aaaaa;
- loadNow = NULL;
-#endif
+ setVariable(fun->reg, SVT_INT, exist);
return BR_CONTINUE;
}
Commit: a751ad5530b991b92d36c04adff14410156c907a
https://github.com/scummvm/scummvm/commit/a751ad5530b991b92d36c04adff14410156c907a
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-08-08T14:08:29+02:00
Commit Message:
SLUDGE: Add thumbnail for save&load interface
Changed paths:
R engines/sludge/thumbnail.h
engines/sludge/builtin.cpp
engines/sludge/graphics.h
engines/sludge/loadsave.cpp
engines/sludge/thumbnail.cpp
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index a092518..d63eb97 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -47,7 +47,6 @@
#include "sludge/savedata.h"
#include "sludge/freeze.h"
#include "sludge/language.h"
-#include "sludge/thumbnail.h"
#include "sludge/sludge.h"
#include "sludge/utf8.h"
#include "sludge/graphics.h"
@@ -2440,7 +2439,7 @@ builtIn(showThumbnail) {
Common::String aaaaa = getTextFromAnyVar(fun->stack->thisVar);
trimStack(fun->stack);
Common::String file = encodeFilename(aaaaa);
- showThumbnail(file, x, y);
+ g_sludge->_gfxMan->showThumbnail(file, x, y);
return BR_CONTINUE;
}
diff --git a/engines/sludge/graphics.h b/engines/sludge/graphics.h
index bb84b0b..063006d 100644
--- a/engines/sludge/graphics.h
+++ b/engines/sludge/graphics.h
@@ -163,6 +163,11 @@ public:
void saveColors(Common::WriteStream *stream);
void loadColors(Common::SeekableReadStream *stream);
+ // Thumb nail
+ bool saveThumbnail(Common::WriteStream *stream);
+ bool skipThumbnail(Common::SeekableReadStream *stream);
+ void showThumbnail(const Common::String &filename, int x, int y);
+
private:
SludgeEngine *_vm;
diff --git a/engines/sludge/loadsave.cpp b/engines/sludge/loadsave.cpp
index 1588ffd..21c80f7 100644
--- a/engines/sludge/loadsave.cpp
+++ b/engines/sludge/loadsave.cpp
@@ -44,7 +44,6 @@
#include "sludge/sound.h"
#include "sludge/loadsave.h"
#include "sludge/bg_effects.h"
-#include "sludge/thumbnail.h"
#include "sludge/utf8.h"
#include "sludge/version.h"
#include "sludge/graphics.h"
@@ -354,7 +353,7 @@ bool saveGame(const Common::String &fname) {
fp->writeByte(MAJOR_VERSION);
fp->writeByte(MINOR_VERSION);
- if (!saveThumbnail(fp))
+ if (!g_sludge->_gfxMan->saveThumbnail(fp))
return false;
fp->write(&fileTime, sizeof(FILETIME));
@@ -481,11 +480,10 @@ bool loadGame(const Common::String &fname) {
int majVersion = fp->readByte();
int minVersion = fp->readByte();
- ssgVersion = majVersion * 256 + minVersion;
-
+ ssgVersion = VERSION(majVersion, minVersion);
if (ssgVersion >= VERSION(1, 4)) {
- if (!skipThumbnail(fp))
+ if (!g_sludge->_gfxMan->skipThumbnail(fp))
return fatal(ERROR_GAME_LOAD_CORRUPT, fname);
}
diff --git a/engines/sludge/thumbnail.cpp b/engines/sludge/thumbnail.cpp
index 424feb4..285b43a 100644
--- a/engines/sludge/thumbnail.cpp
+++ b/engines/sludge/thumbnail.cpp
@@ -20,8 +20,13 @@
*
*/
+#include "common/savefile.h"
+#include "image/png.h"
+
#include "sludge/allfiles.h"
#include "sludge/errors.h"
+#include "sludge/graphics.h"
+#include "sludge/imgloader.h"
#include "sludge/moreio.h"
#include "sludge/sludger.h"
#include "sludge/backdrop.h"
@@ -30,157 +35,68 @@
namespace Sludge {
-bool freeze();
-void unfreeze(bool); // Because FREEZE.H needs a load of other includes
-
int thumbWidth = 0, thumbHeight = 0;
-bool saveThumbnail(Common::WriteStream *stream) {
-#if 0
- GLuint thumbnailTextureName = 0;
+bool GraphicsManager::saveThumbnail(Common::WriteStream *stream) {
- fp->writeUint32LE(thumbWidth);
- fp->writeUint32LE(thumbHeight);
+ stream->writeUint32LE(thumbWidth);
+ stream->writeUint32LE(thumbHeight);
if (thumbWidth && thumbHeight) {
- if (! freeze()) return false;
-
- setPixelCoords(true);
-#if 0
- glUseProgram(shader.texture);
-
- setPMVMatrix(shader.texture);
-
- glGenTextures(1, &thumbnailTextureName);
- glBindTexture(GL_TEXTURE_2D, thumbnailTextureName);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
- texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, thumbWidth, thumbHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, thumbnailTextureName);
-
- // Render the backdrop (scaled)
- //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_LINEAR);
-
- const GLfloat vertices[] = {
- 0., 0., 0.,
- thumbWidth - 1.f, 0., 0.,
- 0., thumbHeight - 1.f, 0.,
- thumbWidth - 1.f, thumbHeight - 1.f, 0.
- };
-
- const GLfloat texCoords[] = {
- 0.0f, 0.0f,
- backdropTexW, 0.0f,
- 0.0f, backdropTexH,
- backdropTexW, backdropTexH
- };
-
- drawQuad(shader.texture, vertices, 1, texCoords);
-
- if (gameSettings.antiAlias < 0) {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- } else {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- }
-
- deleteTextures(1, &thumbnailTextureName);
- thumbnailTextureName = 0;
-
- // Save Our ViewPort
- GLushort *image = new GLushort [thumbWidth * thumbHeight];
- GLuint *tmp = new GLuint [thumbWidth * thumbHeight];
- if (! checkNew(image)) return false;
- glReadPixels(viewportOffsetX, viewportOffsetY, thumbWidth, thumbHeight, GL_RGBA, GL_UNSIGNED_BYTE, tmp);
- for (int y = 0; y < thumbHeight; y++) {
- for (int x = 0; x < thumbWidth; x++) {
- const GLuint a = tmp[y * thumbWidth + x];
- image[y * thumbWidth + x] = ((a & 0x00f80000) >> (16 + 3)) | ((a & 0x0000fc00) >> (8 + 2 - 5)) | ((a & 0x000000f8) << (11 - 3));
- }
- }
- delete[] tmp;
+ if (!freeze())
+ return false;
- glUseProgram(0);
-#endif
- setPixelCoords(false);
+ if(!Image::writePNG(*stream, _renderSurface))
+ return false;
- for (int y = 0; y < thumbHeight; y++) {
- for (int x = 0; x < thumbWidth; x++) {
- put2bytes((*(image + y * thumbWidth + x)), fp);
- }
- }
- delete[] image;
- image = NULL;
unfreeze(true);
}
- fputc('!', fp);
-#endif
+ stream->writeByte('!');
return true;
}
-void showThumbnail(const Common::String &filename, int atX, int atY) {
-#if 0
- GLubyte *thumbnailTexture = NULL;
- GLuint thumbnailTextureName = 0;
+void GraphicsManager::showThumbnail(const Common::String &filename, int atX, int atY) {
+ Common::InSaveFile *fp = g_system->getSavefileManager()->openForLoading(filename);
+
+ if (fp == nullptr)
+ return;
+
+ bool headerBad = false;
+ if (fp->readByte() != 'S')
+ headerBad = true;
+ if (fp->readByte() != 'L')
+ headerBad = true;
+ if (fp->readByte() != 'U')
+ headerBad = true;
+ if (fp->readByte() != 'D')
+ headerBad = true;
+ if (fp->readByte() != 'S')
+ headerBad = true;
+ if (fp->readByte() != 'A')
+ headerBad = true;
+ if (headerBad) {
+ fatal(ERROR_GAME_LOAD_NO, filename);
+ return;
+ }
+ char c = fp->readByte();
+ while ((c = fp->readByte()))
+ ;
- GLfloat texCoordW = 1.0;
- GLfloat texCoordH = 1.0;
+ int majVersion = fp->readByte();
+ int minVersion = fp->readByte();
+ int ssgVersion = VERSION(majVersion, minVersion);
- int ssgVersion;
- FILE *fp = openAndVerify(filename, 'S', 'A', ERROR_GAME_LOAD_NO, ssgVersion);
if (ssgVersion >= VERSION(1, 4)) {
- if (fp == NULL) return;
int fileWidth = fp->readUint32LE();
int fileHeight = fp->readUint32LE();
- int picWidth = fileWidth;
- int picHeight = fileHeight;
- if (! NPOT_textures) {
- picWidth = getNextPOT(picWidth);
- picHeight = getNextPOT(picHeight);
- texCoordW = ((double)fileWidth) / picWidth;
- texCoordH = ((double)fileHeight) / picHeight;
-
- }
-
- thumbnailTexture = new GLubyte [picHeight * picWidth * 4];
- if (thumbnailTexture == NULL) return;
-
- int t1, t2;
- uint16 c;
- GLubyte *target;
- for (t2 = 0; t2 < fileHeight; t2++) {
- t1 = 0;
- while (t1 < fileWidth) {
- c = (uint16) fp->readUint16BE();
- target = thumbnailTexture + 4 * picWidth * t2 + t1 * 4;
- target[0] = (GLubyte) redValue(c);
- target[1] = (GLubyte) greenValue(c);
- target[2] = (GLubyte) blueValue(c);
- target[3] = (GLubyte) 255;
- t1++;
- }
- }
-
- fclose(fp);
+ Graphics::TransparentSurface thumbnail;
+ if (!ImgLoader::loadPNGImage(fp, &thumbnail))
+ return;
- glGenTextures(1, &thumbnailTextureName);
- glBindTexture(GL_TEXTURE_2D, thumbnailTextureName);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ delete fp;
+ fp = nullptr;
- texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, picWidth, picHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, thumbnailTexture, thumbnailTextureName);
-
- delete thumbnailTexture;
- thumbnailTexture = NULL;
if (atX < 0) {
fileWidth += atX;
@@ -190,64 +106,31 @@ void showThumbnail(const Common::String &filename, int atX, int atY) {
fileHeight += atY;
atY = 0;
}
- if (fileWidth + atX > sceneWidth) fileWidth = sceneWidth - atX;
- if (fileHeight + atY > sceneHeight) fileHeight = sceneHeight - atY;
-
- setPixelCoords(true);
-
- glUseProgram(shader.texture);
- setPMVMatrix(shader.texture);
-
- int xoffset = 0;
- while (xoffset < fileWidth) {
- int w = (fileWidth - xoffset < viewportWidth) ? fileWidth - xoffset : viewportWidth;
-
- int yoffset = 0;
- while (yoffset < fileHeight) {
- int h = (fileHeight - yoffset < viewportHeight) ? fileHeight - yoffset : viewportHeight;
- glBindTexture(GL_TEXTURE_2D, thumbnailTextureName);
- const GLfloat vertices[] = {
- (GLfloat)fileWidth - 1.f - xoffset, (GLfloat) - yoffset, 0.,
- (GLfloat) - xoffset, (GLfloat) - yoffset, 0.,
- (GLfloat)fileWidth - 1.f - xoffset, (GLfloat)fileHeight - 1.f - yoffset, 0.,
- (GLfloat) - xoffset, (GLfloat)fileHeight - 1.f - yoffset, 0.
- };
-
- const GLfloat texCoords[] = {
- texCoordW, 0.0f,
- 0.0f, 0.0f,
- texCoordW, texCoordH,
- 0.0f, texCoordH
- };
-
- drawQuad(shader.texture, vertices, 1, texCoords);
- glDisable(GL_BLEND);
- // Copy Our ViewPort To The Texture
- copyTexSubImage2D(GL_TEXTURE_2D, 0, atX + xoffset, atY + yoffset, viewportOffsetX, viewportOffsetY, w, h, backdropTextureName);
-
- yoffset += viewportHeight;
- }
- xoffset += viewportWidth;
- }
- glUseProgram(0);
+ if (fileWidth + atX > (int)_sceneWidth)
+ fileWidth = _sceneWidth - atX;
+ if (fileHeight + atY > (int)_sceneHeight)
+ fileHeight = _sceneHeight - atY;
- setPixelCoords(false);
- deleteTextures(1, &thumbnailTextureName);
-
- thumbnailTextureName = 0;
+ thumbnail.blit(_backdropSurface, atX, atY, Graphics::FLIP_NONE, nullptr, TS_ARGB(255, 255, 255, 255), fileWidth, fileHeight);
+ thumbnail.free();
}
-#endif
}
-bool skipThumbnail(Common::SeekableReadStream *stream) {
-#if 0
+bool GraphicsManager::skipThumbnail(Common::SeekableReadStream *stream) {
thumbWidth = stream->readUint32LE();
thumbHeight = stream->readUint32LE();
- uint32 skippy = thumbWidth;
- skippy *= thumbHeight << 1;
- stream->seek(skippy, 1);
+
+ // Load image
+ Graphics::Surface tmp;
+ if (thumbWidth & thumbHeight) {
+ if (!ImgLoader::loadPNGImage(stream, &tmp))
+ return false;
+ else
+ tmp.free();
+ }
+
+ // Check flag
return (stream->readByte() == '!');
-#endif
return true;
}
diff --git a/engines/sludge/thumbnail.h b/engines/sludge/thumbnail.h
deleted file mode 100644
index 43c0e6b..0000000
--- a/engines/sludge/thumbnail.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-#ifndef SLUDGE_THUMBNAIL_H
-#define SLUDGE_THUMBNAIL_H
-
-namespace Sludge {
-
-bool saveThumbnail(Common::WriteStream *stream);
-bool skipThumbnail(Common::SeekableReadStream *stream);
-
-void showThumbnail(const Common::String &filename, int x, int y);
-
-} // End of namespace Sludge
-
-#endif
More information about the Scummvm-git-logs
mailing list