aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Zbróg2013-11-18 16:19:21 +0000
committerKamil Zbróg2013-11-18 16:19:21 +0000
commit3d1d1884324a240b73fea6de3b5df6f7310eeb53 (patch)
tree1d90a8a93af70a8ef6a8ee9139010adf6719c733
parente8f15766f8bdd1825d38faaef821d267a2f58f18 (diff)
downloadscummvm-rg350-3d1d1884324a240b73fea6de3b5df6f7310eeb53.tar.gz
scummvm-rg350-3d1d1884324a240b73fea6de3b5df6f7310eeb53.tar.bz2
scummvm-rg350-3d1d1884324a240b73fea6de3b5df6f7310eeb53.zip
PRINCE: script updated to read value when necessary
-rw-r--r--engines/prince/animation.cpp0
-rw-r--r--engines/prince/animation.h39
-rw-r--r--engines/prince/archive.cpp8
-rw-r--r--engines/prince/cursor.h2
-rw-r--r--engines/prince/mhwanh.cpp3
-rw-r--r--engines/prince/mhwanh.h4
-rw-r--r--engines/prince/prince.cpp55
-rw-r--r--engines/prince/script.cpp392
-rw-r--r--engines/prince/script.h2
9 files changed, 317 insertions, 188 deletions
diff --git a/engines/prince/animation.cpp b/engines/prince/animation.cpp
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/engines/prince/animation.cpp
diff --git a/engines/prince/animation.h b/engines/prince/animation.h
new file mode 100644
index 0000000000..e6a76d33d2
--- /dev/null
+++ b/engines/prince/animation.h
@@ -0,0 +1,39 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PRINCE_ANIMATION_H
+#define PRINCE_ANIMATION_H
+
+namespace Prince {
+
+class Animation {
+
+ bool loadFromStream(Common::SeekableReadStream &stream);
+
+ const Graphics::Surface *getSurface(uint16 frameIndex) const;
+};
+
+}
+
+#endif
+
+/* vim: set tabstop=4 noexpandtab: */
diff --git a/engines/prince/archive.cpp b/engines/prince/archive.cpp
index a6927baf0c..0b1367f966 100644
--- a/engines/prince/archive.cpp
+++ b/engines/prince/archive.cpp
@@ -55,8 +55,8 @@ bool PtcArchive::open(const Common::String &filename) {
uint32 fileTableOffset = _stream->readUint32LE() ^ 0x4D4F4B2D; // MOK-
uint32 fileTableSize = _stream->readUint32LE() ^ 0x534F4654; // SOFT
- debug("fileTableOffset : %08X", fileTableOffset);
- debug("fileTableSize: %08X", fileTableSize);
+ //debug("fileTableOffset : %08X", fileTableOffset);
+ //debug("fileTableSize: %08X", fileTableSize);
_stream->seek(fileTableOffset);
@@ -70,7 +70,7 @@ bool PtcArchive::open(const Common::String &filename) {
Common::String name = (const char*)fileItem;
item._offset = READ_LE_UINT32(fileItem + 24);
item._size = READ_LE_UINT32(fileItem + 28);
- debug("%12s %8X %d", name.c_str(), item._offset, item._size);
+ //debug("%12s %8X %d", name.c_str(), item._offset, item._size);
_items[name] = item;
}
@@ -135,7 +135,7 @@ Common::SeekableReadStream *PtcArchive::createReadStreamForMember(const Common::
buffer = decompData;
}
- debug("PtcArchive::createReadStreamForMember name %s", name.c_str());
+ //debug("PtcArchive::createReadStreamForMember name %s", name.c_str());
return new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES);
}
diff --git a/engines/prince/cursor.h b/engines/prince/cursor.h
index 05c7da9f33..70516519e6 100644
--- a/engines/prince/cursor.h
+++ b/engines/prince/cursor.h
@@ -37,7 +37,7 @@ public:
~Cursor();
bool loadFromStream(Common::SeekableReadStream &stream);
- Graphics::Surface *getSurface() const { return _surface; }
+ const Graphics::Surface *getSurface() const { return _surface; }
private:
Graphics::Surface *_surface;
diff --git a/engines/prince/mhwanh.cpp b/engines/prince/mhwanh.cpp
index 92a6a900f5..3bd034e4a7 100644
--- a/engines/prince/mhwanh.cpp
+++ b/engines/prince/mhwanh.cpp
@@ -39,7 +39,8 @@ MhwanhDecoder::~MhwanhDecoder() {
void MhwanhDecoder::destroy() {
if (_surface) {
_surface->free();
- delete _surface; _surface = 0;
+ delete _surface;
+ _surface = 0;
}
delete [] _palette; _palette = 0;
diff --git a/engines/prince/mhwanh.h b/engines/prince/mhwanh.h
index 2b70ae525b..b11ecd08e6 100644
--- a/engines/prince/mhwanh.h
+++ b/engines/prince/mhwanh.h
@@ -36,8 +36,8 @@ public:
// ImageDecoder API
void destroy();
virtual bool loadStream(Common::SeekableReadStream &stream);
- virtual Graphics::Surface *getSurface() const { return _surface; }
- const byte *getPalette() const { return _palette; }
+ virtual const Graphics::Surface *getSurface() const { return _surface; }
+ virtual const byte *getPalette() const { return _palette; }
uint16 getPaletteCount() const { return _paletteColorCount; }
private:
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index 4a8fa9ae71..9f4ae19af3 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -100,6 +100,11 @@ PrinceEngine::~PrinceEngine() {
delete _variaTxt;
delete[] _talkTxt;
delete _graph;
+
+ for (uint32 i = 0; i < _objList.size(); ++i) {
+ delete _objList[i];
+ }
+ _objList.clear();
}
GUI::Debugger *PrinceEngine::getDebugger() {
@@ -153,9 +158,9 @@ bool loadResource(Common::Array<T> &array, const char *resourceName, bool requir
delete stream;
return true;
}
-#if 0
+
template <typename T>
-bool loadResource(T * array[], const char *resourceName, bool required = true) {
+bool loadResource(Common::Array<T *> &array, const char *resourceName, bool required = true) {
Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(resourceName);
if (!stream) {
if (required)
@@ -163,14 +168,19 @@ bool loadResource(T * array[], const char *resourceName, bool required = true) {
return false;
}
- T* t = new T();
- while (t->loadFromStream(*stream))
+ // FIXME: This is stupid. Maybe loadFromStream should be helper method that returns initiailzed object
+ while (true) {
+ T* t = new T();
+ if (!t->loadFromStream(*stream)) {
+ delete t;
+ break;
+ }
array.push_back(t);
+ }
delete stream;
return true;
}
-#endif
void PrinceEngine::init() {
@@ -201,6 +211,7 @@ void PrinceEngine::init() {
_font = new Font();
loadResource(_font, "all/font1.raw");
+
_walizkaBmp = new MhwanhDecoder();
loadResource(_walizkaBmp, "all/walizka");
@@ -226,6 +237,8 @@ void PrinceEngine::init() {
talkTxtStream->read(_talkTxt, _talkTxtSize);
delete talkTxtStream;
+
+ _roomBmp = new Graphics::BitmapDecoder();
}
void PrinceEngine::showLogo() {
@@ -244,21 +257,25 @@ Common::Error PrinceEngine::run() {
showLogo();
-// return Common::kNoError;
-
mainLoop();
return Common::kNoError;
}
bool PrinceEngine::loadLocation(uint16 locationNr) {
- _cameraX = 0;
- _newCameraX = 0;
- _debugger->_locationNr = locationNr;
debugEngine("PrinceEngine::loadLocation %d", locationNr);
const Common::FSNode gameDataDir(ConfMan.get("path"));
SearchMan.remove(Common::String::format("%02d", _locationNr));
+
_locationNr = locationNr;
+ _debugger->_locationNr = locationNr;
+ _cameraX = 0;
+ _newCameraX = 0;
+
+ _script->setFlagValue(Flags::CURRROOM, _locationNr);
+ _script->stopBg();
+
+ changeCursor(0);
const Common::String locationNrStr = Common::String::format("%02d", _locationNr);
debugEngine("loadLocation %s", locationNrStr.c_str());
@@ -269,9 +286,10 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
SearchMan.add(locationNrStr, locationArchive);
- delete _roomBmp;
- // load location background
- _roomBmp = new Graphics::BitmapDecoder();
+ const char *musName = MusicPlayer::_musTable[MusicPlayer::_musRoomTable[locationNr]];
+ _midiPlayer->loadMidi(musName);
+
+ // load location background, replace old one
loadResource(_roomBmp, "room");
if (_roomBmp->getSurface()) {
_sceneWidth = _roomBmp->getSurface()->w;
@@ -280,8 +298,11 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
_mobList.clear();
loadResource(_mobList, "mob.lst", false);
- const char *musName = MusicPlayer::_musTable[MusicPlayer::_musRoomTable[locationNr]];
- _midiPlayer->loadMidi(musName);
+ for (uint32 i = 0; i < _objList.size(); ++i) {
+ delete _objList[i];
+ }
+ _objList.clear();
+ loadResource(_objList, "obj.lst", false);
return true;
}
@@ -289,7 +310,7 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
void PrinceEngine::changeCursor(uint16 curId) {
_debugger->_cursorNr = curId;
- Graphics::Surface *curSurface = NULL;
+ const Graphics::Surface *curSurface = NULL;
uint16 hotspotX = 0;
uint16 hotspotY = 0;
@@ -591,7 +612,7 @@ void PrinceEngine::mainLoop() {
// TODO: Update all structures, animations, naks, heros etc.
- //_script->step();
+ _script->step();
drawScreen();
// Calculate the frame delay based off a desired frame time
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp
index 7ad2df2a56..07821f27a8 100644
--- a/engines/prince/script.cpp
+++ b/engines/prince/script.cpp
@@ -98,30 +98,24 @@ void Script::step() {
}
uint32 Script::step(uint32 opcodePC) {
-
_currentInstruction = opcodePC;
- while (!_opcodeNF)
- {
+
+ while (!_opcodeNF) {
_lastInstruction = _currentInstruction;
- // Prepare the base debug string
- Common::String dstr = Common::String::format("@0x%04X: ", _currentInstruction);
// Get the current opcode
_lastOpcode = readScript16bits();
- dstr += Common::String::format("op %02d: ", _lastOpcode);
-
- if (_lastOpcode > NUM_OPCODES)
- error("Trying to execute unknown opcode %s", dstr.c_str());
-
-
- //debugScript("");
+ if (_lastOpcode > NUM_OPCODES)
+ error(
+ "Trying to execute unknown opcode @0x%04X: %02d",
+ _currentInstruction,
+ _lastOpcode);
// Execute the current opcode
OpcodeFunc op = _opcodes[_lastOpcode];
(this->*op)();
if (_opcodeNF) {
-
_opcodeNF = 0;
break;
}
@@ -178,68 +172,68 @@ void Script::O_SETUPPALETTE() {
}
void Script::O_INITROOM() {
- uint16 roomId = readScript16bits();
+ uint16 roomId = readScriptValue();
debugScript("O_INITROOM %d", roomId);
_vm->loadLocation(roomId);
_opcodeNF = 1;
}
void Script::O_SETSAMPLE() {
- uint16 sampleId = readScript16bits();
+ uint16 sampleId = readScriptValue();
int32 sampleNameOffset = readScript32bits();
- const char * sampleName = (const char *)_code + _currentInstruction + sampleNameOffset - 4;
+ const char * sampleName = (const char *)&_code[_currentInstruction + sampleNameOffset - 4];
debugScript("O_SETSAMPLE %d %s", sampleId, sampleName);
}
void Script::O_FREESAMPLE() {
- uint16 sample = readScript16bits();
+ uint16 sample = readScriptValue();
debugScript("O_FREESAMPLE %d", sample);
}
void Script::O_PLAYSAMPLE() {
- uint16 sampleId = readScript16bits();
+ uint16 sampleId = readScriptValue();
uint16 loopType = readScript16bits();
debugScript("O_PLAYSAMPLE sampleId %d loopType %d", sampleId, loopType);
_vm->playSample(sampleId, loopType);
}
void Script::O_PUTOBJECT() {
- uint16 roomId = readScript16bits();
- uint16 slot = readScript16bits();
- uint16 objectId = readScript16bits();
+ uint16 roomId = readScriptValue();
+ uint16 slot = readScriptValue();
+ uint16 objectId = readScriptValue();
debugScript("O_PUTOBJECT roomId %d, slot %d, objectId %d", roomId, slot, objectId);
}
void Script::O_REMOBJECT() {
- uint16 roomId = readScript16bits();
- uint16 objectId = readScript16bits();
+ uint16 roomId = readScriptValue();
+ uint16 objectId = readScriptValue();
debugScript("O_REMOBJECT roomId %d objectId %d", roomId, objectId);
}
void Script::O_SHOWANIM() {
- uint16 slot = readScript16bits();
- uint16 animId = readScript16bits();
+ uint16 slot = readScriptValue();
+ uint16 animId = readScriptValue();
debugScript("O_SHOWANIM slot %d, animId %d", slot, animId);
}
void Script::O_CHECKANIMEND() {
- uint16 slot = readScript16bits();
- uint16 frameId = readScript16bits();
+ uint16 slot = readScriptValue();
+ uint16 frameId = readScriptValue();
debugScript("O_CHECKANIMEND slot %d, frameId %d", slot, frameId);
_opcodeNF = 1;
}
void Script::O_FREEANIM() {
- uint16 slot = readScript16bits();
+ uint16 slot = readScriptValue();
debugScript("O_FREEANIM slot %d", slot);
}
void Script::O_CHECKANIMFRAME() {
- uint16 slot = readScript16bits();
- uint16 frameId = readScript16bits();
+ uint16 slot = readScriptValue();
+ uint16 frameId = readScriptValue();
debugScript("O_CHECKANIMFRAME slot %d, frameId %d", slot, frameId);
_opcodeNF = 1;
@@ -253,15 +247,15 @@ void Script::O_PUTBACKANIM() {
}
void Script::O_REMBACKANIM() {
- uint16 roomId = readScript16bits();
- uint16 slot = readScript16bits();
+ uint16 roomId = readScriptValue();
+ uint16 slot = readScriptValue();
debugScript("O_REMBACKANIM roomId %d, slot %d", roomId, slot);
}
void Script::O_CHECKBACKANIMFRAME() {
- uint16 slotId = readScript16bits();
- uint16 frameId = readScript16bits();
+ uint16 slotId = readScriptValue();
+ uint16 frameId = readScriptValue();
debugScript("O_CHECKBACKANIMFRAME slotId %d, frameId %d", slotId, frameId);
_opcodeNF = 1;
@@ -282,7 +276,7 @@ void Script::O_STOPMUSIC() {
}
void Script::O__WAIT() {
- uint16 pause = readScript16bits();
+ uint16 pause = readScriptValue();
debugScript("O__WAIT pause %d", pause);
@@ -305,18 +299,22 @@ void Script::O__WAIT() {
void Script::O_UPDATEOFF() {
debugScript("O_UPDATEOFF");
+ //_updateEnable = false;
}
void Script::O_UPDATEON() {
debugScript("O_UPDATEON");
+ //_updateEnable = true;
}
void Script::O_UPDATE () {
debugScript("O_UPDATE");
+ // Refresh screen
}
void Script::O_CLS() {
debugScript("O_CLS");
+ // do nothing
}
void Script::O__CALL() {
@@ -345,17 +343,17 @@ void Script::O_GO() {
}
void Script::O_BACKANIMUPDATEOFF() {
- uint16 slotId = readScript32bits();
+ uint16 slotId = readScriptValue();
debugScript("O_BACKANIMUPDATEOFF slotId %d", slotId);
}
void Script::O_BACKANIMUPDATEON() {
- uint16 slot = readScript16bits();
+ uint16 slot = readScriptValue();
debugScript("O_BACKANIMUPDATEON %d", slot);
}
void Script::O_CHANGECURSOR() {
- uint16 cursorId = readScript16bits();
+ uint16 cursorId = readScriptValue();
debugScript("O_CHANGECURSOR %x", cursorId);
}
@@ -399,8 +397,10 @@ void Script::O_JUMPNZ() {
}
void Script::O_EXIT() {
- uint16 exitCode = readScript16bits();
+ uint16 exitCode = readScriptValue();
debugScript("O_EXIT exitCode %d", exitCode);
+ // Set exit code and shows credits
+ // if exit code == 0x02EAD
}
void Script::O_ADDFLAG() {
@@ -417,8 +417,8 @@ void Script::O_ADDFLAG() {
}
void Script::O_TALKANIM() {
- uint16 animSlot = readScript16bits();
- uint16 slot = readScript16bits();
+ uint16 animSlot = readScriptValue();
+ uint16 slot = readScriptValue();
debugScript("O_TALKANIM animSlot %d, slot %d", animSlot, slot);
}
@@ -440,6 +440,7 @@ void Script::O_SETSTRING() {
int32 offset = readScript32bits();
_currentString = offset;
+ // FIXME: Make it better ;)
if (offset >= 80000) {
debugScript("GetVaria %s", _vm->_variaTxt->getString(offset - 80000));
}
@@ -515,22 +516,23 @@ void Script::O_XORFLAG() {
}
void Script::O_GETMOBTEXT() {
- uint16 value = readScript16bits();
+ uint16 value = readScriptValue();
debugScript("O_GETMOBTEXT value %d", value);
+ // Use Mob::ExamText as current string
}
void Script::O_MOVEHERO() {
- uint16 heroId = readScript16bits();
- uint16 x = readScript16bits();
- uint16 y = readScript16bits();
- uint16 dir = readScript16bits();
+ uint16 heroId = readScriptValue();
+ uint16 x = readScriptValue();
+ uint16 y = readScriptValue();
+ uint16 dir = readScriptValue();
debugScript("O_MOVEHERO heroId %d, x %d, y %d, dir %d", heroId, x, y, dir);
}
void Script::O_WALKHERO() {
- uint16 heroId = readScript16bits();
+ uint16 heroId = readScriptValue();
debugScript("O_WALKHERO %d", heroId);
_opcodeNF = 1;
@@ -545,18 +547,22 @@ void Script::O_SETHERO() {
}
void Script::O_HEROOFF() {
- uint16 heroId = readScript16bits();
+ uint16 heroId = readScriptValue();
debugScript("O_HEROOFF %d", heroId);
+ // sets hero visible flag to false
}
void Script::O_HEROON() {
- uint16 heroId = readScript16bits();
+ uint16 heroId = readScriptValue();
debugScript("O_HEROON %d", heroId);
+ // sets hero visible flag to true
}
void Script::O_CLSTEXT() {
- uint16 slot = readScript16bits();
+ uint16 slot = readScriptValue();
debugScript("O_CLSTEXT slot %d", slot);
+ // Sets text line to null
+ // Sets text timeout to zero
}
void Script::O_CALLTABLE() {
@@ -564,23 +570,27 @@ void Script::O_CALLTABLE() {
int32 table = readScript32bits();
debugScript("O_CALLTABLE flag %d, table %d", flag, table);
+ // makes a call from script function table
+ // must read table pointer from _code and
+ // use table entry as next opcode
}
void Script::O_CHANGEMOB() {
- uint16 mob = readScript16bits();
- uint16 value = readScript16bits();
+ uint16 mob = readScriptValue();
+ uint16 value = readScriptValue();
debugScript("O_CHANGEMOB mob %d, value %d", mob, value);
+ // Probably sets mobs visible flag to value
}
void Script::O_ADDINV() {
- uint16 hero = readScript16bits();
- uint16 item = readScript16bits();
+ uint16 hero = readScriptValue();
+ uint16 item = readScriptValue();
debugScript("O_ADDINV hero %d, item %d", hero, item);
}
void Script::O_REMINV() {
- uint16 hero = readScript16bits();
- uint16 item = readScript16bits();
+ uint16 hero = readScriptValue();
+ uint16 item = readScriptValue();
debugScript("O_REMINV hero %d, item %d", hero, item);
}
@@ -588,11 +598,13 @@ void Script::O_REPINV() {
uint16 hero = readScript16bits();
uint16 item1 = readScript16bits();
uint16 item2 = readScript16bits();
- debugScript("O_REPINV hero %d, item1 %d, item2 %d", hero, item1, item2);
+ // shouldn't be uses
+ error("O_REPINV hero %d, item1 %d, item2 %d", hero, item1, item2);
}
void Script::O_OBSOLETE_GETACTION() {
- debugScript("O_OBSOLETE_GETACTION");
+ // shouldn't be uses
+ error("O_OBSOLETE_GETACTION");
}
void Script::O_ADDWALKAREA() {
@@ -600,7 +612,8 @@ void Script::O_ADDWALKAREA() {
uint16 y1 = readScript16bits();
uint16 x2 = readScript16bits();
uint16 y2 = readScript16bits();
- debugScript("O_ADDWALKAREA x1 %d, y1 %d, x2 %d, y2 %d", x1, y1, x2, y2);
+ // shouldn't be uses
+ error("O_ADDWALKAREA x1 %d, y1 %d, x2 %d, y2 %d", x1, y1, x2, y2);
}
void Script::O_REMWALKAREA() {
@@ -608,7 +621,9 @@ void Script::O_REMWALKAREA() {
uint16 y1 = readScript16bits();
uint16 x2 = readScript16bits();
uint16 y2 = readScript16bits();
- debugScript("O_REMWALKAREA x1 %d, y1 %d, x2 %d, y2 %d", x1, y1, x2, y2);
+
+ // shouldn't be uses
+ error("O_REMWALKAREA x1 %d, y1 %d, x2 %d, y2 %d", x1, y1, x2, y2);
}
void Script::O_RESTOREWALKAREA() {
@@ -621,46 +636,53 @@ void Script::O_WAITFRAME() {
}
void Script::O_SETFRAME() {
- uint16 anim = readScript16bits();
- uint16 frame = readScript16bits();
+ uint16 anim = readScriptValue();
+ uint16 frame = readScriptValue();
debugScript("O_SETFRAME anim %d, frame %d", anim, frame);
}
void Script::O_RUNACTION() {
- debugScript("O_RUNACTION");
+ // It's empty in original and never used in script
+ // it's better to report error
+ error("O_RUNACTION");
}
void Script::O_COMPAREHI() {
- uint16 flag = readScript16bits();
- uint16 value = readScript16bits();
+ Flags::Id flag = readScriptFlagId();
+ uint16 value = readScriptValue();
debugScript("O_COMPAREHI flag %d, value %d", flag, value);
+ _result = value < getFlagValue(flag);
}
void Script::O_COMPARELO() {
- uint16 flag = readScript16bits();
- uint16 value = readScript16bits();
+ Flags::Id flag = readScriptFlagId();
+ uint16 value = readScriptValue();
debugScript("O_COMPARELO flag %d, value %d", flag, value);
+ _result = value > getFlagValue(flag);
}
void Script::O_PRELOADSET() {
+ // not used in script
int32 offset = readScript32bits();
debugScript("O_PRELOADSET offset %04x", offset);
}
void Script::O_FREEPRELOAD() {
+ // not used in script
debugScript("O_FREEPRELOAD");
}
void Script::O_CHECKINV() {
- uint16 hero = readScript16bits();
- uint16 item = readScript16bits();
+ uint16 hero = readScriptValue();
+ uint16 item = readScriptValue();
debugScript("O_CHECKINV hero %d, item %d", hero, item);
+ // checks if item is in heros inventory
}
void Script::O_TALKHERO() {
- uint16 hero = readScript16bits();
+ uint16 hero = readScriptValue();
debugScript("O_TALKHERO hero %d", hero);
}
@@ -674,21 +696,21 @@ void Script::O_WAITTEXT() {
}
void Script::O_SETHEROANIM() {
- uint16 hero = readScript16bits();
+ uint16 hero = readScriptValue();
int32 offset = readScript32bits();
debugScript("O_SETHEROANIM hero %d, offset %d", hero, offset);
}
void Script::O_WAITHEROANIM() {
- uint16 hero = readScript16bits();
+ uint16 hero = readScriptValue();
debugScript("O_WAITHEROANIM hero %d", hero);
}
void Script::O_GETHERODATA() {
uint16 flag = readScript16bits();
- uint16 hero = readScript16bits();
- uint16 heroOffset =readScript16bits();
+ uint16 hero = readScriptValue();
+ uint16 heroOffset = readScriptValue();
debugScript("O_GETHERODATA flag %d, hero %d, heroOffset %d", flag, hero, heroOffset);
}
@@ -697,22 +719,32 @@ void Script::O_GETMOUSEBUTTON() {
}
void Script::O_CHANGEFRAMES() {
- uint16 anim = readScript16bits();
- uint16 fr1 = readScript16bits();
- uint16 fr2 = readScript16bits();
- uint16 fr3 = readScript16bits();
+ uint16 anim = readScriptValue();
+ uint16 frame = readScriptValue();
+ uint16 lastFrame = readScriptValue();
+ uint16 loopFrame = readScriptValue();
- debugScript("O_CHANGFRAMES anim %d, fr1 %d, fr2 %d, fr3 %d", anim, fr1, fr2, fr3);
+ debugScript(
+ "O_CHANGFRAMES anim %d, fr1 %d, fr2 %d, fr3 %d",
+ anim,
+ frame,
+ lastFrame,
+ loopFrame);
}
void Script::O_CHANGEBACKFRAMES() {
- uint16 anim = readScript16bits();
- uint16 fr1 = readScript16bits();
- uint16 fr2 = readScript16bits();
- uint16 fr3 = readScript16bits();
+ uint16 anim = readScriptValue();
+ uint16 frame = readScriptValue();
+ uint16 lastFrame = readScriptValue();
+ uint16 loopFrame = readScriptValue();
- debugScript("O_CHANGEBACKFRAMES anim %d, fr1 %d, fr2 %d, fr3 %d", anim, fr1, fr2, fr3);
+ debugScript(
+ "O_CHANGEBACKFRAMES anim %d, fr1 %d, fr2 %d, fr3 %d",
+ anim,
+ frame,
+ lastFrame,
+ loopFrame);
}
void Script::O_GETBACKANIMDATA() {
@@ -724,9 +756,11 @@ void Script::O_GETBACKANIMDATA() {
void Script::O_GETANIMDATA() {
uint16 flag = readScript16bits();
- uint16 anim = readScript16bits();
- uint16 animOffset = readScript16bits();
+ uint16 anim = readScriptValue();
+ uint16 animOffset = readScriptValue();
debugScript("O_GETANIMDATA flag %d, anim %d, animOffset %d", flag, anim, animOffset);
+ // Gets value of anim data
+ // use anim offset as attribute id not an offset
}
void Script::O_SETBGCODE() {
@@ -736,27 +770,33 @@ void Script::O_SETBGCODE() {
}
void Script::O_SETBACKFRAME() {
- uint16 anim = readScript16bits();
- uint16 frame = readScript16bits();
+ uint16 anim = readScriptValue();
+ uint16 frame = readScriptValue();
debugScript("O_SETBACKFRAME anim %d, frame %d", anim, frame);
}
void Script::O_GETRND() {
- uint16 flag = readScript16bits();
+ Flags::Id flag = readScriptFlagId();
uint16 rndSeed = readScript16bits();
debugScript("O_GETRND flag %d, rndSeed %d", flag, rndSeed);
+ // puts and random value as flag value
+ // fairly random value ;)
+ // setFlagValue(flag, 4);
}
void Script::O_TALKBACKANIM() {
- uint16 animSlot = readScript16bits();
- uint16 slot = readScript16bits();
+ uint16 animSlot = readScriptValue();
+ uint16 slot = readScriptValue();
debugScript("O_TALKBACKANIM animSlot %d, slot %d", animSlot, slot);
}
void Script::O_LOADPATH() {
int32 offset = readScript32bits();
debugScript("O_LOADPATH offset %d", offset);
+ // _currentInstruction + offset path file name ptr
+ // free path bitmap
+ // load packet path bitmap and puts in Sala
}
void Script::O_GETCHAR() {
@@ -764,7 +804,11 @@ void Script::O_GETCHAR() {
setFlagValue(flagId, *_string);
- debugScript("O_GETCHAR %04X (%s) %02x", flagId, Flags::getFlagName(flagId), getFlagValue(flagId));
+ debugScript(
+ "O_GETCHAR %04X (%s) %02x",
+ flagId,
+ Flags::getFlagName(flagId),
+ getFlagValue(flagId));
++_string;
}
@@ -773,17 +817,20 @@ void Script::O_SETDFLAG() {
uint16 flag = readScript16bits();
int32 offset = readScript32bits();
debugScript("O_SETDFLAG flag %d, offset %04x", flag, offset);
+ // run this through debugger looks strange
+ // it looks like this one store two 16 bit value in one go
}
void Script::O_CALLDFLAG() {
uint16 flag = readScript16bits();
debugScript("O_CALLDFLAG flag %d", flag);
+ // it seems that some flags are 32 bit long
}
void Script::O_PRINTAT() {
- uint16 slot = readScript16bits();
- uint16 fr1 = readScript16bits();
- uint16 fr2 = readScript16bits();
+ uint16 slot = readScriptValue();
+ uint16 fr1 = readScriptValue();
+ uint16 fr2 = readScriptValue();
debugScript("O_PRINTAT slot %d, fr1 %d, fr2 %d", slot, fr1, fr2);
@@ -798,31 +845,33 @@ void Script::O_PRINTAT() {
}
void Script::O_ZOOMIN() {
- uint16 slot = readScript16bits();
+ uint16 slot = readScriptValue();
debugScript("O_ZOOMIN slot %04d", slot);
}
void Script::O_ZOOMOUT() {
- uint16 slot = readScript16bits();
+ uint16 slot = readScriptValue();
debugScript("O_ZOOMOUT slot %d", slot);
}
void Script::O_SETSTRINGOFFSET() {
int32 offset = readScript32bits();
debugScript("O_SETSTRINGOFFSET offset %04x", offset);
+ // _currentString = ""
+ // _string = (const char *)_currentInstruction + offset
}
void Script::O_GETOBJDATA() {
- uint16 flag = readScript16bits();
- uint16 obj = readScript16bits();
- int16 objOffset = readScript16bits();
+ Flags::Id flag = readScriptFlagId();
+ uint16 obj = readScriptValue();
+ int16 objOffset = readScriptValue();
debugScript("O_GETOBJDATA flag %d, obj %d, objOffset %d", flag, obj, objOffset);
}
void Script::O_SETOBJDATA() {
- uint16 obj = readScript16bits();
- int16 objOffset = readScript16bits();
- uint16 value = readScript16bits();
+ uint16 obj = readScriptValue();
+ int16 objOffset = readScriptValue();
+ uint16 value = readScriptValue();
debugScript("O_SETOBJDATA obj %d, objOffset %d, value %d", obj, objOffset, value);
}
@@ -833,19 +882,21 @@ void Script::O_SWAPOBJECTS() {
}
void Script::O_CHANGEHEROSET() {
- uint16 hero = readScript16bits();
- uint16 heroSet = readScript16bits();
+ uint16 hero = readScriptValue();
+ uint16 heroSet = readScriptValue();
debugScript("O_CHANGEHEROSET hero %d, heroSet %d", hero, heroSet);
}
void Script::O_ADDSTRING() {
- uint16 value = readScript16bits();
+ uint16 value = readScriptValue();
debugScript("O_ADDSTRING value %d", value);
+ // _string += value
}
void Script::O_SUBSTRING() {
- uint16 value = readScript16bits();
+ uint16 value = readScriptValue();
debugScript("O_SUBSTRING value %d", value);
+ // _string -= value
}
void Script::O_INITDIALOG() {
@@ -853,45 +904,47 @@ void Script::O_INITDIALOG() {
}
void Script::O_ENABLEDIALOGOPT() {
- uint16 opt = readScript16bits();
+ uint16 opt = readScriptValue();
debugScript("O_ENABLEDIALOGOPT opt %d", opt);
}
void Script::O_DISABLEDIALOGOPT() {
- uint16 opt = readScript16bits();
+ uint16 opt = readScriptValue();
debugScript("O_DISABLEDIALOGOPT opt %d", opt);
}
void Script::O_SHOWDIALOGBOX() {
- uint16 box = readScript16bits();
+ uint16 box = readScriptValue();
debugScript("O_SHOWDIALOGBOX box %d", box);
}
void Script::O_STOPSAMPLE() {
- uint16 slot = readScript16bits();
+ uint16 slot = readScriptValue();
debugScript("O_STOPSAMPLE slot %d", slot);
_vm->stopSample(slot);
}
void Script::O_BACKANIMRANGE() {
- uint16 slotId = readScript16bits();
- uint16 animId = readScript16bits();
- uint16 low = readScript16bits();
- uint16 high = readScript16bits();
+ uint16 slotId = readScriptValue();
+ uint16 animId = readScriptValue();
+ uint16 low = readScriptValue();
+ uint16 high = readScriptValue();
debugScript("O_BACKANIMRANGE slotId %d, animId %d, low %d, high %d", slotId, animId, low, high);
}
void Script::O_CLEARPATH() {
debugScript("O_CLEARPATH");
+ // Fill Sala with 255
}
void Script::O_SETPATH() {
debugScript("O_SETPATH");
+ // CopyPath
}
void Script::O_GETHEROX() {
- uint16 heroId = readScript16bits();
+ uint16 heroId = readScriptValue();
Flags::Id flagId = readScriptFlagId();
debugScript("O_GETHEROX heroId %d, flagId %d", heroId, flagId);
@@ -905,7 +958,7 @@ void Script::O_GETHEROY() {
}
void Script::O_GETHEROD() {
- uint16 heroId = readScript16bits();
+ uint16 heroId = readScriptValue();
Flags::Id flagId = readScriptFlagId();
debugScript("O_GETHEROD heroId %d, flagId %d", heroId, flagId);
@@ -913,10 +966,18 @@ void Script::O_GETHEROD() {
void Script::O_PUSHSTRING() {
debugScript("O_PUSHSTRING");
+ // push on the stack
+ // _currentString
+ // _dialogData
+ // _string
}
void Script::O_POPSTRING() {
debugScript("O_POPSTRING");
+ // pop from the stack
+ // _currentString
+ // _dialogData
+ // _string
}
void Script::O_SETFGCODE() {
@@ -927,9 +988,11 @@ void Script::O_SETFGCODE() {
}
void Script::O_STOPHERO() {
- uint16 heroId = readScript16bits();
+ uint16 heroId = readScriptValue();
debugScript("O_STOPHERO heroId %d", heroId);
+
+ // clear move steps for hero
}
void Script::O_ANIMUPDATEOFF() {
@@ -938,53 +1001,54 @@ void Script::O_ANIMUPDATEOFF() {
}
void Script::O_ANIMUPDATEON() {
- uint16 slotId = readScript16bits();
+ uint16 slotId = readScriptValue();
debugScript("O_ANIMUPDATEON slotId %d", slotId);
}
void Script::O_FREECURSOR() {
debugScript("O_FREECURSOR");
+ // Change cursor to 0
+ // free inv cursor 1
}
void Script::O_ADDINVQUIET() {
- uint16 heroId = readScript16bits();
- uint16 itemId = readScript16bits();
+ uint16 heroId = readScriptValue();
+ uint16 itemId = readScriptValue();
debugScript("O_ADDINVQUIET heorId %d, itemId %d", heroId, itemId);
}
void Script::O_RUNHERO() {
- uint16 heroId = readScript16bits();
- uint16 x = readScript16bits();
- uint16 y = readScript16bits();
- uint16 dir = readScript16bits();
+ uint16 heroId = readScriptValue();
+ uint16 x = readScriptValue();
+ uint16 y = readScriptValue();
+ uint16 dir = readScriptValue();
debugScript("O_RUNHERO heroId %d, x %d, y %d, dir %d", heroId, x, y, dir);
}
void Script::O_SETBACKANIMDATA() {
- uint16 animId = readScript16bits();
- uint16 animOffset = readScript16bits();
- uint16 wart = readScript16bits();
+ uint16 animId = readScriptValue();
+ uint16 animOffset = readScriptValue();
+ uint16 wart = readScriptValue();
debugScript("O_SETBACKANIMDATA animId %d, animOffset %d, wart %d", animId, animOffset, wart);
}
void Script::O_VIEWFLC() {
- uint16 animNr = readScript16bits();
+ uint16 animNr = readScriptValue();
debugScript("O_VIEWFLC animNr %d", animNr);
_vm->loadAnim(animNr, false);
}
void Script::O_CHECKFLCFRAME() {
- uint16 frameNr = readScript16bits();
+ uint16 frameNr = readScriptValue();
debugScript("O_CHECKFLCFRAME frame number %d", frameNr);
const Video::FlicDecoder &flicPlayer = _vm->_flicPlayer;
- if (flicPlayer.getCurFrame() != frameNr)
- {
+ if (flicPlayer.getCurFrame() != frameNr) {
// Move instruction pointer before current instruciton
// must do this check once again till it's false
_currentInstruction -= 2;
@@ -1000,8 +1064,7 @@ void Script::O_CHECKFLCEND() {
//debug("frameCount %d, currentFrame %d", flicPlayer.getFrameCount(), flicPlayer.getCurFrame());
- if (flicPlayer.getFrameCount() - flicPlayer.getCurFrame() > 1)
- {
+ if (flicPlayer.getFrameCount() - flicPlayer.getCurFrame() > 1) {
// Move instruction pointer before current instruciton
// must do this check once again till it's false
_currentInstruction -= 2;
@@ -1014,13 +1077,13 @@ void Script::O_FREEFLC() {
}
void Script::O_TALKHEROSTOP() {
- uint16 heroId = readScript16bits();
+ uint16 heroId = readScriptValue();
debugScript("O_TALKHEROSTOP %d", heroId);
}
void Script::O_HEROCOLOR() {
- uint16 heroId = readScript16bits();
- uint16 kolorr = readScript16bits();
+ uint16 heroId = readScriptValue();
+ uint16 kolorr = readScriptValue();
debugScript("O_HEROCOLOR heroId %d, kolorr %d", heroId, kolorr);
}
@@ -1029,27 +1092,27 @@ void Script::O_GRABMAPA() {
}
void Script::O_ENABLENAK() {
- uint16 nakId = readScript16bits();
+ uint16 nakId = readScriptValue();
debugScript("O_ENABLENAK nakId %d", nakId);
}
void Script::O_DISABLENAK() {
- uint16 nakId = readScript16bits();
+ uint16 nakId = readScriptValue();
debugScript("O_DISABLENAK nakId %d", nakId);
}
void Script::O_GETMOBNAME() {
- uint16 war = readScript16bits();
+ uint16 war = readScriptValue();
debugScript("O_GETMOBNAME war %d", war);
}
void Script::O_SWAPINVENTORY() {
- uint16 heroId = readScript16bits();
+ uint16 heroId = readScriptValue();
debugScript("O_SWAPINVENTORY heroId %d", heroId);
}
void Script::O_CLEARINVENTORY() {
- uint16 heroId = readScript16bits();
+ uint16 heroId = readScriptValue();
debugScript("O_CLEARINVENTORY heroId %d", heroId);
}
@@ -1057,7 +1120,9 @@ void Script::O_SKIPTEXT() {
debugScript("O_SKIPTEXT");
}
-void Script::SetVoice(uint32 slot) {
+void Script::SetVoice(uint32 sampleSlot) {
+ // TODO: use sample slot
+ uint16 slot = readScriptValue();
_vm->loadVoice(
slot,
Common::String::format(
@@ -1069,27 +1134,28 @@ void Script::SetVoice(uint32 slot) {
}
void Script::O_SETVOICEH() {
- uint16 txn = readScript16bits();
- debugScript("O_SETVOICEH txn %d", txn);
- SetVoice(txn);
+ static const uint32 VOICE_H_SLOT = 28;
+ SetVoice(VOICE_H_SLOT);
}
void Script::O_SETVOICEA() {
- uint16 txn = readScript16bits();
- debugScript("O_SETVOICEA txn %d", txn);
- SetVoice(txn);
+ static const uint32 VOICE_A_SLOT = 29;
+ SetVoice(VOICE_A_SLOT);
}
void Script::O_SETVOICEB() {
- uint16 txn = readScript16bits();
- debugScript("O_SETVOICEB txn %d", txn);
- SetVoice(txn);
+ static const uint32 VOICE_B_SLOT = 30;
+ SetVoice(VOICE_B_SLOT);
}
void Script::O_SETVOICEC() {
- uint16 txn = readScript16bits();
- debugScript("O_SETVOICEC txn %d", txn);
- SetVoice(txn);
+ static const uint32 VOICE_C_SLOT = 31;
+ SetVoice(VOICE_C_SLOT);
+}
+
+void Script::O_SETVOICED() {
+ static const uint32 VOICE_D_SLOT = 32;
+ SetVoice(VOICE_D_SLOT);
}
void Script::O_VIEWFLCLOOP() {
@@ -1100,13 +1166,14 @@ void Script::O_VIEWFLCLOOP() {
}
void Script::O_FLCSPEED() {
- uint16 speed = readScript16bits();
+ uint16 speed = readScriptValue();
debugScript("O_FLCSPEED speed %d", speed);
}
void Script::O_OPENINVENTORY() {
debugScript("O_OPENINVENTORY");
_opcodeNF = 1;
+ // _showInventoryFlag = true
}
void Script::O_KRZYWA() {
@@ -1115,24 +1182,23 @@ void Script::O_KRZYWA() {
void Script::O_GETKRZYWA() {
debugScript("O_GETKRZYWA");
+ // setFlagValue(Flags::TORX1, krzywa[_krzywaIndex++])
+ // setFlagValue(Flags::TORY1, krzywa[_krzywaIndex++])
+ // Check _krzywaIndex
}
void Script::O_GETMOB() {
Flags::Id flagId = readScriptFlagId();
- uint16 mx = readScript16bits();
- uint16 my = readScript16bits();
+ uint16 mx = readScriptValue();
+ uint16 my = readScriptValue();
debugScript("O_GETMOB flagId %d, mx %d, my %d", flagId, mx, my);
+ // check if current mob pos = (mx, my)
}
void Script::O_INPUTLINE() {
debugScript("O_INPUTLINE");
}
-void Script::O_SETVOICED() {
- uint16 txn = readScript16bits();
- debugScript("O_SETVOICED txn %d", txn);
- SetVoice(txn);
-}
void Script::O_BREAK_POINT() {
debugScript("O_BREAK_POINT");
diff --git a/engines/prince/script.h b/engines/prince/script.h
index 86b998829f..d9b42baf39 100644
--- a/engines/prince/script.h
+++ b/engines/prince/script.h
@@ -49,6 +49,8 @@ public:
void setFlagValue(Flags::Id flag, uint16 value);
uint16 getFlagValue(Flags::Id flag);
+ void stopBg() { _bgOpcodePC = 0; }
+
private:
PrinceEngine *_vm;