aboutsummaryrefslogtreecommitdiff
path: root/engines/prince
diff options
context:
space:
mode:
authorKamil Zbróg2013-10-21 01:18:27 +0100
committerKamil Zbróg2013-10-21 01:18:27 +0100
commit263b02eb6156dcbc9e8f6bf3a5301c855cce3af9 (patch)
tree22a92fc3f733b55af74767afed5c0138f69d8ade /engines/prince
parent1f0e976ea69e1e28aeb146047181eb814c0f2aef (diff)
downloadscummvm-rg350-263b02eb6156dcbc9e8f6bf3a5301c855cce3af9.tar.gz
scummvm-rg350-263b02eb6156dcbc9e8f6bf3a5301c855cce3af9.tar.bz2
scummvm-rg350-263b02eb6156dcbc9e8f6bf3a5301c855cce3af9.zip
PRINCE: flic anim decoder works with room 59 (intro)
Diffstat (limited to 'engines/prince')
-rw-r--r--engines/prince/graphics.cpp25
-rw-r--r--engines/prince/graphics.h5
-rw-r--r--engines/prince/prince.cpp117
-rw-r--r--engines/prince/prince.h12
-rw-r--r--engines/prince/script.cpp31
-rw-r--r--engines/prince/script.h149
6 files changed, 131 insertions, 208 deletions
diff --git a/engines/prince/graphics.cpp b/engines/prince/graphics.cpp
index 356b35f832..2b6366b00b 100644
--- a/engines/prince/graphics.cpp
+++ b/engines/prince/graphics.cpp
@@ -9,11 +9,13 @@ namespace Prince {
GraphicsMan::GraphicsMan(PrinceEngine *vm)
: _vm(vm), _changed(false) {
initGraphics(640, 480, true);
+ _frontScreen = new Graphics::Surface();
+ _frontScreen->create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
}
void GraphicsMan::update() {
if (_changed) {
- _vm->_system->copyRectToScreen((byte*)_roomBackground->getBasePtr(0,0), 640, 0, 0, 640, 480);
+ _vm->_system->copyRectToScreen((byte*)_frontScreen->getBasePtr(0,0), 640, 0, 0, 640, 480);
_vm->_system->updateScreen();
}
@@ -27,4 +29,25 @@ void GraphicsMan::change() {
_changed = true;
}
+void GraphicsMan::draw(const Graphics::Surface *s)
+{
+ for (uint y = 0; y < 480; y++)
+ memcpy((byte*)_frontScreen->getBasePtr(0, y), (byte*)s->getBasePtr(0, y), 640);
+}
+
+void GraphicsMan::drawTransparent(const Graphics::Surface *s)
+{
+ for (uint y = 0; y < 480; ++y)
+ {
+ for (uint x = 0; x < 640; ++x)
+ {
+ byte pixel = *((byte*)s->getBasePtr(x,y));
+ if (pixel != 255)
+ {
+ *((byte*)_frontScreen->getBasePtr(x, y)) = pixel;
+ }
+ }
+ }
+}
+
}
diff --git a/engines/prince/graphics.h b/engines/prince/graphics.h
index 3599cbc346..0f12c734c6 100644
--- a/engines/prince/graphics.h
+++ b/engines/prince/graphics.h
@@ -41,6 +41,10 @@ public:
void setPalette(const byte *palette);
+ void draw(const Graphics::Surface *s);
+ void drawTransparent(const Graphics::Surface *s);
+
+ Graphics::Surface *_frontScreen;
Graphics::Surface *_backScreen;
const Graphics::Surface *_roomBackground;
@@ -50,7 +54,6 @@ private:
bool _changed;
byte _palette[3 * 256];
- Graphics::Surface *_frontScreen;
};
}
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index c82dfd6723..72d5e55fe8 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -36,7 +36,6 @@
#include "graphics/surface.h"
#include "graphics/palette.h"
#include "graphics/pixelformat.h"
-#include "graphics/decoders/bmp.h"
#include "engines/util.h"
#include "engines/advancedDetector.h"
@@ -49,18 +48,20 @@
#include "prince/graphics.h"
#include "prince/script.h"
+#include "video/flic_decoder.h"
+
namespace Prince {
PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc) :
Engine(syst), _gameDescription(gameDesc), _graph(NULL), _script(NULL) {
- _rnd = new Common::RandomSource("prince");
+ _rnd = new Common::RandomSource("prince");
}
PrinceEngine::~PrinceEngine() {
- DebugMan.clearAllDebugChannels();
+ DebugMan.clearAllDebugChannels();
- delete _rnd;
+ delete _rnd;
}
Common::Error PrinceEngine::run() {
@@ -71,8 +72,8 @@ Common::Error PrinceEngine::run() {
debug("Adding all path: %s", gameDataDir.getPath().c_str());
- SearchMan.addSubDirectoryMatching(gameDataDir, "all", 0, 2);
- SearchMan.addSubDirectoryMatching(gameDataDir, "01", 0, 2);
+ SearchMan.addSubDirectoryMatching(gameDataDir, "all", 0, 2);
+ SearchMan.addSubDirectoryMatching(gameDataDir, "59", 0, 2);
Common::SeekableReadStream * walizka = SearchMan.createReadStreamForMember("walizka");
@@ -80,27 +81,24 @@ Common::Error PrinceEngine::run() {
if (!font1stream)
return Common::kPathNotFile;
- Font font1 = Font();
- if (font1.load(*font1stream)) {
- font1.getCharWidth(103);
+ if (_font.load(*font1stream)) {
+ _font.getCharWidth(103);
}
delete font1stream;
Common::SeekableReadStream *room = SearchMan.createReadStreamForMember("room");
- //_frontScreen = new Graphics::Surface();
- //_frontScreen->create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
+ //_frontScreen = new Graphics::Surface();
+ //_frontScreen->create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
if (room) {
- Graphics::BitmapDecoder roomBmp;
- roomBmp.loadStream(*room);
+ _roomBmp.loadStream(*room);
//_roomBackground = roomBmp.getSurface();
- _system->getPaletteManager()->setPalette(roomBmp.getPalette(), 0, 256);
+ _system->getPaletteManager()->setPalette(_roomBmp.getPalette(), 0, 256);
//font1.drawString(_frontScreen, "Hello World", 10, 10, 640, 1);
//
- _graph->_roomBackground = roomBmp.getSurface();
-#if 1
+#if 0
MhwanhDecoder *walizkaBmp = new MhwanhDecoder();
if (walizka) {
debug("Loading walizka");
@@ -123,46 +121,77 @@ Common::Error PrinceEngine::run() {
mainLoop();
delete room;
- delete walizkaBmp;
+ //delete walizkaBmp;
}
- return Common::kNoError;
+ return Common::kNoError;
+}
+
+bool PrinceEngine::PlayNextFrame()
+{
+ _graph->draw(_roomBmp.getSurface());
+
+ const Graphics::Surface *s = _flicPlayer.decodeNextFrame();
+ if (s)
+ {
+ _graph->drawTransparent(s);
+ _graph->change();
+ }
+
+ return true;
}
void PrinceEngine::mainLoop() {
- //uint32 nextFrameTime = 0;
- while (!shouldQuit()) {
- Common::Event event;
- Common::EventManager *eventMan = _system->getEventManager();
- while (eventMan->pollEvent(event)) {
- switch (event.type) {
- case Common::EVENT_KEYDOWN:
- break;
- case Common::EVENT_KEYUP:
- break;
- case Common::EVENT_MOUSEMOVE:
- break;
- case Common::EVENT_LBUTTONDOWN:
- case Common::EVENT_RBUTTONDOWN:
- break;
- case Common::EVENT_LBUTTONUP:
- case Common::EVENT_RBUTTONUP:
- break;
- case Common::EVENT_QUIT:
- break;
- default:
- break;
- }
- }
+ //uint32 nextFrameTime = 0;
+ uint32 an = 1;
+
+ while (!shouldQuit()) {
+ Common::Event event;
+ Common::EventManager *eventMan = _system->getEventManager();
+ while (eventMan->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ break;
+ case Common::EVENT_KEYUP:
+ break;
+ case Common::EVENT_MOUSEMOVE:
+ break;
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_RBUTTONDOWN:
+ break;
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONUP:
+ break;
+ case Common::EVENT_QUIT:
+ break;
+ default:
+ break;
+ }
+ }
if (shouldQuit())
return;
- _script->step();
+ //_script->step();
+ if (_flicPlayer.endOfVideo())
+ {
+ Common::String streamName = Common::String::format("AN%02d", an++);
+ Common::SeekableReadStream * flicStream = SearchMan.createReadStreamForMember(streamName);
+
+ if (flicStream)
+ {
+ if (_flicPlayer.loadStream(flicStream))
+ {
+ debug("%s loaded", streamName.c_str());
+ _flicPlayer.start();
+ }
+ }
+ }
+ PlayNextFrame();
_graph->update();
- _system->delayMillis(40);
+ _system->delayMillis(40);
}
}
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index 966cee982e..58a4466825 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -30,11 +30,17 @@
#include "common/textconsole.h"
#include "common/rect.h"
+#include "graphics/decoders/bmp.h"
+
#include "engines/engine.h"
#include "engines/util.h"
#include "audio/mixer.h"
+#include "video/flic_decoder.h"
+
+#include "prince/font.h"
+
namespace Prince {
struct PrinceGameDescription;
@@ -61,9 +67,15 @@ public:
const PrinceGameDescription *_gameDescription;
private:
+ bool PlayNextFrame();
+
Common::RandomSource *_rnd;
+ Video::FlicDecoder _flicPlayer;
+ Graphics::BitmapDecoder _roomBmp;
+
GraphicsMan *_graph;
Script *_script;
+ Font _font;
void mainLoop();
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp
index d59b373a2b..c2f1706ee5 100644
--- a/engines/prince/script.cpp
+++ b/engines/prince/script.cpp
@@ -9,7 +9,7 @@ namespace Prince {
static const uint16 NUM_OPCODES = 144;
Script::Script(PrinceEngine *vm) :
- _code(NULL), _stacktop(0), _vm(vm), _random("GroovieScripts") {
+ _code(NULL), _stacktop(0), _vm(vm), _random("GroovieScripts"), _opcodeNF(false) {
}
Script::~Script() {
@@ -44,24 +44,27 @@ void Script::debugScript(const char *s, ...) {
}
void Script::step() {
- _lastInstruction = _currentInstruction;
- // Prepare the base debug string
- Common::String dstr = Common::String::format("@0x%04X: ", _currentInstruction);
+ while (!_opcodeNF)
+ {
+ _lastInstruction = _currentInstruction;
+ // Prepare the base debug string
+ Common::String dstr = Common::String::format("@0x%04X: ", _currentInstruction);
- // Get the current opcode
- _lastOpcode = readScript16bits();
+ // Get the current opcode
+ _lastOpcode = readScript16bits();
- dstr += Common::String::format("op %02d: ", _lastOpcode);
+ dstr += Common::String::format("op %02d: ", _lastOpcode);
- if (_lastOpcode > NUM_OPCODES)
- error("Trying to execute unknown opcode %s", dstr.c_str());
+ if (_lastOpcode > NUM_OPCODES)
+ error("Trying to execute unknown opcode %s", dstr.c_str());
- debug("%s", dstr.c_str());
+ debug("%s", dstr.c_str());
- // Execute the current opcode
- OpcodeFunc op = _opcodes[_lastOpcode];
- (this->*op)();
+ // Execute the current opcode
+ OpcodeFunc op = _opcodes[_lastOpcode];
+ (this->*op)();
+ }
}
uint8 Script::getCodeByte(uint32 address) {
@@ -110,7 +113,7 @@ void Script::O_SETSAMPLE() {
uint16 sampleId = readScript16bits();
int32 sampleNameOffset = readScript32bits();
const char * sampleName = (const char *)_code + _currentInstruction + sampleNameOffset - 4;
- debugScript("O_SETSAMPLE %d %s", sampleName, sampleName);
+ debugScript("O_SETSAMPLE %d %s", sampleId, sampleName);
}
void Script::O_FREESAMPLE() {
diff --git a/engines/prince/script.h b/engines/prince/script.h
index 08488d3877..a68e834c68 100644
--- a/engines/prince/script.h
+++ b/engines/prince/script.h
@@ -55,6 +55,7 @@ private:
uint32 _lastInstruction;
byte _result;
int16 _flags[2000];
+ bool _opcodeNF;
// Stack
uint16 _stack[500];
@@ -217,154 +218,6 @@ private:
void O_INPUTLINE();
void O_SETVOICED();
void O_BREAK_POINT();
-
-
-#if 0
- O_WAITFOREVER ;00
- O_BLACKPALETTE ;01
- O_SETUPPALETTE ;02
- O_INITROOM ;03
- O_SETSAMPLE ;04
- O_FREESAMPLE ;05
- O_PLAYSAMPLE ;06
- O_PUTOBJECT ;07
- O_REMOBJECT ;08
- O_SHOWANIM ;09
- O_CHECKANIMEND ;10
- O_FREEANIM ;11
- O_CHECKANIMFRAME ;12
- O_PUTBACKANIM ;13
- O_REMBACKANIM ;14
- O_CHECKBACKANIMFRAME ;15
- O_FREEALLSAMPLES ;16
- O_SETMUSIC ;17
- O_STOPMUSIC ;18
- O__WAIT ;19
- O_UPDATEOFF ;20
- O_UPDATEON ;21
- O_UPDATE ;22
- O_CLS ;23
- O__CALL ;24
- O_RETURN ;25
- O_GO ;26
- O_BACKANIMUPDATEOFF ;27
- O_BACKANIMUPDATEON ;28
- O_CHANGECURSOR ;29
- O_CHANGEANIMTYPE ;30
- O__SETFLAG ;31
- O_COMPARE ;32
- O_JUMPZ ;33
- O_JUMPNZ ;34
- O_EXIT ;35
- O_ADDFLAG ;36
- O_TALKANIM ;37
- O_SUBFLAG ;38
- O_SETSTRING ;39
- O_ANDFLAG ;40
- O_GETMOBDATA ;41
- O_ORFLAG ;42
- O_SETMOBDATA ;43
- O_XORFLAG ;44
- O_GETMOBTEXT ;45
- O_MOVEHERO ;46
- O_WALKHERO ;47
- O_SETHERO ;48
- O_HEROOFF ;49
- O_HEROON ;50
- O_CLSTEXT ;51
- O_CALLTABLE ;52
- O_CHANGEMOB ;53
- O_ADDINV ;54
- O_REMINV ;55
- O_REPINV ;56
- O_OBSOLETE_GETACTION ;57
- O_ADDWALKAREA ;58
- O_REMWALKAREA ;59
- O_RESTOREWALKAREA ;60
- O_WAITFRAME ;61
- O_SETFRAME ;62
- O_RUNACTION ;63
- O_COMPAREHI ;64
- O_COMPARELO ;65
- O_PRELOADSET ;66
- O_FREEPRELOAD ;67
- O_CHECKINV ;68
- O_TALKHERO ;69
- O_WAITTEXT ;70
- O_SETHEROANIM ;71
- O_WAITHEROANIM ;72
- O_GETHERODATA ;73
- O_GETMOUSEBUTTON ;74
- O_CHANGEFRAMES ;75
- O_CHANGEBACKFRAMES ;76
- O_GETBACKANIMDATA ;77
- O_GETANIMDATA ;78
- O_SETBGCODE ;79
- O_SETBACKFRAME ;80
- O_GETRND ;81
- O_TALKBACKANIM ;82
- O_LOADPATH ;83
- O_GETCHAR ;84
- O_SETDFLAG ;85
- O_CALLDFLAG ;86
- O_PRINTAT ;87
- O_ZOOMIN ;88
- O_ZOOMOUT ;89
- O_SETSTRINGOFFSET ;90
- O_GETOBJDATA ;91
- O_SETOBJDATA ;92
- O_SWAPOBJECTS ;93
- O_CHANGEHEROSET ;94
- O_ADDSTRING ;95
- O_SUBSTRING ;96
- O_INITDIALOG ;97
- O_ENABLEDIALOGOPT ;98
- O_DISABLEDIALOGOPT ;99
- O_SHOWDIALOGBOX ;100
- O_STOPSAMPLE ;101
- O_BACKANIMRANGE ;102
- O_CLEARPATH ;103
- O_SETPATH ;104
- O_GETHEROX ;105
- O_GETHEROY ;106
- O_GETHEROD ;107
- O_PUSHSTRING ;108
- O_POPSTRING ;109
- O_SETFGCODE ;110
- O_STOPHERO ;111
- O_ANIMUPDATEOFF ;112
- O_ANIMUPDATEON ;113
- O_FREECURSOR ;114
- O_ADDINVQUIET ;115
- O_RUNHERO ;116
- O_SETBACKANIMDATA ;117
- O_VIEWFLC ;118
- O_CHECKFLCFRAME ;119
- O_CHECKFLCEND ;120
- O_FREEFLC ;121
- O_TALKHEROSTOP ;122
- O_HEROCOLOR ;123
- O_GRABMAPA ;124
- O_ENABLENAK ;125
- O_DISABLENAK ;126
- O_GETMOBNAME ;127
- O_SWAPINVENTORY ;128
- O_CLEARINVENTORY ;129
- O_SKIPTEXT ;130
- O_SETVOICEH ;131
- O_SETVOICEA ;132
- O_SETVOICEB ;133
- O_SETVOICEC ;134
- O_VIEWFLCLOOP ;135
- O_FLCSPEED ;136
- O_OPENINVENTORY ;137
- O_KRZYWA ;138
- O_GETKRZYWA ;139
- O_GETMOB ;140
- O_INPUTLINE ;141
- O_SETVOICED ;142
- O_BREAK_POINT ;143
-#endif
};
}