[Scummvm-cvs-logs] CVS: residual driver.h,1.15,1.16 driver_gl.cpp,1.58,1.59 driver_gl.h,1.28,1.29 driver_tinygl.cpp,1.31,1.32 driver_tinygl.h,1.16,1.17 engine.cpp,1.96,1.97 engine.h,1.37,1.38 lua.cpp,1.159,1.160
Pawel Kolodziejski
aquadran at users.sourceforge.net
Sun Aug 28 16:27:12 CEST 2005
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6762
Modified Files:
driver.h driver_gl.cpp driver_gl.h driver_tinygl.cpp
driver_tinygl.h engine.cpp engine.h lua.cpp
Log Message:
added dim support
Index: driver.h
===================================================================
RCS file: /cvsroot/scummvm/residual/driver.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- driver.h 13 Aug 2005 20:14:46 -0000 1.15
+++ driver.h 28 Aug 2005 23:25:13 -0000 1.16
@@ -39,7 +39,6 @@
_screenHeight = screenH;
_screenBPP = screenBPP;
_isFullscreen = fullscreen;
- _dim = false;
}
struct TextObjectHandle {
@@ -85,8 +84,8 @@
virtual Bitmap *getScreenshot(int w, int h) = 0;
virtual void storeDisplay() = 0;
virtual void copyStoredToDisplay() = 0;
- virtual void enableDim(int x, int y, int w, int h) = 0;
- virtual void disableDim(int x, int y, int w, int h) = 0;
+ virtual void dimScreen() = 0;
+ virtual void dimRegion(int x, int y, int w, int h, float level) = 0;
virtual void drawEmergString(int x, int y, const char *text, const Color &fgColor) = 0;
virtual void loadEmergFont() = 0;
@@ -103,9 +102,6 @@
protected:
int _screenWidth, _screenHeight, _screenBPP;
bool _isFullscreen;
- bool _dim;
-
- virtual void drawDim() = 0;
};
extern Driver *g_driver;
Index: driver_gl.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_gl.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- driver_gl.cpp 13 Aug 2005 20:14:46 -0000 1.58
+++ driver_gl.cpp 28 Aug 2005 23:25:14 -0000 1.59
@@ -703,7 +703,16 @@
return NULL;
}
-void DriverGL::drawDim() {
+void DriverGL::storeDisplay() {
+}
+
+void DriverGL::copyStoredToDisplay() {
+}
+
+void DriverGL::dimScreen() {
+}
+
+void DriverGL::dimRegion(int x, int y, int w, int h, float level) {
}
void DriverGL::drawRectangle(PrimitiveObject *primitive) {
Index: driver_gl.h
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_gl.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- driver_gl.h 13 Aug 2005 20:14:46 -0000 1.28
+++ driver_gl.h 28 Aug 2005 23:25:14 -0000 1.29
@@ -66,10 +66,10 @@
void drawBitmap();
Bitmap *getScreenshot(int w, int h);
- void storeDisplay() {}
- void copyStoredToDisplay() {}
- void enableDim(int /*x*/, int /*y*/, int /*w*/, int /*h*/) { _dim = true; }
- void disableDim(int /*x*/, int /*y*/, int /*w*/, int /*h*/) { _dim = false; }
+ void storeDisplay();
+ void copyStoredToDisplay();
+ void dimScreen();
+ void dimRegion(int x, int y, int w, int h, float level);
void drawEmergString(int x, int y, const char *text, const Color &fgColor);
void loadEmergFont();
@@ -84,7 +84,6 @@
void drawSmushFrame(int offsetX, int offsetY);
protected:
- void drawDim();
private:
GLuint _emergFont;
Index: driver_tinygl.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_tinygl.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- driver_tinygl.cpp 14 Aug 2005 14:30:18 -0000 1.31
+++ driver_tinygl.cpp 28 Aug 2005 23:25:14 -0000 1.32
@@ -482,7 +482,12 @@
int step = 0;
for (float y = 0; y < 479; y += step_y) {
for (float x = 0; x < 639; x += step_x) {
- buffer[step++] = *(src + (int)y * 640 + (int)x);
+ uint16 pixel = *(src + (int)y * 640 + (int)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);
}
}
@@ -499,7 +504,30 @@
memcpy(_zb->pbuf, _storedDisplay, 640 * 480 * 2);
}
-void DriverTinyGL::drawDim() {
+void DriverTinyGL::dimScreen() {
+ uint16 *data = (uint16 *)_storedDisplay;
+ for (int l = 0; l < 640 * 480; l++) {
+ uint16 pixel = data[l];
+ uint8 r = (pixel & 0xF800) >> 8;
+ uint8 g = (pixel & 0x07E0) >> 3;
+ uint8 b = (pixel & 0x001F) << 3;
+ uint32 color = (r + g + b) / 6;
+ data[l] = ((color & 0xF8) << 8) | ((color & 0xFC) << 3) | (color >> 3);
+ }
+}
+
+void DriverTinyGL::dimRegion(int x, int y, int w, int h, float level) {
+ uint16 *data = (uint16 *)_zb->pbuf;
+ for (int ly = y; ly < y + h; ly++) {
+ for (int lx = x; lx < x + w; lx++) {
+ uint16 pixel = data[ly * 640 + lx];
+ uint8 r = (pixel & 0xF800) >> 8;
+ uint8 g = (pixel & 0x07E0) >> 3;
+ uint8 b = (pixel & 0x001F) << 3;
+ uint16 color = (uint16)(((r + g + b) / 3) * level);
+ data[ly * 640 + lx] = ((color & 0xF8) << 8) | ((color & 0xFC) << 3) | (color >> 3);
+ }
+ }
}
void DriverTinyGL::drawRectangle(PrimitiveObject *primitive) {
Index: driver_tinygl.h
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_tinygl.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- driver_tinygl.h 13 Aug 2005 20:14:46 -0000 1.16
+++ driver_tinygl.h 28 Aug 2005 23:25:14 -0000 1.17
@@ -66,12 +66,12 @@
void drawDepthBitmap(int x, int y, int w, int h, char *data);
void drawBitmap();
+ void dimScreen();
+ void dimRegion(int x, int y, int w, int h, float level);
Bitmap *getScreenshot(int w, int h);
void storeDisplay();
void copyStoredToDisplay();
- void enableDim(int /*x*/, int /*y*/, int /*w*/, int /*h*/) { _dim = true; }
- void disableDim(int /*x*/, int /*y*/, int /*w*/, int /*h*/) { _dim = false; }
void drawEmergString(int x, int y, const char *text, const Color &fgColor);
void loadEmergFont();
@@ -86,7 +86,6 @@
void drawSmushFrame(int offsetX, int offsetY);
protected:
- void drawDim();
private:
ZBuffer *_zb;
Index: engine.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.cpp,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -d -r1.96 -r1.97
--- engine.cpp 27 Aug 2005 16:08:44 -0000 1.96
+++ engine.cpp 28 Aug 2005 23:25:14 -0000 1.97
@@ -154,6 +154,7 @@
if (resource == NULL)
warning("Requested resouce (%s) not found!");
}
+
void Engine::drawPrimitives() {
// Draw Primitives
for (PrimitiveListType::iterator i = _primitiveObjects.begin(); i != _primitiveObjects.end(); i++) {
@@ -164,15 +165,6 @@
for (TextListType::iterator i = _textObjects.begin(); i != _textObjects.end(); i++) {
(*i)->draw();
}
-
- if (_mode == ENGINE_MODE_DRAW) {
- g_engine->killPrimitiveObjects();
- g_engine->killTextObjects();
-
- // Cleanup references to deleted text objects
- for (Engine::ActorListType::const_iterator i = g_engine->actorsBegin(); i != g_engine->actorsEnd(); i++)
- (*i)->lineCleanup();
- }
}
void Engine::luaUpdate() {
@@ -200,8 +192,7 @@
}
void Engine::updateDisplayScene() {
- static char fps[8] = "";
- bool doFlip = true;
+ _doFlip = true;
if (_mode == ENGINE_MODE_SMUSH) {
if (g_smush->isPlaying()) {
@@ -217,11 +208,12 @@
_prevSmushFrame = g_smush->getFrame();
g_driver->drawSmushFrame(g_smush->getX(), g_smush->getY());
if (SHOWFPS_GLOBAL)
- g_driver->drawEmergString(550, 25, fps, Color(255, 255, 255));
+ g_driver->drawEmergString(550, 25, _fps, Color(255, 255, 255));
} else
- doFlip = false;
+ _doFlip = false;
}
}
+ drawPrimitives();
} else if (_mode == ENGINE_MODE_NORMAL) {
if (_currScene == NULL)
return;
@@ -293,6 +285,7 @@
_currScene->drawBitmaps(ObjectState::OBJSTATE_OVERLAY);
g_driver->storeDisplay();
+ drawPrimitives();
} else if (_mode == ENGINE_MODE_DRAW) {
if (_refreshDrawNeeded) {
lua_beginblock();
@@ -306,23 +299,23 @@
_refreshDrawNeeded = false;
return;
}
+}
- drawPrimitives();
-
+void Engine::doFlip() {
if (SHOWFPS_GLOBAL)
- g_driver->drawEmergString(550, 25, fps, Color(255, 255, 255));
+ g_driver->drawEmergString(550, 25, _fps, Color(255, 255, 255));
- if (doFlip && _flipEnable)
+ if (_doFlip && _flipEnable)
g_driver->flipBuffer();
// don't kill CPU
SDL_Delay(1);
- if (SHOWFPS_GLOBAL && doFlip) {
+ if (SHOWFPS_GLOBAL && _doFlip) {
_frameCounter++;
_timeAccum += _frameTime;
if (_timeAccum > 1000) {
- sprintf(fps, "%7.2f", (double)(_frameCounter * 1000) / (double)_timeAccum );
+ sprintf(_fps, "%7.2f", (double)(_frameCounter * 1000) / (double)_timeAccum );
_frameCounter = 0;
_timeAccum = 0;
}
@@ -390,6 +383,7 @@
if (_mode != ENGINE_MODE_PAUSE) {
updateDisplayScene();
+ doFlip();
}
if (g_imuseState != -1) {
Index: engine.h
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- engine.h 27 Aug 2005 16:08:44 -0000 1.37
+++ engine.h 28 Aug 2005 23:25:14 -0000 1.38
@@ -107,6 +107,7 @@
void handleDebugLoadResource();
void luaUpdate();
void updateDisplayScene();
+ void doFlip();
void setFlipEnable(bool state) { _flipEnable = state; }
bool getFlipEnable() { return _flipEnable; }
void refreshDrawMode() { _refreshDrawNeeded = true; }
@@ -222,6 +223,8 @@
int _textSpeed;
bool _flipEnable;
bool _refreshDrawNeeded;
+ char _fps[8];
+ bool _doFlip;
unsigned _frameStart, _frameTime, _movieTime;
unsigned int _frameTimeCollection;
Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -d -r1.159 -r1.160
--- lua.cpp 27 Aug 2005 16:17:53 -0000 1.159
+++ lua.cpp 28 Aug 2005 23:25:14 -0000 1.160
@@ -2207,24 +2207,20 @@
}
static void BlastImage() {
- PrimitiveObject *p = new PrimitiveObject();
bool transparent;
Bitmap *bitmap;
int x, y;
DEBUG_FUNCTION();
- // Allow displaying a null image to fail gracefully.
- // Once main_menu:cancel is handled better this should
- // be unnecessary.
- if (lua_isnil(lua_getparam(1)))
- return;
bitmap = check_bitmapobject(1);
x = check_int(2);
y = check_int(3);
transparent = getbool(4);
- p->createBitmap(bitmap, x, y, transparent);
- g_engine->registerPrimitiveObject(p);
- lua_pushusertag(p, MKID('PRIM'));
+ bitmap->setX(x);
+ bitmap->setY(y);
+ // transparent: what to do ?
+ g_driver->createBitmap(bitmap);
+ g_driver->drawBitmap(bitmap);
}
void getTextObjectParams(TextObject *textObject, lua_Object table_obj) {
@@ -2387,12 +2383,6 @@
g_engine->setTextSpeed(speed);
}
-/* Make a text object, known to be used by the menu
- * please note that if the same text is issued we will
- * add an additional space (TEXT_NULL) until the text
- * becomes unique
- * (otherwise we'll get identically named menu objects)
- */
static void MakeTextObject() {
TextObject *textObject = new TextObject();
lua_Object tableObj;
@@ -2454,9 +2444,28 @@
static void BlastText() {
DEBUG_FUNCTION();
- // there is some diffrence to MakeTextObject
- // it draw directly to gfx buffer from here, not from main loop
- MakeTextObject();
+ TextObject *textObject = new TextObject();
+ lua_Object tableObj;
+ char *line;
+
+ DEBUG_FUNCTION();
+ line = lua_getstring(lua_getparam(1));
+ std::string text = line;
+ tableObj = lua_getparam(2);
+ textObject->setDefaults(&textObjectDefaults);
+
+ if (lua_istable(tableObj))
+ getTextObjectParams(textObject, tableObj);
+
+ while (TextObjectExists((char *)text.c_str()) != NULL)
+ text += TEXT_NULL;
+
+ //printf("Make: %s\n", (char *)text.c_str());
+
+ textObject->setText((char *)text.c_str());
+ textObject->createBitmap();
+ textObject->draw();
+ delete textObject;
}
static void SetOffscreenTextPos() {
@@ -2650,22 +2659,57 @@
static void BlastRect() {
DEBUG_FUNCTION();
- // BlastRect is specifically for the menu thread;
- // however, we don't need to handle the menu in a
- // separate thread so this works fine
- DrawRectangle();
+ int x1, y1, x2, y2;
+ lua_Object tableObj;
+ Color color;
+
+ DEBUG_FUNCTION();
+ x1 = check_int(1);
+ y1 = check_int(2);
+ x2 = check_int(3);
+ y2 = check_int(4);
+ tableObj = lua_getparam(5);
+ color._vals[0] = 255;
+ color._vals[1] = 255;
+ color._vals[2] = 255;
+ bool filled = false;
+
+ if (lua_istable(tableObj)){
+ lua_pushobject(tableObj);
+ lua_pushstring("color");
+ lua_Object colorObj = lua_gettable();
+ if (lua_isuserdata(colorObj) && lua_tag(colorObj) == MKID('COLR')) {
+ color = static_cast<Color *>(lua_getuserdata(colorObj));
+ }
+
+ lua_pushobject(tableObj);
+ lua_pushstring("filled");
+ lua_Object objFilled = lua_gettable();
+ if (!lua_isnil(objFilled))
+ filled = true;
+ }
+
+ PrimitiveObject *p = new PrimitiveObject();
+ p->createRectangle(x1, x2, y1, y2, color, filled);
+ p->draw();
+ delete p;
}
static void DimScreen() {
DEBUG_FUNCTION();
- if (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
- warning("DimRegion()");
+ g_driver->dimScreen();
}
static void DimRegion() {
DEBUG_FUNCTION();
- if (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
- warning("DimRegion()");
+
+ int x = check_int(1);
+ int y = check_int(2);
+ int w = check_int(3);
+ int h = check_int(4);
+ float level = luaL_check_number(5);
+
+ g_driver->dimRegion(x, y, w, h, level);
}
static void GetDiskFreeSpace() {
@@ -2750,7 +2794,12 @@
DEBUG_FUNCTION();
width = check_int(1);
height = check_int(2);
+
+ int mode = g_engine->getMode();
+ g_engine->setMode(ENGINE_MODE_NORMAL);
+ g_engine->updateDisplayScene();
Bitmap *screenshot = g_driver->getScreenshot(width, height);
+ g_engine->setMode(mode);
if (screenshot) {
lua_pushusertag(screenshot, MKID('VBUF'));
} else {
@@ -2953,7 +3002,6 @@
static void Display() {
DEBUG_FUNCTION();
if (g_engine->getFlipEnable()) {
- g_engine->drawPrimitives();
g_driver->flipBuffer();
}
}
@@ -2990,6 +3038,7 @@
if(debugLevel == DEBUG_ERROR || debugLevel == DEBUG_ALL)
error("OPCODE USAGE VERIFICATION: SetEmergencyFont");
}
+
static void LoadBundle() {
// loading grimdemo.mus is allready handled
}
More information about the Scummvm-git-logs
mailing list