[Scummvm-cvs-logs] SF.net SVN: scummvm:[45083] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Oct 14 17:22:03 CEST 2009


Revision: 45083
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45083&view=rev
Author:   thebluegr
Date:     2009-10-14 15:21:53 +0000 (Wed, 14 Oct 2009)

Log Message:
-----------
Started rewriting the SEQ decoder to use the new GUI functions

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kgraphics.cpp
    scummvm/trunk/engines/sci/gfx/seq_decoder.cpp
    scummvm/trunk/engines/sci/gfx/seq_decoder.h
    scummvm/trunk/engines/sci/gui/gui_palette.cpp

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-14 14:17:15 UTC (rev 45082)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-14 15:21:53 UTC (rev 45083)
@@ -40,6 +40,7 @@
 #include "sci/gfx/seq_decoder.h"
 #include "sci/gui/gui.h"
 #include "sci/gui/gui_cursor.h"
+#include "sci/gui/gui_screen.h"
 
 namespace Sci {
 
@@ -1039,28 +1040,30 @@
 static reg_t kShowMovie_DOS(EngineState *s, int argc, reg_t *argv) {
 	Common::String filename = s->_segMan->getString(argv[0]);
 	int delay = argv[1].toUint16(); // Time between frames in ticks
-	int frameNr = 0;
 	SeqDecoder seq;
+	SciGuiScreen *videoScreen = new SciGuiScreen(320, 200, 1);
 
-	if (!seq.loadFile(filename) && !seq.loadFile(Common::String("SEQ/") + filename)) {
+	if (!seq.loadFile(filename, s->resMan, videoScreen) && 
+		!seq.loadFile(Common::String("SEQ/") + filename, s->resMan, videoScreen)) {
 		warning("Failed to open movie file %s", filename.c_str());
+		delete videoScreen;
 		return s->r_acc;
 	}
 
+	delete videoScreen;
+
 	bool play = true;
 	while (play) {
 		uint32 startTime = g_system->getMillis();
+		SeqFrame *frame = seq.getFrame(play);
+		Common::Rect frameRect = frame->frameRect;
 
-		gfx_pixmap_t *pixmap = seq.getFrame(play);
+		g_system->copyRectToScreen(frame->data, frameRect.width(), frameRect.left, frameRect.top, frameRect.width(), frameRect.height());
+		g_system->updateScreen();
 
-		if (frameNr++ == 0)
-			pixmap->palette->forceInto(s->gfx_state->driver->getMode()->palette);
+		delete frame->data;
+		delete frame;
 
-		gfx_xlate_pixmap(pixmap, s->gfx_state->driver->getMode());
-		gfxop_draw_pixmap(s->gfx_state, pixmap, gfx_rect(0, 0, 320, 200), Common::Point(pixmap->xoffset, pixmap->yoffset));
-		gfxop_update_box(s->gfx_state, gfx_rect(0, 0, 320, 200));
-		gfx_free_pixmap(pixmap);
-
 		// Wait before showing the next frame
 		while (play && (g_system->getMillis() < startTime + (delay * 1000 / 60))) {
 			// FIXME: we should probably make a function that handles quitting in these kinds of situations

Modified: scummvm/trunk/engines/sci/gfx/seq_decoder.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/seq_decoder.cpp	2009-10-14 14:17:15 UTC (rev 45082)
+++ scummvm/trunk/engines/sci/gfx/seq_decoder.cpp	2009-10-14 15:21:53 UTC (rev 45083)
@@ -25,8 +25,9 @@
 
 #include "common/archive.h"
 #include "sci/gfx/seq_decoder.h"
-#include "sci/gfx/gfx_resource.h"
-#include "sci/gfx/gfx_tools.h"
+#include "sci/resource.h"
+#include "sci/gui/gui_screen.h"
+#include "sci/gui/gui_palette.h"
 
 namespace Sci {
 
@@ -34,7 +35,7 @@
 	closeFile();
 }
 
-bool SeqDecoder::loadFile(Common::String fileName) {
+bool SeqDecoder::loadFile(Common::String fileName, ResourceManager *resMan, SciGuiScreen *screen) {
 	closeFile();
 
 	_fileStream = SearchMan.createReadStreamForMember(fileName);
@@ -46,7 +47,11 @@
 
 	byte *paletteData = new byte[paletteSize];
 	_fileStream->read(paletteData, paletteSize);
-	_palette = gfxr_read_pal11(-1, paletteData, paletteSize);
+	GuiPalette seqPalette;
+	SciGuiPalette *pal = new SciGuiPalette(resMan, screen);
+	pal->createFromData(paletteData, &seqPalette);
+	pal->set(&seqPalette, 2);
+	delete pal;
 	delete[] paletteData;
 
 	_currentFrame = 0;
@@ -60,9 +65,6 @@
 
 	delete _fileStream;
 	_fileStream = 0;
-
-	delete _palette;
-	_palette = 0;
 }
 
 #define WRITE_TO_BUFFER(n) \
@@ -155,43 +157,37 @@
 	return true;
 }
 
-gfx_pixmap_t *SeqDecoder::getFrame(bool &hasNext) {
-	int frameWidth = _fileStream->readUint16LE();
-	int frameHeight = _fileStream->readUint16LE();
-	int frameLeft = _fileStream->readUint16LE();
-	int frameTop = _fileStream->readUint16LE();
-	int colorKey = _fileStream->readByte();
-	int type = _fileStream->readByte();
-	_fileStream->seek(2, SEEK_CUR);
+SeqFrame *SeqDecoder::getFrame(bool &hasNext) {
+	int16 frameWidth = _fileStream->readUint16LE();
+	int16 frameHeight = _fileStream->readUint16LE();
+	int16 frameLeft = _fileStream->readUint16LE();
+	int16 frameTop = _fileStream->readUint16LE();
+	byte colorKey = _fileStream->readByte();
+	byte type = _fileStream->readByte();
+	_fileStream->skip(2);
 	uint16 bytes = _fileStream->readUint16LE();
-	_fileStream->seek(2, SEEK_CUR);
+	_fileStream->skip(2);
 	uint16 rle_bytes = _fileStream->readUint16LE();
-	_fileStream->seek(6, SEEK_CUR);
+	_fileStream->skip(6);
 	uint32 offset = _fileStream->readUint32LE();
 
 	_fileStream->seek(offset);
-	gfx_pixmap_t *pixmap = gfx_new_pixmap(frameWidth, frameHeight, 0, 0, 0);
+	SeqFrame *frame = new SeqFrame();
+	frame->frameRect = Common::Rect(frameLeft, frameTop, frameLeft + frameWidth, frameTop + frameHeight);
+	frame->data = new byte[frameWidth * frameHeight];
+	frame->colorKey = colorKey;
 
-	assert(pixmap);
-
-	gfx_pixmap_alloc_index_data(pixmap);
-
 	if (type == 0)
-		_fileStream->read(pixmap->index_data, bytes);
+		_fileStream->read(frame->data, bytes);
 	else {
 		byte *buf = new byte[bytes];
 		_fileStream->read(buf, bytes);
-		decodeFrame(buf, rle_bytes, buf + rle_bytes, bytes - rle_bytes, pixmap->index_data, frameWidth, frameHeight, colorKey);
+		decodeFrame(buf, rle_bytes, buf + rle_bytes, bytes - rle_bytes, frame->data, frameWidth, frameHeight, colorKey);
 	}
 
-	pixmap->xoffset = frameLeft;
-	pixmap->yoffset = frameTop;
-	pixmap->color_key = colorKey;
-	pixmap->palette = _palette->getref();
-
 	hasNext = ++_currentFrame < _frameCount;
 
-	return pixmap;
+	return frame;
 }
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gfx/seq_decoder.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/seq_decoder.h	2009-10-14 14:17:15 UTC (rev 45082)
+++ scummvm/trunk/engines/sci/gfx/seq_decoder.h	2009-10-14 15:21:53 UTC (rev 45083)
@@ -24,20 +24,29 @@
  */
 
 #include "common/file.h"
-#include "sci/gfx/gfx_system.h"
+#include "common/rect.h"
 
 namespace Sci {
 
+struct SeqFrame {
+	Common::Rect frameRect;
+	byte colorKey;
+	byte *data;
+};
+
+class ResourceManager;
+class SciGuiScreen;
+
 /**
  * Decoder for image sequences
  */
 class SeqDecoder {
 public:
-	SeqDecoder() : _fileStream(0), _palette(0) { }
+	SeqDecoder() : _fileStream(0) { }
 	~SeqDecoder();
-	bool loadFile(Common::String fileName);
+	bool loadFile(Common::String fileName, ResourceManager *resMan, SciGuiScreen *screen);
 	void closeFile();
-	gfx_pixmap_t *getFrame(bool &hasNext);
+	SeqFrame *getFrame(bool &hasNext);
 
 private:
 	bool decodeFrame(byte *runlength_data, int runlength_size,
@@ -45,7 +54,6 @@
 		int color_key);
 
 	Common::SeekableReadStream *_fileStream;
-	Palette *_palette;
 	int _frameCount;
 	int _currentFrame;
 };

Modified: scummvm/trunk/engines/sci/gui/gui_palette.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_palette.cpp	2009-10-14 14:17:15 UTC (rev 45082)
+++ scummvm/trunk/engines/sci/gui/gui_palette.cpp	2009-10-14 15:21:53 UTC (rev 45083)
@@ -262,7 +262,7 @@
 	return found;
 }
 
-void SciGuiPalette::getSys(GuiPalette*pal) {
+void SciGuiPalette::getSys(GuiPalette *pal) {
 	if (pal != &_sysPalette)
 		memcpy(pal, &_sysPalette,sizeof(GuiPalette));
 }


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