Skip to content

Commit

Permalink
PRINCE: hotspot() - name of mobs in wider locations fix, clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaslw committed Jun 22, 2014
1 parent 854de58 commit c61ccb0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 33 deletions.
2 changes: 1 addition & 1 deletion engines/prince/graphics.cpp
Expand Up @@ -116,7 +116,7 @@ void GraphicsMan::drawMask(Graphics::Surface *frontScreen, DrawNode *drawNode) {
if ((drawNode->data[tempMaskPostion] & maskCounter) != 0) {
byte orgPixel = *((byte*)drawNode->originalRoomSurface->getBasePtr(x + drawNode->posX, y + drawNode->posY));
*((byte*)frontScreen->getBasePtr(x + drawNode->posX, y + drawNode->posY)) = orgPixel;
//*((byte*)frontScreen->getBasePtr(x + posX, y + posY)) = 0; // for debugging
//*((byte*)frontScreen->getBasePtr(x + drawNode->posX, y + drawNode->posY)) = 0; // for debugging
}
}
}
Expand Down
33 changes: 5 additions & 28 deletions engines/prince/prince.cpp
Expand Up @@ -77,7 +77,7 @@ void PrinceEngine::debugEngine(const char *s, ...) {
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), testAnimNr(0), testAnimFrame(0),
_cameraX(0), _newCameraX(0), _frameNr(0), _cursor1(nullptr), _cursor2(nullptr), _font(nullptr),
_frameNr(0), _cursor1(nullptr), _cursor2(nullptr), _font(nullptr),
_suitcaseBmp(nullptr), _roomBmp(nullptr), _cursorNr(0), _picWindowX(0), _picWindowY(0), _randomSource("prince") {

// Debug/console setup
Expand Down Expand Up @@ -279,9 +279,7 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {

_locationNr = locationNr;
_debugger->_locationNr = locationNr;
_cameraX = 0;
_newCameraX = 0;


_flags->setFlagValue(Flags::CURRROOM, _locationNr);
_interpreter->stopBg();

Expand Down Expand Up @@ -544,24 +542,6 @@ bool PrinceEngine::loadShadow(byte *shadowBitmap, uint32 dataSize, const char *r
return true;
}

void PrinceEngine::scrollCameraLeft(int16 delta) {
if (_newCameraX > 0) {
if (_newCameraX < delta)
_newCameraX = 0;
else
_newCameraX -= delta;
}
}

void PrinceEngine::scrollCameraRight(int16 delta) {
if (_newCameraX != _sceneWidth - 640) {
if (_sceneWidth - 640 < delta + _newCameraX)
delta += (_sceneWidth - 640) - (delta + _newCameraX);
_newCameraX += delta;
debugEngine("PrinceEngine::scrollCameraRight() _newCameraX = %d; delta = %d", _newCameraX, delta);
}
}

void PrinceEngine::keyHandler(Common::Event event) {
uint16 nChar = event.kbd.keycode;
switch (nChar) {
Expand All @@ -571,14 +551,12 @@ void PrinceEngine::keyHandler(Common::Event event) {
}
break;
case Common::KEYCODE_LEFT:
scrollCameraLeft(32);
if(testAnimNr > 0) {
testAnimNr--;
}
debug("testAnimNr: %d", testAnimNr);
break;
case Common::KEYCODE_RIGHT:
scrollCameraRight(32);
testAnimNr++;
debug("testAnimNr: %d", testAnimNr);
break;
Expand Down Expand Up @@ -652,7 +630,7 @@ void PrinceEngine::keyHandler(Common::Event event) {

void PrinceEngine::hotspot() {
Common::Point mousepos = _system->getEventManager()->getMousePos();
Common::Point mousePosCamera(mousepos.x + _cameraX, mousepos.y);
Common::Point mousePosCamera(mousepos.x + _picWindowX, mousepos.y);

for (Common::Array<Mob>::const_iterator it = _mobList.begin(); it != _mobList.end() ; it++) {
const Mob& mob = *it;
Expand Down Expand Up @@ -1272,9 +1250,8 @@ void PrinceEngine::mainLoop() {
// Ensure non-negative
delay = delay < 0 ? 0 : delay;
_system->delayMillis(delay);

_cameraX = _newCameraX;
++_frameNr;

_frameNr++;

if (_debugger->_locationNr != _locationNr)
loadLocation(_debugger->_locationNr);
Expand Down
4 changes: 0 additions & 4 deletions engines/prince/prince.h
Expand Up @@ -245,8 +245,6 @@ class PrinceEngine : public Engine {
Hero *_mainHero;
Hero *_secondHero;

uint16 _cameraX;
uint16 _newCameraX;
uint16 _sceneWidth;
int32 _picWindowX;
int32 _picWindowY;
Expand Down Expand Up @@ -274,8 +272,6 @@ class PrinceEngine : public Engine {
bool playNextFrame();
void keyHandler(Common::Event event);
void hotspot();
void scrollCameraRight(int16 delta);
void scrollCameraLeft(int16 delta);
void drawScreen();
void showTexts();
void init();
Expand Down

0 comments on commit c61ccb0

Please sign in to comment.