[Scummvm-cvs-logs] CVS: scummvm/sword2/driver d_draw.cpp,1.55,1.56 d_draw.h,1.20,1.21 render.cpp,1.48,1.49
James Brown
ender at users.sourceforge.net
Mon Jan 12 03:11:02 CET 2004
Update of /cvsroot/scummvm/scummvm/sword2/driver
In directory sc8-pr-cvs1:/tmp/cvs-serv13821/sword2/driver
Modified Files:
d_draw.cpp d_draw.h render.cpp
Log Message:
Initial libmpeg2 cutscene support based on patch #874510.
Pre-converted cutscenes w/ palette files available - ask LeChuck about Cutscenes :)
Index: d_draw.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_draw.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- d_draw.cpp 8 Jan 2004 13:03:50 -0000 1.55
+++ d_draw.cpp 12 Jan 2004 11:10:30 -0000 1.56
@@ -141,11 +141,125 @@
*/
int32 MoviePlayer::play(char *filename, MovieTextObject *text[], uint8 *musicOut) {
- warning("semi-stub PlaySmacker %s", filename);
+#ifdef USE_MPEG2
+ int frameCounter = 0, textCounter = 0;
+ PlayingSoundHandle handle;
+ bool skipCutscene = false, textVisible = false;
+ uint32 flags = SoundMixer::FLAG_16BITS, ticks = _vm->_system->get_msecs() + 83;
- // WORKAROUND: For now, we just do the voice-over parts of the
- // movies, since they're separate from the actual smacker files.
+ uint8 oldPal[1024];
+ memcpy(oldPal, _vm->_graphics->_palCopy, 1024);
+
+ AnimationState * anim = initanimation(filename);
+ if (!anim) {
+ // Missing Files? Use the old 'Narration Only' hack
+ playDummy(filename, text, musicOut);
+ return RD_OK;
+ }
+
+ _vm->_graphics->clearScene();
+ memset(_vm->_graphics->_buffer, 0, _vm->_graphics->_screenWide * MENUDEEP);
+
+
+#ifndef SCUMM_BIG_ENDIAN
+ flags |= SoundMixer::FLAG_LITTLE_ENDIAN;
+#endif
+
+ while (1) {
+ if (!pic(anim)) break;
+ _vm->_graphics->setNeedFullRedraw();
+
+ if (text && text[textCounter]) {
+ if (frameCounter == text[textCounter]->startFrame) {
+ openTextObject(text[textCounter]);
+ textVisible = true;
+ if (text[textCounter]->speech) {
+ _vm->_mixer->playRaw(&handle, text[textCounter]->speech, text[textCounter]->speechBufferSize, 22050, flags);
+ }
+ }
+
+ if (frameCounter == text[textCounter]->endFrame) {
+ closeTextObject(text[textCounter]);
+ textCounter++;
+ textVisible = false;
+ }
+ if (textVisible)
+ drawTextObject(text[textCounter]);
+ }
+
+ frameCounter++;
+
+ _vm->_graphics->updateDisplay(true);
+
+ KeyboardEvent ke;
+
+ if ((_vm->_input->readKey(&ke) == RD_OK && ke.keycode == 27) || _vm->_quit) {
+ _vm->_mixer->stopHandle(handle);
+ skipCutscene = true;
+ break;
+ }
+
+ // Simulate ~12 frames per second. I don't know what
+ // frame rate the original movies had, or even if it
+ // was constant, but this seems to work reasonably.
+
+ while (_vm->_system->get_msecs() < ticks);
+ ticks += 82;
+
+ }
+
+ // Wait for the voice to stop playing. This is to make sure
+ // that we don't cut off the speech in mid-sentence, and - even
+ // more importantly - that we don't free the sound buffer while
+ // it's in use.
+
+ while (handle.isActive()) {
+ _vm->_graphics->updateDisplay(false);
+ _vm->_system->delay_msecs(100);
+ }
+
+ if (text)
+ closeTextObject(text[textCounter]);
+
+ _vm->_graphics->clearScene();
+ _vm->_graphics->setNeedFullRedraw();
+
+ // HACK: Remove the instructions created above
+ Common::Rect r;
+
+ memset(_vm->_graphics->_buffer, 0, _vm->_graphics->_screenWide * MENUDEEP);
+ r.left = r.top = 0;
+ r.right = _vm->_graphics->_screenWide;
+ r.bottom = MENUDEEP;
+ _vm->_graphics->updateRect(&r);
+
+ // FIXME: For now, only play the lead-out music for cutscenes
+ // that have subtitles.
+ if (!skipCutscene)
+ _vm->_sound->playLeadOut(musicOut);
+
+ _vm->_graphics->setPalette(0, 256, oldPal, RDPAL_INSTANT);
+
+ doneanimation(anim);
+
+ // Lead-in and lead-out music are, as far as I can tell, only used for
+ // the animated cut-scenes, so this seems like a good place to close
+ // both of them.
+
+ _vm->_sound->closeFx(-1);
+ _vm->_sound->closeFx(-2);
+
+ return RD_OK;
+#else
+ // No MPEG2? Use the old 'Narration Only' hack
+ playDummy(filename, text, musicOut);
+ return RD_OK;
+#endif
+}
+// This just plays the cutscene with voiceovers / subtitles, in case the files are missing
+int32 MoviePlayer::playDummy(char *filename, MovieTextObject *text[], uint8 *musicOut) {
+ int frameCounter = 0, textCounter = 0;
if (text) {
uint8 oldPal[1024];
uint8 tmpPal[1024];
@@ -159,7 +273,7 @@
memset(_vm->_graphics->_buffer, 0, _vm->_graphics->_screenWide * MENUDEEP);
- uint8 msg[] = "Cutscene - Press ESC to exit";
+ uint8 msg[] = "Cutscene - Narration Only: Press ESC to exit, or visit www.scummvm.org to download cutscene videos";
Memory *data = _vm->_fontRenderer->makeTextSprite(msg, 640, 255, _vm->_speechFontId);
FrameHeader *frame = (FrameHeader *) data->ad;
SpriteInfo msgSprite;
@@ -180,8 +294,7 @@
// In case the cutscene has a long lead-in, start just before
// the first line of text.
- int frameCounter = text[0]->startFrame - 12;
- int textCounter = 0;
+ frameCounter = text[0]->startFrame - 12;
// Fake a palette that will hopefully make the text visible.
// In the opening cutscene it seems to use colours 1 (black?)
@@ -197,7 +310,7 @@
tmpPal[255 * 4 + 2] = 255;
_vm->_graphics->setPalette(0, 256, tmpPal, RDPAL_INSTANT);
- PlayingSoundHandle handle;
+PlayingSoundHandle handle;
bool skipCutscene = false;
@@ -219,7 +332,6 @@
_vm->_mixer->playRaw(&handle, text[textCounter]->speech, text[textCounter]->speechBufferSize, 22050, flags);
}
}
-
if (frameCounter == text[textCounter]->endFrame) {
closeTextObject(text[textCounter]);
_vm->_graphics->clearScene();
Index: d_draw.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_draw.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- d_draw.h 9 Jan 2004 07:53:08 -0000 1.20
+++ d_draw.h 12 Jan 2004 11:10:30 -0000 1.21
@@ -22,6 +22,8 @@
#include "common/rect.h"
+#include "animation.h"
+
namespace Sword2 {
// This is the maximum mouse cursor size in the SDL backend
@@ -72,9 +74,17 @@
void closeTextObject(MovieTextObject *obj);
void drawTextObject(MovieTextObject *obj);
+ void buildlookup(AnimationState * st, int p, int lines);
+ void checkPaletteSwitch(AnimationState * st);
+
+ AnimationState * initanimation(char *name);
+ void doneanimation(AnimationState * st);
+ bool pic(AnimationState * st);
+
public:
MoviePlayer(Sword2Engine *vm) : _vm(vm), _textSurface(NULL) {}
int32 play(char *filename, MovieTextObject *text[], uint8 *musicOut);
+ int32 playDummy(char *filename, MovieTextObject *text[], uint8 *musicOut);
};
struct BlockSurface {
@@ -185,6 +195,7 @@
void unwindRaw16(uint8 *dest, uint8 *source, uint8 blockSize, uint8 *colTable);
int32 decompressRLE16(uint8 *dest, uint8 *source, int32 decompSize, uint8 *colTable);
+
public:
Graphics(Sword2Engine *vm, int16 width, int16 height);
~Graphics();
@@ -238,6 +249,7 @@
void plotPoint(uint16 x, uint16 y, uint8 colour);
void drawLine(int16 x1, int16 y1, int16 x2, int16 y2, uint8 colour);
+ void plotYUV(unsigned char * lut, int width, int height, uint8_t * const * buf);
int32 createSurface(SpriteInfo *s, uint8 **surface);
void drawSurface(SpriteInfo *s, uint8 *surface, Common::Rect *clipRect = NULL);
Index: render.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/render.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- render.cpp 9 Jan 2004 07:53:08 -0000 1.48
+++ render.cpp 12 Jan 2004 11:10:30 -0000 1.49
@@ -820,4 +820,31 @@
_layer = 0;
}
+
+void Graphics::plotYUV(unsigned char * lut, int width, int height, uint8_t * const * dat)
+{
+ uint8 *buf = _buffer + (40+(400-height)/2) * RENDERWIDE + (640-width)/2;
+
+ int x, y;
+
+ int ypos = 0;
+ int cpos = 0;
+ int linepos = 0;
+
+ for (y = 0; y < height; y+=2) {
+ for (x = 0; x < width; x+=2) {
+ int i = ((((dat[2][cpos]+ROUNDADD)>>SHIFT) * BITDEPTH) + ((dat[1][cpos]+ROUNDADD)>>SHIFT)) * BITDEPTH;
+ cpos++;
+
+ buf[linepos ] = lut[i+((dat[0][ ypos ]+ROUNDADD)>>SHIFT)];
+ buf[RENDERWIDE + linepos++] = lut[i+((dat[0][width+ypos++]+ROUNDADD)>>SHIFT)];
+ buf[linepos ] = lut[i+((dat[0][ ypos ]+ROUNDADD)>>SHIFT)];
+ buf[RENDERWIDE + linepos++] = lut[i+((dat[0][width+ypos++]+ROUNDADD)>>SHIFT)];
+ }
+ linepos += (2*RENDERWIDE-width);
+ ypos += width;
+ }
+}
+
+
} // End of namespace Sword2
More information about the Scummvm-git-logs
mailing list