implemented drawing of additional scrolling frames

svn-id: r12223
This commit is contained in:
Robert Göffringmann 2004-01-07 19:08:59 +00:00
parent 821bbed1e0
commit 63fbde359a
3 changed files with 38 additions and 7 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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)) {