diff options
author | Filippos Karapetis | 2009-10-14 15:21:53 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-10-14 15:21:53 +0000 |
commit | 1b3a5eaff610a55f7f4295e2585616619c3517f6 (patch) | |
tree | 9554e035a2075f416cf4d4702ffcec715f7e7884 | |
parent | 51975b50cb8f95d15b3d9e63b8de4b590eb90016 (diff) | |
download | scummvm-rg350-1b3a5eaff610a55f7f4295e2585616619c3517f6.tar.gz scummvm-rg350-1b3a5eaff610a55f7f4295e2585616619c3517f6.tar.bz2 scummvm-rg350-1b3a5eaff610a55f7f4295e2585616619c3517f6.zip |
Started rewriting the SEQ decoder to use the new GUI functions
svn-id: r45083
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 23 | ||||
-rw-r--r-- | engines/sci/gfx/seq_decoder.cpp | 56 | ||||
-rw-r--r-- | engines/sci/gfx/seq_decoder.h | 18 | ||||
-rw-r--r-- | engines/sci/gui/gui_palette.cpp | 2 |
4 files changed, 53 insertions, 46 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index ab4beb55b3..76aa9dc11b 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -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,27 +1040,29 @@ static reg_t kShowMovie_Windows(EngineState *s, int argc, reg_t *argv) { 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); - - if (frameNr++ == 0) - pixmap->palette->forceInto(s->gfx_state->driver->getMode()->palette); + g_system->copyRectToScreen(frame->data, frameRect.width(), frameRect.left, frameRect.top, frameRect.width(), frameRect.height()); + g_system->updateScreen(); - 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); + delete frame->data; + delete frame; // Wait before showing the next frame while (play && (g_system->getMillis() < startTime + (delay * 1000 / 60))) { diff --git a/engines/sci/gfx/seq_decoder.cpp b/engines/sci/gfx/seq_decoder.cpp index 5a1babced9..047ec4294a 100644 --- a/engines/sci/gfx/seq_decoder.cpp +++ b/engines/sci/gfx/seq_decoder.cpp @@ -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 @@ SeqDecoder::~SeqDecoder() { 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 @@ bool SeqDecoder::loadFile(Common::String fileName) { 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 @@ void SeqDecoder::closeFile() { delete _fileStream; _fileStream = 0; - - delete _palette; - _palette = 0; } #define WRITE_TO_BUFFER(n) \ @@ -155,43 +157,37 @@ bool SeqDecoder::decodeFrame(byte *rleData, int rleSize, byte *litData, int litS 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); - - assert(pixmap); - - gfx_pixmap_alloc_index_data(pixmap); + SeqFrame *frame = new SeqFrame(); + frame->frameRect = Common::Rect(frameLeft, frameTop, frameLeft + frameWidth, frameTop + frameHeight); + frame->data = new byte[frameWidth * frameHeight]; + frame->colorKey = colorKey; 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 diff --git a/engines/sci/gfx/seq_decoder.h b/engines/sci/gfx/seq_decoder.h index b9feadb5f3..af90ef1eb8 100644 --- a/engines/sci/gfx/seq_decoder.h +++ b/engines/sci/gfx/seq_decoder.h @@ -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 @@ private: int color_key); Common::SeekableReadStream *_fileStream; - Palette *_palette; int _frameCount; int _currentFrame; }; diff --git a/engines/sci/gui/gui_palette.cpp b/engines/sci/gui/gui_palette.cpp index 2e2ae650ae..5a237822e1 100644 --- a/engines/sci/gui/gui_palette.cpp +++ b/engines/sci/gui/gui_palette.cpp @@ -262,7 +262,7 @@ uint16 SciGuiPalette::matchColor(GuiPalette *pPal, byte r, byte g, byte b) { return found; } -void SciGuiPalette::getSys(GuiPalette*pal) { +void SciGuiPalette::getSys(GuiPalette *pal) { if (pal != &_sysPalette) memcpy(pal, &_sysPalette,sizeof(GuiPalette)); } |