Skip to content

Commit

Permalink
PRINCE: mainLoop() update
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaslw committed Aug 2, 2014
1 parent a1ffdcb commit 54a78d6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 38 deletions.
66 changes: 30 additions & 36 deletions engines/prince/prince.cpp
Expand Up @@ -71,12 +71,12 @@ void PrinceEngine::debugEngine(const char *s, ...) {
vsnprintf(buf, STRINGBUFLEN, s, va);
va_end(va);

debug("Prince::Engine frame %08ld %s", _frameNr, buf);
debug("Prince::Engine %s", buf);
}

PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc) :
Engine(syst), _gameDescription(gameDesc), _graph(nullptr), _script(nullptr), _interpreter(nullptr), _flags(nullptr),
_locationNr(0), _debugger(nullptr), _midiPlayer(nullptr), _room(nullptr), _frameNr(0),
_locationNr(0), _debugger(nullptr), _midiPlayer(nullptr), _room(nullptr),
_cursor1(nullptr), _cursor2(nullptr), _cursor3(nullptr), _font(nullptr),
_suitcaseBmp(nullptr), _roomBmp(nullptr), _cursorNr(0), _picWindowX(0), _picWindowY(0), _randomSource("prince"),
_invLineX(134), _invLineY(176), _invLine(5), _invLines(3), _invLineW(70), _invLineH(76), _maxInvW(72), _maxInvH(76),
Expand Down Expand Up @@ -4379,6 +4379,29 @@ void PrinceEngine::freeCoords3() {
}
}

void PrinceEngine::openInventoryCheck() {
if (!_optionsFlag) {
if (_mouseFlag == 1 || _mouseFlag == 2) {
if (_mainHero->_visible) {
if (!_flags->getFlagValue(Flags::INVALLOWED)) {
// 29 - Basement, 50 - Map
if (_locationNr != 29 && _locationNr != 50) {
Common::Point mousePos = _system->getEventManager()->getMousePos();
if (mousePos.y < 4 && !_showInventoryFlag) {
_invCounter++;
} else {
_invCounter = 0;
}
if (_invCounter >= _invMaxCount) {
inventoryFlagChange(true);
}
}
}
}
}
}
}

void PrinceEngine::mainLoop() {

changeCursor(0);
Expand All @@ -4393,64 +4416,35 @@ void PrinceEngine::mainLoop() {
case Common::EVENT_KEYDOWN:
keyHandler(event);
break;
case Common::EVENT_KEYUP:
break;
case Common::EVENT_MOUSEMOVE:
break;
case Common::EVENT_LBUTTONDOWN:
leftMouseButton();
break;
case Common::EVENT_RBUTTONDOWN:
rightMouseButton();
break;
case Common::EVENT_LBUTTONUP:
break;
case Common::EVENT_RBUTTONUP:
break;
case Common::EVENT_QUIT:
break;
default:
break;
}
}

if (shouldQuit())
if (shouldQuit()) {
return;
}

_interpreter->step();

drawScreen();

_graph->update(_graph->_frontScreen);

openInventoryCheck();

// Calculate the frame delay based off a desired frame time
int delay = 1000 / 15 - int32(_system->getMillis() - currentTime);
// Ensure non-negative
delay = delay < 0 ? 0 : delay;
_system->delayMillis(delay);

_frameNr++;

// inventory turning on:
if (!_optionsFlag) {
if (_mouseFlag == 1 || _mouseFlag == 2) {
if (_mainHero->_visible) {
if (!_flags->getFlagValue(Flags::INVALLOWED)) {
// 29 - Basement, 50 - Map
if (_locationNr != 29 && _locationNr != 50) {
Common::Point mousePos = _system->getEventManager()->getMousePos();
if (mousePos.y < 4 && !_showInventoryFlag) {
_invCounter++;
} else {
_invCounter = 0;
}
if (_invCounter >= _invMaxCount) {
inventoryFlagChange(true);
}
}
}
}
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion engines/prince/prince.h
Expand Up @@ -306,7 +306,6 @@ class PrinceEngine : public Engine {
static const uint8 kMaxTexts = 32;
Text _textSlots[kMaxTexts];

uint64 _frameNr;
Hero *_mainHero;
Hero *_secondHero;

Expand Down Expand Up @@ -439,6 +438,7 @@ class PrinceEngine : public Engine {
void enableOptions(bool checkType);
void checkOptions();
void checkInvOptions();
void openInventoryCheck();

void leftMouseButton();
void rightMouseButton();
Expand Down
2 changes: 1 addition & 1 deletion engines/prince/script.cpp
Expand Up @@ -426,7 +426,7 @@ void Interpreter::debugInterpreter(const char *s, ...) {
if (!strcmp(_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);
//debug("Prince::Script mode %s %s %s", _mode, str.c_str(), buf);
}

void Interpreter::step() {
Expand Down

0 comments on commit 54a78d6

Please sign in to comment.