diff options
author | Robert Göffringmann | 2003-12-17 07:33:00 +0000 |
---|---|---|
committer | Robert Göffringmann | 2003-12-17 07:33:00 +0000 |
commit | 5fdff2824c7cf45edb0dc2fb6f0bdbe150e3a20f (patch) | |
tree | 040ef276db16211eab69244552e171ff1d612909 /sword1 | |
parent | 4077b92c0263760643f81253ed06a24c5c488225 (diff) | |
download | scummvm-rg350-5fdff2824c7cf45edb0dc2fb6f0bdbe150e3a20f.tar.gz scummvm-rg350-5fdff2824c7cf45edb0dc2fb6f0bdbe150e3a20f.tar.bz2 scummvm-rg350-5fdff2824c7cf45edb0dc2fb6f0bdbe150e3a20f.zip |
fixed text output and logic bug. changed scrolling code.
hey, sword is running really nice already. :)
svn-id: r11703
Diffstat (limited to 'sword1')
-rw-r--r-- | sword1/logic.cpp | 12 | ||||
-rw-r--r-- | sword1/menu.cpp | 10 | ||||
-rw-r--r-- | sword1/mouse.cpp | 19 | ||||
-rw-r--r-- | sword1/screen.cpp | 43 | ||||
-rw-r--r-- | sword1/screen.h | 2 | ||||
-rw-r--r-- | sword1/sound.h | 2 | ||||
-rw-r--r-- | sword1/sword1.cpp | 4 |
7 files changed, 43 insertions, 49 deletions
diff --git a/sword1/logic.cpp b/sword1/logic.cpp index 360d9e0f21..17e123472e 100644 --- a/sword1/logic.cpp +++ b/sword1/logic.cpp @@ -91,6 +91,7 @@ void SwordLogic::newScreen(uint32 screen) { } void SwordLogic::engine(void) { + debug(5, "\n\nNext logic cycle"); _eventMan->serviceGlobalEventList(); for (uint16 sectCnt = 0; sectCnt < TOTAL_SECTIONS; sectCnt++) { @@ -862,7 +863,7 @@ int SwordLogic::fnFadeUp(BsObject *cpt, int32 id, int32 speed, int32 d, int32 e, int SwordLogic::fnCheckFade(BsObject *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x) { - _scriptVars[RETURN_VALUE] = (uint8)_screen->stillFading(); + _scriptVars[RETURN_VALUE] = (uint8)(!_screen->stillFading()); return SCRIPT_CONT; } @@ -1083,12 +1084,13 @@ int SwordLogic::fnISpeak(BsObject *cpt, int32 id, int32 cdt, int32 textNo, int32 _objMan->unlockText(textNo); BsObject * textCpt = _objMan->fetchObject(textCptId); + textCpt->o_screen = cpt->o_screen; + textCpt->o_target = textCptId; // the graphic is a property of SwordText, so we don't lock/unlock it. - uint16 textSpriteWidth = _textMan->giveSpriteData(cpt->o_target)->width; - uint16 textSpriteHeight = _textMan->giveSpriteData(cpt->o_target)->height; + uint16 textSpriteWidth = _textMan->giveSpriteData(textCpt->o_target)->width; + uint16 textSpriteHeight = _textMan->giveSpriteData(textCpt->o_target)->height; - textCpt->o_screen = cpt->o_screen; cpt->o_text_id = textCptId; // now set text coords, above the player, usually @@ -1096,7 +1098,7 @@ int SwordLogic::fnISpeak(BsObject *cpt, int32 id, int32 cdt, int32 textNo, int32 #define TEXT_MARGIN 3 // distance kept from edges of screen #define ABOVE_HEAD 20 // distance kept above talking sprite uint16 textX, textY; - if ((id == GEORGE) || ((id == NICO) && (_scriptVars[SCREEN] == 10)) && (!cpt->o_anim_resource)) { + if (((id == GEORGE) || ((id == NICO) && (_scriptVars[SCREEN] == 10))) && (!cpt->o_anim_resource)) { // if George is doing Voice-Over text (centered at the bottom of the screen) textX = _scriptVars[SCROLL_OFFSET_X] + 128 + (640 / 2) - textSpriteWidth / 2; textY = _scriptVars[SCROLL_OFFSET_Y] + 128 + 400; diff --git a/sword1/menu.cpp b/sword1/menu.cpp index bbe993201d..ba44bc4577 100644 --- a/sword1/menu.cpp +++ b/sword1/menu.cpp @@ -213,13 +213,15 @@ void SwordMenu::checkTopMenu(void) { } int SwordMenu::logicChooser(BsObject *compact) { + uint8 objSelected = 0; if (_objectBarShown) - uint8 objSelected = checkMenuClick(MENU_TOP); - if (checkMenuClick(MENU_BOT)) { + objSelected = checkMenuClick(MENU_TOP); + if (!objSelected) + objSelected = checkMenuClick(MENU_BOT); + if (objSelected) { compact->o_logic = LOGIC_script; return 1; - } else - return 0; + } return 0; } diff --git a/sword1/mouse.cpp b/sword1/mouse.cpp index 6b243bd5b8..895edc5e33 100644 --- a/sword1/mouse.cpp +++ b/sword1/mouse.cpp @@ -110,13 +110,18 @@ void SwordMouse::engine(uint16 x, uint16 y, uint16 eventFlags) { _numObjs = 0; return; // no human, so we don't want the mouse engine } - - if (y < 40) { // okay, we are in the top menu. - if (!_inTopMenu) // are we just entering it? - _menu->fnStartMenu(); - _menu->checkTopMenu(); - _inTopMenu = true; - } else if (_inTopMenu) { // we're not in the menu. did we just leave it? + + if (!SwordLogic::_scriptVars[TOP_MENU_DISABLED]) { + if (y < 40) { // okay, we are in the top menu. + if (!_inTopMenu) // are we just entering it? + _menu->fnStartMenu(); + _menu->checkTopMenu(); + _inTopMenu = true; + } else if (_inTopMenu) { // we're not in the menu. did we just leave it? + _menu->fnEndMenu(); + _inTopMenu = false; + } + } else if (_inTopMenu) { _menu->fnEndMenu(); _inTopMenu = false; } diff --git a/sword1/screen.cpp b/sword1/screen.cpp index bc0811258e..c4154dae17 100644 --- a/sword1/screen.cpp +++ b/sword1/screen.cpp @@ -57,36 +57,17 @@ void SwordScreen::setScrolling(int16 offsetX, int16 offsetY) { if (!SwordLogic::_scriptVars[SCROLL_FLAG]) return ; // screen is smaller than 640x400 => no need for scrolling - int32 dx, dy; - uint32 scrlDistX, scrlDistY; uint32 scrlToX, scrlToY; offsetX = inRange(0, offsetX, SwordLogic::_scriptVars[MAX_SCROLL_OFFSET_X]); offsetY = inRange(0, offsetY, SwordLogic::_scriptVars[MAX_SCROLL_OFFSET_Y]); _oldScrollX = SwordLogic::_scriptVars[SCROLL_OFFSET_X]; _oldScrollY = SwordLogic::_scriptVars[SCROLL_OFFSET_Y]; + scrlToX = (uint32)offsetX; + scrlToY = (uint32)offsetY; - if (SwordLogic::_scriptVars[SCROLL_FLAG] == 2) { // first time on this screen - need absolute scroll immediately! - scrlToX = (uint32)offsetX; - scrlToY = (uint32)offsetY; - } else { // catch up with required scroll offsets - speed depending on distance to catch up (dx and dy) & 'SCROLL_FRACTION' used - // but limit to certain number of pixels per cycle (MAX_SCROLL_DISTANCE) - dx = SwordLogic::_scriptVars[SCROLL_OFFSET_X] - offsetX; - dy = SwordLogic::_scriptVars[SCROLL_OFFSET_Y] - offsetY; - int8 sig = (dx < 0) ? (-1) : 1; - if (dx < 0) - dx = -dx; - scrlDistX = 1 + dx/SCROLL_FRACTION; - scrlDistX = inRange(0, scrlDistX, MAX_SCROLL_DISTANCE); - scrlToX = SwordLogic::_scriptVars[SCROLL_OFFSET_X] + sig * scrlDistX; - - sig = (dy < 0) ? (-1) : 1; - if (dy < 0) - dy = -dy; - scrlDistY = 1 + dy/SCROLL_FRACTION; - scrlDistY = inRange(0, scrlDistY, MAX_SCROLL_DISTANCE); - scrlToY = SwordLogic::_scriptVars[SCROLL_OFFSET_Y] + sig * scrlDistY; - } + if (SwordLogic::_scriptVars[SCROLL_FLAG] == 2) // first time on this screen - need absolute scroll immediately! + SwordLogic::_scriptVars[SCROLL_FLAG] = 1; scrlToX = inRange(0, scrlToX, SwordLogic::_scriptVars[MAX_SCROLL_OFFSET_X]); scrlToY = inRange(0, scrlToY, SwordLogic::_scriptVars[MAX_SCROLL_OFFSET_Y]); if ((scrlToX != SwordLogic::_scriptVars[SCROLL_OFFSET_X]) || (scrlToY != SwordLogic::_scriptVars[SCROLL_OFFSET_Y])) { @@ -103,8 +84,10 @@ void SwordScreen::setScrolling(int16 offsetX, int16 offsetY) { } void SwordScreen::fadeDownPalette(void) { - _fadingStep = 15; - _fadingDirection = FADE_DOWN; + if (!_isBlack) { // don't fade down twice + _fadingStep = 15; + _fadingDirection = FADE_DOWN; + } } void SwordScreen::fadeUpPalette(void) { @@ -122,15 +105,16 @@ void SwordScreen::fnSetPalette(uint8 start, uint16 length, uint32 id, bool fadeU _targetPalette[(start + cnt) * 4 + 2] = palData[cnt * 3 + 2] << 2; } _resMan->resClose(id); + _isBlack = false; if (fadeUp) { _fadingStep = 1; - _fadingDirection = 1; + _fadingDirection = FADE_UP; } else _system->set_palette(_targetPalette, start, length); } bool SwordScreen::stillFading(void) { - return (_fadingStep > 0); + return !_isBlack; } void SwordScreen::updateScreen(void) { @@ -662,8 +646,11 @@ void SwordScreen::fadePalette(void) { _currentPalette[cnt] = (_targetPalette[cnt] * _fadingStep) >> 4; _fadingStep += _fadingDirection; - if (_fadingStep == 17) + if (_fadingStep == 17) { _fadingStep = 0; + _isBlack = false; + } else if (_fadingStep == 0) + _isBlack = true; } void SwordScreen::fnSetParallax(uint32 screen, uint32 resId) { diff --git a/sword1/screen.h b/sword1/screen.h index 1b3cee8b75..64b506227f 100644 --- a/sword1/screen.h +++ b/sword1/screen.h @@ -142,6 +142,8 @@ private: uint8 _currentPalette[256 * 4]; // for fading uint8 _fadingStep; int8 _fadingDirection; // 1 for fade up, -1 for fade down + bool _isBlack; // if the logic already faded down the palette, this is set to show the + // mainloop that no further fading is necessary. }; #endif //BSSCREEN_H diff --git a/sword1/sound.h b/sword1/sound.h index a4a43ae6e8..3c6fba476e 100644 --- a/sword1/sound.h +++ b/sword1/sound.h @@ -68,8 +68,6 @@ public: void fnStopFx(int32 fxNo); void clearAllFx(void); int addToQueue(int32 fxNo); - //void removeFromQueue(int32 fxNo); - // ^= part of fnPlayFx void engine(void); diff --git a/sword1/sword1.cpp b/sword1/sword1.cpp index 4372b7cae4..2b95eb9b2d 100644 --- a/sword1/sword1.cpp +++ b/sword1/sword1.cpp @@ -180,7 +180,6 @@ void SwordEngine::mainLoop(void) { _music->stream(); frameTime = _system->get_msecs(); _systemVars.saveGameFlag = 0; - debug(5, "\n\nNext logic cycle"); _logic->engine(); _logic->updateScreenParams(); // sets scrolling @@ -222,8 +221,7 @@ void SwordEngine::mainLoop(void) { } while ((SwordLogic::_scriptVars[SCREEN] == SwordLogic::_scriptVars[NEW_SCREEN]) && (_systemVars.saveGameFlag < 2)); // change screen - // we don't fade down after syria pan (53). Also, scripts can call fnFadeDown, in that case, we already are fading - if ((SwordLogic::_scriptVars[SCREEN] != 53) && (!_screen->stillFading())) + if (SwordLogic::_scriptVars[SCREEN] != 53) // we don't fade down after syria pan (53). _screen->fadeDownPalette(); while (_screen->stillFading()) { _music->stream(); |