[Scummvm-cvs-logs] CVS: residual bitmap.cpp,1.13,1.14 driver_gl.cpp,1.2,1.3 driver_gl.h,1.2,1.3 lua.cpp,1.36,1.37 main.cpp,1.18,1.19 smush.cpp,1.22,1.23 smush.h,1.7,1.8
Pawel Kolodziejski
aquadran at users.sourceforge.net
Sat Feb 21 14:13:01 CET 2004
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21882
Modified Files:
bitmap.cpp driver_gl.cpp driver_gl.h lua.cpp main.cpp
smush.cpp smush.h
Log Message:
more smush stuff, sound disabled for now
Index: bitmap.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/bitmap.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- bitmap.cpp 21 Feb 2004 15:36:31 -0000 1.13
+++ bitmap.cpp 21 Feb 2004 22:00:12 -0000 1.14
@@ -20,6 +20,7 @@
#include <cstring>
#include "bitmap.h"
#include "bits.h"
+#include "smush.h"
#include "debug.h"
#include "driver_gl.h"
@@ -147,6 +148,14 @@
cur_tex_idx++;
}
}
+
+ if (g_smush->isPlaying()) {
+ if (g_smush->isUpdateNeeded()) {
+ g_driver->drawSMUSHframe(g_smush->getX(), g_smush->getY(), g_smush->getWidth(), g_smush->getHeight(), g_smush->getDstPtr());
+ g_smush->setUpdateNeeded();
+ }
+ }
+
glDisable(GL_SCISSOR_TEST);
glDisable(GL_TEXTURE_2D);
glDepthMask(GL_TRUE);
@@ -154,7 +163,7 @@
} else if (format_ == 5) { // ZBuffer image
// Only draw the manual zbuffer when we are not using screenblocks, and when enabled
if ((ZBUFFER_GLOBAL == 0) || (SCREENBLOCKS_GLOBAL == 1))
- return;
+ return;
g_driver->drawDepthBitmap(curr_image_, x_, y_, width_, height_, data_);
}
Index: driver_gl.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_gl.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- driver_gl.cpp 28 Jan 2004 06:16:33 -0000 1.2
+++ driver_gl.cpp 21 Feb 2004 22:00:13 -0000 1.3
@@ -148,7 +148,7 @@
}
// drawSMUSHframe, used for quickly pushing full-screen images from cutscenes
-void Driver::drawSMUSHframe(int _width, int _height, uint8 *_dst) {
+void Driver::drawSMUSHframe(int offsetX, int offsetY, int _width, int _height, uint8 *_dst) {
int num_tex_;
GLuint *tex_ids_;
@@ -194,23 +194,25 @@
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// prepare view
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, 640, 480, 0, 0, 1);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
+// glMatrixMode(GL_PROJECTION);
+ // glLoadIdentity();
+ // glOrtho(0, 640, 480, 0, 0, 1);
+ // glMatrixMode(GL_MODELVIEW);
+ // glLoadIdentity();
+ // glMatrixMode(GL_TEXTURE);
+ // glLoadIdentity();
// A lot more may need to be put there : disabling Alpha test, blending, ...
// For now, just keep this here :-)
- glDisable(GL_LIGHTING);
- glEnable(GL_TEXTURE_2D);
+// glDisable(GL_LIGHTING);
+ // glEnable(GL_TEXTURE_2D);
// draw
- glDisable(GL_DEPTH_TEST);
- glDepthMask(GL_FALSE);
- glEnable(GL_SCISSOR_TEST);
+// glDisable(GL_DEPTH_TEST);
+// glDepthMask(GL_FALSE);
+// glEnable(GL_SCISSOR_TEST);
+
+ offsetY = 480 - offsetY - _height;
cur_tex_idx = 0;
for (int y = 0; y < _height; y += BITMAP_TEXTURE_SIZE) {
for (int x = 0; x < _width; x += BITMAP_TEXTURE_SIZE) {
@@ -219,7 +221,7 @@
glBindTexture(GL_TEXTURE_2D, tex_ids_[cur_tex_idx]);
glScissor(x, 480 - (y + height), x + width, 480 - y);
glBegin(GL_QUADS);
- glTexCoord2f(0.0, 0.0);
+ glTexCoord2f(0, 0);
glVertex2i(x, y);
glTexCoord2f(1.0, 0.0);
@@ -232,11 +234,11 @@
cur_tex_idx++;
}
}
- glDisable(GL_SCISSOR_TEST);
- glDisable(GL_TEXTURE_2D);
- glDepthMask(GL_TRUE);
- glEnable(GL_DEPTH_TEST);
- SDL_GL_SwapBuffers();
+// glDisable(GL_SCISSOR_TEST);
+ // glDisable(GL_TEXTURE_2D);
+ // glDepthMask(GL_TRUE);
+ // glEnable(GL_DEPTH_TEST);
+ // SDL_GL_SwapBuffers();
// remove
glDeleteTextures(num_tex_, tex_ids_);
Index: driver_gl.h
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_gl.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- driver_gl.h 29 Jan 2004 13:03:07 -0000 1.2
+++ driver_gl.h 21 Feb 2004 22:00:13 -0000 1.3
@@ -26,7 +26,7 @@
void drawBitmap();
void drawHackFont(int x, int y, const char *text, Color &fgColor);
- void drawSMUSHframe(int _width, int _height, uint8 *_dst);
+ void drawSMUSHframe(int offsetX, int offsetY, int _width, int _height, uint8 *_dst);
private:
GLuint hackFont; // FIXME: Temporary font drawing hack
Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- lua.cpp 18 Dec 2003 22:54:01 -0000 1.36
+++ lua.cpp 21 Feb 2004 22:00:13 -0000 1.37
@@ -1017,16 +1017,48 @@
lua_pushnumber(100); // Dummy Y
}
+static void StartFullscreenMovie() {
+ bool mode = lua_getparam(2) != 0;
+ if (g_smush->play(lua_getstring(lua_getparam(1)), 0, 0)) {
+ lua_pushnumber(1);
+ } else {
+ lua_pushnil();
+ }
+}
+
static void StartMovie() {
- Smush player;
- char *filename = lua_getstring(lua_getparam(1));
- player.play(filename, "");
+ bool mode = lua_getparam(2) != 0;
+ int x = lua_getparam(3);
+ int y = lua_getparam(4);
+ if (g_smush->play(lua_getstring(lua_getparam(1)), x, y)) {
+ lua_pushnumber(1);
+ } else {
+ lua_pushnil();
+ }
}
-static void StartFullscreenMovie() {
- Smush player;
- char *filename = lua_getstring(lua_getparam(1));
- player.play(filename, "");
+static void IsFullscreenMoviePlaying() {
+ if (g_smush->isPlaying()) {
+ lua_pushnumber(1);
+ } else {
+ lua_pushnil();
+ }
+}
+
+static void IsMoviePlaying() {
+ if (g_smush->isPlaying()) {
+ lua_pushnumber(1);
+ } else {
+ lua_pushnil();
+ }
+}
+
+static void StopMovie() {
+ g_smush->stop();
+}
+
+static void PauseMovie() {
+ g_smush->pause(lua_isnil(lua_getparam(1)));
}
// Stub function for builtin functions not yet implemented
@@ -1169,10 +1201,6 @@
"SetSoundPosition",
"IsSoundPlaying",
"PlaySoundAt",
- "IsMoviePlaying",
- "PauseMovie",
- "StopMovie",
- "IsFullscreenMoviePlaying",
"PreviousSetup",
"NextSetup",
"UnLockSet",
@@ -1462,7 +1490,11 @@
{ "GetActorLookRate", GetActorLookRate },
{ "SetActorHead", SetActorHead },
{ "StartMovie", StartMovie },
+ { "StopMovie", StopMovie },
+ { "PauseMovie", PauseMovie },
+ { "IsMoviePlaying", IsMoviePlaying },
{ "StartFullscreenMovie", StartFullscreenMovie },
+ { "IsFullscreenMoviePlaying", IsFullscreenMoviePlaying },
};
void register_lua() {
Index: main.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/main.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- main.cpp 23 Jan 2004 11:10:46 -0000 1.18
+++ main.cpp 21 Feb 2004 22:00:13 -0000 1.19
@@ -26,6 +26,7 @@
#include "engine.h"
#include "sound.h"
#include "timer.h"
+#include "smush.h"
#include "mixer/mixer.h"
#include "driver_gl.h"
@@ -78,6 +79,12 @@
atexit(SDL_Quit);
atexit(saveRegistry);
+ g_mixer = new SoundMixer();
+ g_timer = new Timer();
+ g_smush = new Smush();
+
+ Mixer::instance()->start();
+
Bitmap *splash_bm = ResourceLoader::instance()->loadBitmap("splash.bm");
SDL_Event event;
@@ -92,10 +99,6 @@
}
}
- g_mixer = new SoundMixer();
- g_timer = new Timer();
- Mixer::instance()->start();
-
lua_open();
lua_beginblock();
@@ -120,6 +123,7 @@
Engine::instance()->mainLoop();
+ delete g_smush;
delete g_timer;
delete g_mixer;
Index: smush.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/smush.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- smush.cpp 21 Feb 2004 18:08:41 -0000 1.22
+++ smush.cpp 21 Feb 2004 22:00:13 -0000 1.23
@@ -26,15 +26,14 @@
#include "driver_gl.h"
#include "resource.h"
-
-Smush *smush;
+Smush *g_smush;
void Smush::timerCallback(void *refCon) {
- smush->handleFrame();
+ g_smush->handleFrame();
}
Smush::Smush() {
- smush = this;
+ g_smush = this;
_nbframes = 0;
_dst = NULL;
_width = 0;
@@ -42,6 +41,8 @@
_speed = 0;
_channels = -1;
_freq = 22050;
+ _videoFinished = false;
+ _videoPause = true;
}
Smush::~Smush() {
@@ -50,20 +51,19 @@
void Smush::init() {
_frame = 0;
- _alreadyInit = false;
_videoFinished = false;
+ _videoPause = false;
g_timer->installTimerProc(&timerCallback, _speed, NULL);
}
void Smush::deinit() {
+ _videoFinished = true;
+ _videoPause = true;
g_timer->removeTimerProc(&timerCallback);
+ _file.close();
}
void Smush::handleBlocky16(byte *src) {
- if (!_alreadyInit) {
- _blocky16.init(_width, _height);
- _alreadyInit = true;
- }
_blocky16.decode(_dst, src);
}
@@ -94,6 +94,14 @@
int32 size;
int pos = 0;
+ if (_videoPause)
+ return;
+
+ if (_videoFinished) {
+ _videoPause = true;
+ return;
+ }
+
tag = _file.readUint32BE();
if (tag == MKID_BE('ANNO')) {
size = _file.readUint32BE();
@@ -109,7 +117,7 @@
handleBlocky16(frame + pos + 8);
pos += READ_BE_UINT32(frame + pos + 4) + 8;
} else if (READ_BE_UINT32(frame + pos) == MKID_BE('Wave')) {
- handleWave(frame + pos + 8 + 4, READ_BE_UINT32(frame + pos + 8));
+// handleWave(frame + pos + 8 + 4, READ_BE_UINT32(frame + pos + 8));
pos += READ_BE_UINT32(frame + pos + 4) + 8;
} else {
error("unknown tag");
@@ -151,7 +159,7 @@
free(f_header);
}
-bool Smush::setupAnim(const char *file, const char *directory) {
+bool Smush::setupAnim(const char *file, int x, int y) {
if (!_file.open(file))
return false;
@@ -167,27 +175,33 @@
byte *s_header = (byte *)malloc(size);
_file.read(s_header, size);
_nbframes = READ_LE_UINT32(s_header + 2);
- _width = READ_LE_UINT16(s_header + 8);
- _height = READ_LE_UINT16(s_header + 10);
+ _x = x;
+ _y = y;
+ int width = READ_LE_UINT16(s_header + 8);
+ int height = READ_LE_UINT16(s_header + 10);
- if ((_width != 640) || (_height != 480)) {
- warning("resolution of smush frame other than 640x480 not supported");
- return false;
+ if ((_width != width) || (_height != height)) {
+ _blocky16.init(width, height);
}
+ _width = width;
+ _height = height;
+
_speed = READ_LE_UINT32(s_header + 14);
free(s_header);
return true;
}
-void Smush::play(const char *filename, const char *directory) {
+bool Smush::play(const char *filename, int x, int y) {
+ stop();
+
// Tempfile version of decompression code
#ifdef ZLIB_MEMORY
// zlibFile version of code. Experimental.
// Load the video
- if (!setupAnim(filename, directory))
- return;
+ if (!setupAnim(filename, x, y))
+ return false;
#else
char tmpOut[256];
FILE *tmp = ResourceLoader::instance()->openNewStream(filename);
@@ -249,7 +263,7 @@
if (status != Z_OK) {
warning("Smush::play() - Error inflating stream (%d) [-3 means bad data]", status);
- return;
+ return false;
}
if (z.avail_out == 0) {
@@ -265,11 +279,13 @@
inflateEnd(&z);
fclose(outFile);
warning("Smush::play() Open okay for %s!\n", filename);
+ } else {
+ return false;
}
// Load the video
- if (!setupAnim(tmpOut, directory))
- return;
+ if (!setupAnim(tmpOut, x, y))
+ return false;
#endif
handleFramesHeader();
@@ -292,25 +308,49 @@
init();
- while (!_videoFinished) {
-
- if (_updateNeeded) {
- g_driver->drawSMUSHframe(_width, _height, _buf);
- _updateNeeded = false;
- }
+ return true;
+}
- SDL_Event event;
- if (SDL_PollEvent(&event)) {
- // Skip cutscene?
- if (event.type == SDL_KEYDOWN)
- if (event.key.keysym.sym == SDLK_ESCAPE)
- _videoFinished = true;
- }
- SDL_Delay(10);
- };
+void Smush::stop() {
deinit();
}
+void Smush::pause(bool pause) {
+ _videoPause = pause;
+}
+
+bool Smush::isPlaying() {
+ return !_videoPause;
+}
+
+bool Smush::isUpdateNeeded() {
+ return _updateNeeded;
+}
+
+int Smush::getX() {
+ return _x;
+}
+
+int Smush::getY() {
+ return _y;
+}
+
+int Smush::getWidth() {
+ return _width;
+}
+
+int Smush::getHeight() {
+ return _height;
+}
+
+byte *Smush::getDstPtr() {
+ return _buf;
+}
+
+void Smush::setUpdateNeeded() {
+ _updateNeeded = true;
+}
+
FILE *File::fopenNoCase(const char *filename, const char *directory, const char *mode) {
FILE *file;
char buf[512];
Index: smush.h
===================================================================
RCS file: /cvsroot/scummvm/residual/smush.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- smush.h 21 Feb 2004 17:48:45 -0000 1.7
+++ smush.h 21 Feb 2004 22:00:13 -0000 1.8
@@ -106,11 +106,12 @@
int32 _frame;
bool _updateNeeded;
- bool _alreadyInit;
int32 _speed;
int _channels;
int _freq;
bool _videoFinished;
+ bool _videoPause;
+ int _x, _y;
int _width, _height;
byte *_dst;
byte *_buf;
@@ -119,7 +120,17 @@
Smush();
~Smush();
- void play(const char *filename, const char *directory);
+ bool play(const char *filename, int x, int y);
+ void stop();
+ void pause(bool pause);
+ bool isPlaying();
+ bool isUpdateNeeded();
+ byte *getDstPtr();
+ int getX();
+ int getY();
+ int getWidth();
+ int getHeight();
+ void setUpdateNeeded();
private:
static void timerCallback(void *ptr);
@@ -130,8 +141,10 @@
void handleWave(const byte *src, uint32 size);
void init();
void deinit();
- bool setupAnim(const char *file, const char *directory);
+ bool setupAnim(const char *file, int x, int y);
void updateGLScreen();
};
+extern Smush *g_smush;
+
#endif
More information about the Scummvm-git-logs
mailing list