Skip to content

Commit

Permalink
PRINCE: O_CHANGEMOB(), getMobVisible(), setMobVisible()
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaslw committed Jun 28, 2014
1 parent 011ecf0 commit 49de202
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion engines/prince/prince.cpp
Expand Up @@ -401,7 +401,7 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
_mainHero->setShadowScale(_script->getShadowScale(_locationNr));

for (uint i = 0; i < _mobList.size(); i++) {
_mobList[i]._visible = _script->getMobVisible(_room->_mobs, i);
_mobList[i]._visible = _script->getMobVisible(i);
}

clearBackAnimList();
Expand Down
4 changes: 2 additions & 2 deletions engines/prince/prince.h
Expand Up @@ -266,6 +266,8 @@ class PrinceEngine : public Engine {
int32 _picWindowY;
Image::BitmapDecoder *_roomBmp;
MhwanhDecoder *_suitcaseBmp;
Room *_room;
Script *_script;

Common::Array<AnimListItem> _animList;
Common::Array<BackgroundAnim> _backAnimList;
Expand Down Expand Up @@ -403,12 +405,10 @@ class PrinceEngine : public Engine {
Cursor *_cursor3;
Debugger *_debugger;
GraphicsMan *_graph;
Script *_script;
InterpreterFlags *_flags;
Interpreter *_interpreter;
Font *_font;
MusicPlayer *_midiPlayer;
Room *_room;

static const uint32 MAX_SAMPLES = 60;
Common::SeekableReadStream *_voiceStream[MAX_SAMPLES];
Expand Down
19 changes: 14 additions & 5 deletions engines/prince/script.cpp
Expand Up @@ -224,8 +224,12 @@ uint32 Script::getStartGameOffset() {
return _scriptInfo.startGame;
}

bool Script::getMobVisible(int roomMobOffset, int mobNr) {
return _data[roomMobOffset + mobNr];
bool Script::getMobVisible(int mob) {
return _data[_vm->_room->_mobs + mob];
}

void Script::setMobVisible(int mob, int value) {
_data[_vm->_room->_mobs + mob] = value;
}

uint8 *Script::getRoomOffset(int locationNr) {
Expand Down Expand Up @@ -458,7 +462,9 @@ void Interpreter::debugInterpreter(const char *s, ...) {
Common::String str = Common::String::format("@0x%08X: ", _lastInstruction);
str += Common::String::format("op %04d: ", _lastOpcode);
//debugC(10, DebugChannel::kScript, "PrinceEngine::Script %s %s", str.c_str(), buf);
debug(10, "PrinceEngine::Script %s %s", str.c_str(), buf);
if (_mode == "fg") {
debug(10, "PrinceEngine::Script %s %s", str.c_str(), buf);
}
//debug("Prince::Script frame %08ld mode %s %s %s", _vm->_frameNr, _mode, str.c_str(), buf);
}

Expand Down Expand Up @@ -536,7 +542,7 @@ Flags::Id Interpreter::readScriptFlagId() {
}

void Interpreter::O_WAITFOREVER() {
debugInterpreter("O_WAITFOREVER");
//debugInterpreter("O_WAITFOREVER");
_opcodeNF = 1;
_currentInstruction -= 2;
}
Expand Down Expand Up @@ -965,7 +971,10 @@ void Interpreter::O_CHANGEMOB() {
uint16 mob = readScriptFlagValue();
uint16 value = readScriptFlagValue();
debugInterpreter("O_CHANGEMOB mob %d, value %d", mob, value);
// Probably sets mobs visible flag to value

value ^= 1;
_vm->_script->setMobVisible(mob, value);
_vm->_mobList[mob]._visible = value;
}

void Interpreter::O_ADDINV() {
Expand Down
3 changes: 2 additions & 1 deletion engines/prince/script.h
Expand Up @@ -143,7 +143,8 @@ class Script {

int scanMobEvents(int mobMask, int dataEventOffset);
int scanMobEventsWithItem(int mobMask, int dataEventOffset, int itemMask);
bool getMobVisible(int roomMobOffset, int mobNr);
bool getMobVisible(int mob);
void setMobVisible(int mob, int value);

const char *getString(uint32 offset) {
return (const char *)(&_data[offset]);
Expand Down

0 comments on commit 49de202

Please sign in to comment.