aboutsummaryrefslogtreecommitdiff
path: root/sword1
diff options
context:
space:
mode:
authorRobert Göffringmann2004-01-07 19:08:59 +0000
committerRobert Göffringmann2004-01-07 19:08:59 +0000
commit63fbde359adfae8a545977f7a5092216b696368a (patch)
treedf1cc6c0a7eee7facb37a23e3234eea5e5a6b796 /sword1
parent821bbed1e052205746d9bc2118120a7d31a2a2a1 (diff)
downloadscummvm-rg350-63fbde359adfae8a545977f7a5092216b696368a.tar.gz
scummvm-rg350-63fbde359adfae8a545977f7a5092216b696368a.tar.bz2
scummvm-rg350-63fbde359adfae8a545977f7a5092216b696368a.zip
implemented drawing of additional scrolling frames
svn-id: r12223
Diffstat (limited to 'sword1')
-rw-r--r--sword1/screen.cpp19
-rw-r--r--sword1/screen.h1
-rw-r--r--sword1/sword1.cpp25
3 files changed, 38 insertions, 7 deletions
diff --git a/sword1/screen.cpp b/sword1/screen.cpp
index ce80b3298c..2f3915ba19 100644
--- a/sword1/screen.cpp
+++ b/sword1/screen.cpp
@@ -119,6 +119,21 @@ bool SwordScreen::stillFading(void) {
return (_fadingStep != 0);
}
+bool SwordScreen::showScrollFrame(void) {
+ if ((!_fullRefresh) || SwordLogic::_scriptVars[NEW_PALETTE] || (!SwordLogic::_scriptVars[SCROLL_FLAG]))
+ return false; // don't draw an additional frame if we aren't scrolling or have to change the palette
+ if ((_oldScrollX == SwordLogic::_scriptVars[SCROLL_OFFSET_X]) &&
+ (_oldScrollY == SwordLogic::_scriptVars[SCROLL_OFFSET_Y]))
+ return false; // check again if we *really* are scrolling.
+
+ uint16 avgScrlX = (uint16)(_oldScrollX + SwordLogic::_scriptVars[SCROLL_OFFSET_X]) / 2;
+ uint16 avgScrlY = (uint16)(_oldScrollY + SwordLogic::_scriptVars[SCROLL_OFFSET_Y]) / 2;
+
+ _system->copy_rect(_screenBuf + avgScrlY * _scrnSizeX + avgScrlX, _scrnSizeX, 0, 40, SCREEN_WIDTH, SCREEN_DEPTH);
+ _system->update_screen();
+ return true;
+}
+
void SwordScreen::updateScreen(void) {
if (SwordLogic::_scriptVars[NEW_PALETTE]) {
_fadingStep = 1;
@@ -653,7 +668,9 @@ void SwordScreen::decompressRLE0(uint8 *src, uint32 compSize, uint8 *dest) {
void SwordScreen::fadePalette(void) {
if (_fadingStep == 16)
memcpy(_currentPalette, _targetPalette, 256 * 4);
- else
+ else if ((_fadingStep == 1) && (_fadingDirection == FADE_DOWN)) {
+ memset(_currentPalette, 0, 4 * 256);
+ } else
for (uint16 cnt = 0; cnt < 256 * 4; cnt++)
_currentPalette[cnt] = (_targetPalette[cnt] * _fadingStep) >> 4;
diff --git a/sword1/screen.h b/sword1/screen.h
index 8abe94a95b..741eb4992f 100644
--- a/sword1/screen.h
+++ b/sword1/screen.h
@@ -80,6 +80,7 @@ public:
bool stillFading(void);
void fullRefresh(void);
+ bool showScrollFrame(void);
void updateScreen(void);
void showFrame(uint16 x, uint16 y, uint32 resId, uint32 frameNo, const byte *fadeMask = NULL, int8 fadeStatus = 0);
diff --git a/sword1/sword1.cpp b/sword1/sword1.cpp
index ce2d9db887..6adba5702d 100644
--- a/sword1/sword1.cpp
+++ b/sword1/sword1.cpp
@@ -1119,6 +1119,7 @@ void SwordEngine::checkCd(void) {
uint8 SwordEngine::mainLoop(void) {
uint8 retCode = 0;
+ _keyPressed = 0;
while (retCode == 0) {
// do we need the section45-hack from sword.c here?
@@ -1130,6 +1131,9 @@ uint8 SwordEngine::mainLoop(void) {
SwordLogic::_scriptVars[SCREEN] = SwordLogic::_scriptVars[NEW_SCREEN];
do {
+ uint32 newTime;
+ bool scrollFrameShown = false;
+
uint32 frameTime = _system->get_msecs();
_logic->engine();
_logic->updateScreenParams(); // sets scrolling
@@ -1138,15 +1142,24 @@ uint8 SwordEngine::mainLoop(void) {
_mouse->animate();
_sound->engine();
- _screen->updateScreen();
-
_menu->refresh(MENU_TOP);
_menu->refresh(MENU_BOT);
- uint32 newTime = _system->get_msecs();
+ newTime = _system->get_msecs();
+ if (newTime - frameTime < 1000 / FRAME_RATE) {
+ scrollFrameShown = _screen->showScrollFrame();
+ int32 restDelay = (1000 / (FRAME_RATE * 2)) - (_system->get_msecs() - frameTime);
+ if (restDelay > 0)
+ delay((uint)restDelay);
+ }
- if (newTime - frameTime < 80)
- delay(80 - (newTime - frameTime));
+ newTime = _system->get_msecs();
+ if ((newTime - frameTime < 1000 / FRAME_RATE) || (!scrollFrameShown))
+ _screen->updateScreen();
+
+ int32 frameDelay = (1000 / FRAME_RATE) - (_system->get_msecs() - frameTime);
+ if (frameDelay > 0)
+ delay((uint)frameDelay);
else
delay(0);
@@ -1160,6 +1173,7 @@ uint8 SwordEngine::mainLoop(void) {
if (!retCode)
_screen->fullRefresh();
}
+ _keyPressed = 0;
// do something smart here to implement pausing the game. If we even want that, that is.
} while ((SwordLogic::_scriptVars[SCREEN] == SwordLogic::_scriptVars[NEW_SCREEN]) && (retCode == 0));
@@ -1185,7 +1199,6 @@ void SwordEngine::delay(uint amount) { //copied and mutilated from sky.cpp
uint32 start = _system->get_msecs();
uint32 cur = start;
- _keyPressed = 0;
do {
while (_system->poll_event(&event)) {