[Scummvm-cvs-logs] SF.net SVN: scummvm: [22463] residual/trunk
aquadran at users.sourceforge.net
aquadran at users.sourceforge.net
Sun May 14 00:53:01 CEST 2006
Revision: 22463
Author: aquadran
Date: 2006-05-14 00:51:41 -0700 (Sun, 14 May 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=22463&view=rev
Log Message:
-----------
corrected screenshot to matach original engine. moved creating savegame screenshot into engine class, some formating code in driver class
Modified Paths:
--------------
residual/trunk/driver_gl.cpp
residual/trunk/driver_tinygl.cpp
residual/trunk/engine.cpp
residual/trunk/engine.h
residual/trunk/lua.cpp
Modified: residual/trunk/driver_gl.cpp
===================================================================
--- residual/trunk/driver_gl.cpp 2006-05-14 06:00:40 UTC (rev 22462)
+++ residual/trunk/driver_gl.cpp 2006-05-14 07:51:41 UTC (rev 22463)
@@ -720,22 +720,33 @@
Bitmap *DriverGL::getScreenshot(int w, int h) {
uint16 *buffer = new uint16[w * h];
uint32 *src = (uint32 *)_storedDisplay;
+
+ int step = 0;
+ for (int y = 0; y <= 479; y++) {
+ for (int x = 0; x <= 639; x++) {
+ uint32 pixel = *(src + y * 640 + x);
+ uint8 r = (pixel & 0xFF0000);
+ uint8 g = (pixel & 0x00FF00);
+ uint8 b = (pixel & 0x0000FF);
+ uint32 color = (r + g + b) / 3;
+ src[step++] = ((color << 24) | (color << 16) | (color << 8) | color);
+ }
+ }
+
float step_x = _screenWidth * 1.0f / w;
float step_y = _screenHeight * 1.0f / h;
-
- int step = 0;
+ step = 0;
for (float y = 0; y < 479; y += step_y) {
for (float x = 0; x < 639; x += step_x) {
uint32 pixel = *(src + (int)y * _screenWidth + (int)x);
-
uint8 r = (pixel & 0xFF0000) >> 16;
uint8 g = (pixel & 0x00FF00) >> 8;
uint8 b = (pixel & 0x0000FF);
uint32 color = (r + g + b) / 3;
- int pos = step/w;
- int wpos = step-pos*w;
+ int pos = step / w;
+ int wpos = step - pos * w;
// source is upside down, flip appropriately while storing
- buffer[h*w - (pos*w+w-wpos)] = ((color & 0xF8) << 8) | ((color & 0xFC) << 3) | (color >> 3);
+ buffer[h * w - (pos * w + w - wpos)] = ((color & 0xF8) << 8) | ((color & 0xFC) << 3) | (color >> 3);
step++;
}
}
@@ -785,7 +796,7 @@
int y = _screenHeight - yReal;
// collect the requested area and generate the dimmed version
- glReadPixels(x, y-h, w, h, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ glReadPixels(x, y - h, w, h, GL_RGBA, GL_UNSIGNED_BYTE, data);
for (int ly = 0; ly < h; ly++) {
for (int lx = 0; lx < w; lx++) {
uint32 pixel = data[ly * w + lx];
@@ -808,7 +819,7 @@
glDepthMask(GL_FALSE);
// Set the raster position and draw the bitmap
- glRasterPos2i(x, yReal+h);
+ glRasterPos2i(x, yReal + h);
glDrawPixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, data);
glDepthMask(GL_TRUE);
Modified: residual/trunk/driver_tinygl.cpp
===================================================================
--- residual/trunk/driver_tinygl.cpp 2006-05-14 06:00:40 UTC (rev 22462)
+++ residual/trunk/driver_tinygl.cpp 2006-05-14 07:51:41 UTC (rev 22463)
@@ -490,20 +490,28 @@
uint16 *src = (uint16 *)_storedDisplay;
assert(buffer);
- float step_x = 640.0 / w;
- float step_y = 480.0 / h;
int step = 0;
- for (float y = 0; y < 479; y += step_y) {
- for (float x = 0; x < 639; x += step_x) {
- uint16 pixel = *(src + (int)y * 640 + (int)x);
+ for (int y = 0; y <= 479; y++) {
+ for (int x = 0; x <= 639; x++) {
+ uint16 pixel = *(src + y * 640 + x);
uint8 r = (pixel & 0xF800) >> 8;
uint8 g = (pixel & 0x07E0) >> 3;
uint8 b = (pixel & 0x001F) << 3;
uint32 color = (r + g + b) / 3;
- buffer[step++] = ((color & 0xF8) << 8) | ((color & 0xFC) << 3) | (color >> 3);
+ src[step++] = ((color & 0xF8) << 8) | ((color & 0xFC) << 3) | (color >> 3);
}
}
+ float step_x = 640.0 / w;
+ float step_y = 480.0 / h;
+ step = 0;
+ for (float y = 0; y < 479; y += step_y) {
+ for (float x = 0; x < 639; x += step_x) {
+ uint16 pixel = *(src + (int)y * 640 + (int)x);
+ buffer[step++] = pixel;
+ }
+ }
+
Bitmap *screenshot = new Bitmap((char *)buffer, w, h, "screenshot");
delete []buffer;
return screenshot;
Modified: residual/trunk/engine.cpp
===================================================================
--- residual/trunk/engine.cpp 2006-05-14 06:00:40 UTC (rev 22462)
+++ residual/trunk/engine.cpp 2006-05-14 07:51:41 UTC (rev 22463)
@@ -505,6 +505,30 @@
printf("Engine::savegameRestore() finished.\n");
}
+void Engine::storeSaveGameImage(SaveGame *savedState) {
+ int width = 250, height = 188;
+ Bitmap *screenshot;
+
+ printf("Engine::StoreSaveGameImage() started.\n");
+
+ int mode = g_engine->getMode();
+ g_engine->setMode(ENGINE_MODE_NORMAL);
+ g_engine->updateDisplayScene();
+ screenshot = g_driver->getScreenshot(width, height);
+ g_engine->setMode(mode);
+ savedState->beginSection('SIMG');
+ if (screenshot) {
+ int size = screenshot->width() * screenshot->height() * sizeof(uint16);
+ screenshot->setNumber(0);
+ char *data = screenshot->getData();
+ savedState->write(data, size);
+ } else {
+ error("Unable to store screenshot!");
+ }
+ savedState->endSection();
+ printf("Engine::StoreSaveGameImage() finished.\n");
+}
+
void Engine::savegameSave() {
printf("Engine::savegameSave() started.\n");
_savegameSaveRequest = false;
@@ -516,6 +540,8 @@
}
_savedState = new SaveGame(filename, true);
+ storeSaveGameImage(_savedState);
+
g_imuse->pause(true);
g_smush->pause(true);
Modified: residual/trunk/engine.h
===================================================================
--- residual/trunk/engine.h 2006-05-14 06:00:40 UTC (rev 22462)
+++ residual/trunk/engine.h 2006-05-14 07:51:41 UTC (rev 22463)
@@ -158,6 +158,7 @@
void savegameCallback();
static void savegameRead(void *data, int size);
static void savegameWrite(void *data, int size);
+ void storeSaveGameImage(SaveGame *savedState);
bool _savegameLoadRequest;
bool _savegameSaveRequest;
Modified: residual/trunk/lua.cpp
===================================================================
--- residual/trunk/lua.cpp 2006-05-14 06:00:40 UTC (rev 22462)
+++ residual/trunk/lua.cpp 2006-05-14 07:51:41 UTC (rev 22463)
@@ -2800,37 +2800,6 @@
}
/*
- * Store a screenshot into a savegame file
- *
- */
-static void StoreSaveGameImage(SaveGame *savedState) {
- int width = 250, height = 188;
- Bitmap *screenshot;
-
- printf("StoreSaveGameImage() started.\n");
-
- DEBUG_FUNCTION();
-
- int mode = g_engine->getMode();
- g_engine->setMode(ENGINE_MODE_NORMAL);
- g_engine->updateDisplayScene();
- screenshot = g_driver->getScreenshot(width, height);
- g_engine->setMode(mode);
- savedState->beginSection('SIMG');
- if (screenshot) {
- int size = screenshot->width() * screenshot->height() * sizeof(uint16);
- screenshot->setNumber(0);
- char *data = screenshot->getData();
-
- savedState->write(data, size);
- } else {
- error("Unable to store screenshot!");
- }
- savedState->endSection();
- printf("StoreSaveGameImage() finished.\n");
-}
-
-/*
* Restore a screenshot from a savegame file
*
*/
@@ -2888,7 +2857,6 @@
}
savedState->endSection();
printf("SubmitSaveGameData() finished.\n");
- StoreSaveGameImage(savedState);
}
static void GetSaveGameData() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list