Skip to content

Commit

Permalink
SHERLOCK: Implement remainder of RT doBgAnim
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed May 31, 2015
1 parent 1302644 commit 45c9b42
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 6 deletions.
4 changes: 4 additions & 0 deletions engines/sherlock/objects.cpp
Expand Up @@ -364,6 +364,10 @@ void Sprite::checkSprite() {
}
}

const Common::Rect Sprite::getOldBounds() const {
return Common::Rect(_oldPosition.x, _oldPosition.y, _oldPosition.x + _oldSize.x, _oldPosition.y + _oldSize.y);
}

/*----------------------------------------------------------------*/

void WalkSequence::load(Common::SeekableReadStream &s) {
Expand Down
5 changes: 5 additions & 0 deletions engines/sherlock/objects.h
Expand Up @@ -242,6 +242,11 @@ class Sprite {
* Return frame height
*/
int frameHeight() const { return _imageFrame ? _imageFrame->_frame.h : 0; }

/**
* Returns the old bounsd for the sprite from the previous frame
*/
const Common::Rect getOldBounds() const;
};

enum { OBJ_BEHIND = 1, OBJ_FLIPPED = 2, OBJ_FORWARD = 4, TURNON_OBJ = 0x20, TURNOFF_OBJ = 0x40 };
Expand Down
4 changes: 4 additions & 0 deletions engines/sherlock/people.cpp
Expand Up @@ -79,6 +79,10 @@ void Person::clearNPC() {
_npcName = "";
}

void Person::updateNPC() {
// TODO
}

/*----------------------------------------------------------------*/

People::People(SherlockEngine *vm) : _vm(vm), _player(_data[0]) {
Expand Down
6 changes: 6 additions & 0 deletions engines/sherlock/people.h
Expand Up @@ -76,6 +76,7 @@ class Person : public Sprite {
Common::String _npcName;
int _tempX;
int _tempScaleVal;
bool _updateNPCPath;

// Rose Tattoo fields
Common::String _walkVGSName; // Name of walk library person is using
Expand All @@ -86,6 +87,11 @@ class Person : public Sprite {
* Clear the NPC related data
*/
void clearNPC();

/**
* Update the NPC
*/
void updateNPC();
};

class SherlockEngine;
Expand Down
12 changes: 12 additions & 0 deletions engines/sherlock/screen.cpp
Expand Up @@ -306,6 +306,18 @@ void Screen::flushScaleImage(ImageFrame *frame, const Common::Point &pt, int16 *
*height = newBounds.height();
}

void Screen::flushImage(ImageFrame *frame, const Common::Point &pt, Common::Rect &newBounds, int scaleVal) {
Common::Point newPos, newSize;

if (scaleVal == 256)
flushImage(frame, pt, &newPos.x, &newPos.y, &newSize.x, &newSize.y);
else
flushScaleImage(frame, pt, &newPos.x, &newPos.y, &newSize.x, &newSize.y, scaleVal);

// Transfer the pos and size amounts into a single bounds rect
newBounds = Common::Rect(newPos.x, newPos.y, newPos.x + newSize.x, newPos.y + newSize.y);
}

void Screen::blockMove(const Common::Rect &r, const Common::Point &scrollPos) {
Common::Rect bounds = r;
bounds.translate(scrollPos.x, scrollPos.y);
Expand Down
5 changes: 5 additions & 0 deletions engines/sherlock/screen.h
Expand Up @@ -189,6 +189,11 @@ class Screen : public Surface {
void flushScaleImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, int16 *yp,
int16 *width, int16 *height, int scaleVal);

/**
* Variation of flushImage/flushScaleImage that takes in and updates a rect
*/
void flushImage(ImageFrame *frame, const Common::Point &pt, Common::Rect &newBounds, int scaleVal);

/**
* Copies data from the back buffer to the screen, taking into account scrolling position
*/
Expand Down
1 change: 1 addition & 0 deletions engines/sherlock/sherlock.cpp
Expand Up @@ -50,6 +50,7 @@ SherlockEngine::SherlockEngine(OSystem *syst, const SherlockGameDescription *gam
_canLoadSave = false;
_showOriginalSavesDialog = false;
_interactiveFl = true;
_fastMode = false;
}

SherlockEngine::~SherlockEngine() {
Expand Down
1 change: 1 addition & 0 deletions engines/sherlock/sherlock.h
Expand Up @@ -123,6 +123,7 @@ class SherlockEngine : public Engine {
bool _canLoadSave;
bool _showOriginalSavesDialog;
bool _interactiveFl;
bool _fastMode;
public:
SherlockEngine(OSystem *syst, const SherlockGameDescription *gameDesc);
virtual ~SherlockEngine();
Expand Down
4 changes: 4 additions & 0 deletions engines/sherlock/tattoo/tattoo.cpp
Expand Up @@ -72,6 +72,10 @@ void TattooEngine::drawCredits() {
// TODO
}

void TattooEngine::blitCredits() {
// TODO
}

void TattooEngine::eraseCredits() {
// TODO
}
Expand Down
5 changes: 5 additions & 0 deletions engines/sherlock/tattoo/tattoo.h
Expand Up @@ -58,6 +58,11 @@ class TattooEngine : public SherlockEngine {
*/
void drawCredits();

/**
* Blit the drawn credits to the screen
*/
void blitCredits();

/**
* Erase any area of the screen covered by credits
*/
Expand Down
105 changes: 99 additions & 6 deletions engines/sherlock/tattoo/tattoo_scene.cpp
Expand Up @@ -196,15 +196,15 @@ void TattooScene::doBgAnimEraseBackground() {
}

void TattooScene::doBgAnim() {
TattooEngine &vm = *(TattooEngine *)_vm;
Events &events = *_vm->_events;
People &people = *_vm->_people;
Screen &screen = *_vm->_screen;
Talk &talk = *_vm->_talk;
TattooUserInterface &ui = *((TattooUserInterface *)_vm->_ui);

doBgAnimCheckCursor();

// Events &events = *_vm->_events;
People &people = *_vm->_people;
// Scene &scene = *_vm->_scene;
Screen &screen = *_vm->_screen;
Talk &talk = *_vm->_talk;

screen.setDisplayBounds(Common::Rect(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCENE_HEIGHT));
talk._talkToAbort = false;
Expand All @@ -226,6 +226,23 @@ void TattooScene::doBgAnim() {
doBgAnimUpdateBgObjectsAndAnim();

ui.drawInterface();

doBgAnimDrawSprites();

if (vm._creditsActive)
vm.blitCredits();

if (!vm._fastMode)
events.wait(3);

screen._flushScreen = false;
_doBgAnimDone = false;
ui._drawMenu = false;

for (uint idx = 1; idx < MAX_CHARACTERS; ++idx) {
if (people[idx]._updateNPCPath)
people[idx].updateNPC();
}
}

void TattooScene::doBgAnimUpdateBgObjectsAndAnim() {
Expand Down Expand Up @@ -288,7 +305,6 @@ void TattooScene::doBgAnimUpdateBgObjectsAndAnim() {
}
}


void TattooScene::updateBackground() {
People &people = *_vm->_people;
Screen &screen = *_vm->_screen;
Expand Down Expand Up @@ -397,6 +413,83 @@ void TattooScene::updateBackground() {
screen._flushScreen = false;
}

void TattooScene::doBgAnimDrawSprites() {
People &people = *_vm->_people;
Screen &screen = *_vm->_screen;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;

for (uint idx = 0; idx < MAX_CHARACTERS; ++idx) {
Person &person = people[idx];

if (person._type != INVALID) {
if (_goToScene == -1 || _cAnim.size() == 0) {
if (person._type == REMOVE) {
screen.slamRect(person.getOldBounds());
person._type = INVALID;
} else {
if (person._tempScaleVal == 256) {
screen.flushImage(person._imageFrame, Common::Point(person._tempX, person._position.y / FIXED_INT_MULTIPLIER
- person.frameHeight()), &person._oldPosition.x, &person._oldPosition.y, &person._oldSize.x, &person._oldSize.y);
} else {
int ts = person._imageFrame->sDrawYSize(person._tempScaleVal);
int ty = person._position.y / FIXED_INT_MULTIPLIER - ts;
screen.flushScaleImage(person._imageFrame, Common::Point(person._tempX, ty),
&person._oldPosition.x, &person._oldPosition.y, &person._oldSize.x, &person._oldSize.y, person._tempScaleVal);
}
}
}
}
}

for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
Object &obj = _bgShapes[idx];

if (obj._type == ACTIVE_BG_SHAPE || obj._type == REMOVE) {
if (_goToScene == -1) {
if (obj._scaleVal == 256)
screen.flushImage(obj._imageFrame, obj._position, &obj._oldPosition.x, &obj._oldPosition.y,
&obj._oldSize.x, &obj._oldSize.y);
else
screen.flushScaleImage(obj._imageFrame, obj._position, &obj._oldPosition.x, &obj._oldPosition.y,
&obj._oldSize.x, &obj._oldSize.y, obj._scaleVal);

if (obj._type == REMOVE)
obj._type = INVALID;
}
}
}

for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
Object &obj = _bgShapes[idx];

if (_goToScene == -1) {
if (obj._type == NO_SHAPE && (obj._flags & 1) == 0) {
screen.slamRect(obj.getNoShapeBounds());
screen.slamRect(obj.getOldBounds());
} else if (obj._type == HIDE_SHAPE) {
if (obj._scaleVal == 256)
screen.flushImage(obj._imageFrame, obj._position, &obj._oldPosition.x, &obj._oldPosition.y,
&obj._oldSize.x, &obj._oldSize.y);
else
screen.flushScaleImage(obj._imageFrame, obj._position, &obj._oldPosition.x, &obj._oldPosition.y,
&obj._oldSize.x, &obj._oldSize.y, obj._scaleVal);
obj._type = HIDDEN;
}
}
}

if (_activeCAnim._images != nullptr || _activeCAnim._zPlacement == REMOVE) {
if (_activeCAnim._zPlacement != REMOVE) {
screen.flushImage(_activeCAnim._imageFrame, _activeCAnim._position, _activeCAnim._oldBounds, _activeCAnim._scaleVal);
} else {
screen.slamArea(_activeCAnim._removeBounds.left - ui._currentScroll.x, _activeCAnim._removeBounds.top,
_activeCAnim._removeBounds.width(), _activeCAnim._removeBounds.height());
_activeCAnim._removeBounds.left = _activeCAnim._removeBounds.top = 0;
_activeCAnim._removeBounds.right = _activeCAnim._removeBounds.bottom = 0;
_activeCAnim._zPlacement = -1; // Reset _zPlacement so we don't REMOVE again
}
}
}

} // End of namespace Tattoo

Expand Down
2 changes: 2 additions & 0 deletions engines/sherlock/tattoo/tattoo_scene.h
Expand Up @@ -44,6 +44,8 @@ class TattooScene : public Scene {
* Update the background objects and canimations as part of doBgAnim
*/
void doBgAnimUpdateBgObjectsAndAnim();

void doBgAnimDrawSprites();
protected:
/**
* Checks all the background shapes. If a background shape is animating,
Expand Down
1 change: 1 addition & 0 deletions engines/sherlock/tattoo/tattoo_user_interface.cpp
Expand Up @@ -34,6 +34,7 @@ TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm)
_tagBuffer = nullptr;
_invGraphic = nullptr;
_scrollSize = _scrollSpeed = 0;
_drawMenu = false;
}

void TattooUserInterface::initScrollVars() {
Expand Down
1 change: 1 addition & 0 deletions engines/sherlock/tattoo/tattoo_user_interface.h
Expand Up @@ -53,6 +53,7 @@ class TattooUserInterface : public UserInterface {
public:
Common::Point _currentScroll, _targetScroll;
int _scrollSize, _scrollSpeed;
bool _drawMenu;
public:
TattooUserInterface(SherlockEngine *vm);

Expand Down

0 comments on commit 45c9b42

Please sign in to comment.