mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 14:18:37 +00:00
MADS: Implement screen shaking
This commit is contained in:
parent
0d54216beb
commit
786c771bb8
@ -495,6 +495,7 @@ void Game::loadGame(int slotNumber) {
|
||||
_scene._currentSceneId = -2;
|
||||
_sectionNumber = _scene._nextSceneId / 100;
|
||||
_scene._frameStartTime = _vm->_events->getFrameCounter();
|
||||
_vm->_screen._shakeCountdown = -1;
|
||||
|
||||
// Default the selected inventory item to the first one, if the player has any
|
||||
_scene._userInterface._selectedInvIndex = _objects._inventoryList.size() > 0 ? 0 : -1;
|
||||
|
@ -2800,7 +2800,7 @@ void Scene318::step() {
|
||||
|
||||
if (_internCounter >= 3600) {
|
||||
_vm->_sound->command(59);
|
||||
warning("TODO: shake_countdown = 20;");
|
||||
_vm->_screen._shakeCountdown = 20;
|
||||
_internWalkingFl = true;
|
||||
}
|
||||
}
|
||||
@ -3270,22 +3270,22 @@ void Scene319::step() {
|
||||
|
||||
if (_animMode == 2) {
|
||||
if (_animFrame == 13)
|
||||
warning("TODO: shake_countdown = 40;");
|
||||
_vm->_screen._shakeCountdown = 40;
|
||||
|
||||
if (_animFrame == 16)
|
||||
warning("TODO: shake_countdown = 1;");
|
||||
_vm->_screen._shakeCountdown = 1;
|
||||
}
|
||||
|
||||
if (_animMode == 3) {
|
||||
if (_animFrame == 11)
|
||||
warning("TODO: shake_countdown = 60;");
|
||||
_vm->_screen._shakeCountdown = 60;
|
||||
|
||||
if (_animFrame == 18)
|
||||
warning("TODO: shake_countdown = 1;");
|
||||
_vm->_screen._shakeCountdown = 1;
|
||||
}
|
||||
|
||||
if ((_animMode == 4) && (_animFrame == 16))
|
||||
warning("TODO: shake_countdown = 80;");
|
||||
_vm->_screen._shakeCountdown = 80;
|
||||
|
||||
if ((nextFrame >= 0) && (nextFrame != _scene->_activeAnimation->getCurrentFrame())) {
|
||||
_scene->_activeAnimation->setCurrentFrame(nextFrame);
|
||||
@ -3308,7 +3308,7 @@ void Scene319::step() {
|
||||
|
||||
_animFrame = _scene->_activeAnimation->getCurrentFrame();
|
||||
_slacheTalkingFl = true;
|
||||
warning("TODO: shake_countdown = 1;");
|
||||
_vm->_screen._shakeCountdown = 1;
|
||||
|
||||
for (int i = 0; i <= 1; i++) {
|
||||
int oldIdx = _globals._sequenceIndexes[i];
|
||||
@ -3325,7 +3325,7 @@ void Scene319::step() {
|
||||
_vm->_palette->setColorValues(0, 0, 0);
|
||||
_vm->_palette->fadeOut(_vm->_palette->_mainPalette, nullptr, 18, 228,
|
||||
248, 0, 1, 16);
|
||||
warning("TODO: shake_countdown = 1;");
|
||||
_vm->_screen._shakeCountdown = 1;
|
||||
_scene->_reloadSceneFlag = true;
|
||||
break;
|
||||
|
||||
@ -3706,7 +3706,7 @@ void Scene320::step() {
|
||||
|
||||
case 417:
|
||||
case 457:
|
||||
warning("TODO: shake_countdown = 40;");
|
||||
_vm->_screen._shakeCountdown = 40;
|
||||
_vm->_sound->command(59);
|
||||
break;
|
||||
|
||||
|
@ -545,6 +545,8 @@ void ScreenObjects::synchronize(Common::Serializer &s) {
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
ScreenSurface::ScreenSurface() {
|
||||
_shakeCountdown = -1;
|
||||
_random = 0x4D2;
|
||||
}
|
||||
|
||||
void ScreenSurface::init() {
|
||||
@ -553,7 +555,7 @@ void ScreenSurface::init() {
|
||||
|
||||
void ScreenSurface::copyRectToScreen(const Common::Point &destPos,
|
||||
const Common::Rect &bounds) {
|
||||
byte *buf = getBasePtr(destPos.x, destPos.y);
|
||||
const byte *buf = getBasePtr(destPos.x, destPos.y);
|
||||
|
||||
if (bounds.width() != 0 && bounds.height() != 0)
|
||||
g_system->copyRectToScreen(buf, this->pitch, bounds.left, bounds.top,
|
||||
@ -564,8 +566,25 @@ void ScreenSurface::copyRectToScreen(const Common::Rect &bounds) {
|
||||
copyRectToScreen(Common::Point(bounds.left, bounds.top), bounds);
|
||||
}
|
||||
|
||||
|
||||
void ScreenSurface::updateScreen() {
|
||||
if (_shakeCountdown >= 0) {
|
||||
_random = _random * 5 + 1;
|
||||
int offset = (_random >> 8) & 3;
|
||||
if (_shakeCountdown-- <= 0)
|
||||
offset = 0;
|
||||
|
||||
// Copy the screen with the left hand hide side of the screen of a given
|
||||
// offset width shown at the very right. The offset changes to give
|
||||
// an effect of shaking the screen
|
||||
offset *= 4;
|
||||
const byte *buf = getBasePtr(offset, 0);
|
||||
g_system->copyRectToScreen(buf, this->pitch, 0, 0,
|
||||
this->pitch - offset, this->h);
|
||||
if (offset > 0)
|
||||
g_system->copyRectToScreen(this->pixels, this->pitch,
|
||||
this->pitch - offset, 0, offset, this->h);
|
||||
}
|
||||
|
||||
g_system->updateScreen();
|
||||
}
|
||||
|
||||
|
@ -197,8 +197,11 @@ public:
|
||||
};
|
||||
|
||||
class ScreenSurface : public MSurface {
|
||||
private:
|
||||
uint16 _random;
|
||||
public:
|
||||
Common::Point _offset;
|
||||
int _shakeCountdown;
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
|
Loading…
Reference in New Issue
Block a user