diff options
author | Robert Göffringmann | 2003-12-22 01:20:47 +0000 |
---|---|---|
committer | Robert Göffringmann | 2003-12-22 01:20:47 +0000 |
commit | fd4417e6bbe0a571e51c1cb82e9941c455b9ce76 (patch) | |
tree | bfd5125d1a9975ebe82e0d796ca3c8f3f7a23aeb | |
parent | 6b0fb6585cf31bbd341a7da8fa60be5f09eb2381 (diff) | |
download | scummvm-rg350-fd4417e6bbe0a571e51c1cb82e9941c455b9ce76.tar.gz scummvm-rg350-fd4417e6bbe0a571e51c1cb82e9941c455b9ce76.tar.bz2 scummvm-rg350-fd4417e6bbe0a571e51c1cb82e9941c455b9ce76.zip |
changed the way the control panel is started
svn-id: r11844
-rw-r--r-- | sword1/screen.cpp | 4 | ||||
-rw-r--r-- | sword1/screen.h | 6 | ||||
-rw-r--r-- | sword1/sword1.cpp | 94 | ||||
-rw-r--r-- | sword1/sword1.h | 4 |
4 files changed, 51 insertions, 57 deletions
diff --git a/sword1/screen.cpp b/sword1/screen.cpp index 98ca039985..f33437df9d 100644 --- a/sword1/screen.cpp +++ b/sword1/screen.cpp @@ -109,6 +109,10 @@ void SwordScreen::fnSetPalette(uint8 start, uint16 length, uint32 id, bool fadeU _system->set_palette(_targetPalette, start, length); } +void SwordScreen::refreshPalette(void) { + _system->set_palette(_targetPalette, 0, 256); +} + bool SwordScreen::stillFading(void) { return !_isBlack; } diff --git a/sword1/screen.h b/sword1/screen.h index 7c7634fdb4..b99aa87794 100644 --- a/sword1/screen.h +++ b/sword1/screen.h @@ -66,21 +66,19 @@ public: SwordScreen(OSystem *system, ResMan *pResMan, ObjectMan *pObjMan); void useTextManager(SwordText *pTextMan); ~SwordScreen(void); - void flushSprites(void) { _backLength = _sortLength = _foreLength = 0; }; + void draw(void); void quitScreen(void); void newScreen(uint32 screen); void setScrolling(int16 offsetX, int16 offsetY); - void addToGraphicList(uint8 listId, uint32 objId); - void draw(void); - void fadeDownPalette(void); void fadeUpPalette(void); void fnSetPalette(uint8 start, uint16 length, uint32 id, bool fadeUp); bool stillFading(void); + void refreshPalette(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 f26c6c7ec7..bba5628c68 100644 --- a/sword1/sword1.cpp +++ b/sword1/sword1.cpp @@ -148,6 +148,7 @@ void SwordEngine::initialize(void) { _logic->initialize(); _objectMan->initialize(); _mouse->initialize(); + _control = new SwordControl(_resMan, _objectMan, _system, _mouse, getSavePath()); } void SwordEngine::reinitialize(void) { @@ -903,10 +904,14 @@ void SwordEngine::startPositions(int32 startNumber) { //--------------------------- case 63: // train_one { - SwordLogic::_scriptVars[CHANGE_X] = 1288; - SwordLogic::_scriptVars[CHANGE_Y] = 264; - SwordLogic::_scriptVars[CHANGE_DIR] = RIGHT; + SwordLogic::_scriptVars[CHANGE_X] = 710; + SwordLogic::_scriptVars[CHANGE_Y] = 450; + SwordLogic::_scriptVars[CHANGE_DIR] = LEFT; SwordLogic::_scriptVars[CHANGE_PLACE] = FLOOR_63; + SwordLogic::_scriptVars[DOOR_SC65_FLAG] = 2; + SwordLogic::_scriptVars[DOOR_ONE_63_OPEN] = 0; + SwordLogic::_scriptVars[DOOR_65_OPEN] = 1; + SwordLogic::_scriptVars[VAIL_TEXT] = 1; } break; //--------------------------- @@ -1029,8 +1034,6 @@ void SwordEngine::go(void) { 1 = dead 2 = game won 3 = game was just started */ - SwordControl *control = new SwordControl(_resMan, _objectMan, _system, _mouse, getSavePath()); - uint8 controlRes = 0; uint8 startPos = ConfMan.getInt("boot_param"); if (startPos) { @@ -1045,20 +1048,13 @@ void SwordEngine::go(void) { } do { - mainLoop(); - - // the mainloop was left, either because the player pressed F5 or because the logic - // wants to restart the game. - if (!_systemVars.forceRestart) - controlRes = control->runPanel(); - if ((controlRes == CONTROL_RESTART_GAME) || (_systemVars.forceRestart)) { - _music->fadeDown(); - startPositions(1); - _systemVars.forceRestart = false; - } else if (controlRes == CONTROL_GAME_RESTORED) { - reinitialize(); // first clear anything which was loaded - control->doRestore(); // then actually load the savegame data. - } + uint8 action = mainLoop(); + + // the mainloop was left, we have to reinitialize. + reinitialize(); + if (action == CONTROL_GAME_RESTORED) + _control->doRestore(); + _systemVars.forceRestart = false; _systemVars.deathScreenFlag = 0; } while (true); } @@ -1072,10 +1068,10 @@ void SwordEngine::checkCd(void) { _systemVars.currentCD = needCd; } -void SwordEngine::mainLoop(void) { - uint32 newTime, frameTime; - bool wantControlPanel = false; - do { +uint8 SwordEngine::mainLoop(void) { + uint8 retCode = 0; + + while (retCode == 0) { // do we need the section45-hack from sword.c here? checkCd(); @@ -1086,61 +1082,55 @@ void SwordEngine::mainLoop(void) { do { _music->stream(); - frameTime = _system->get_msecs(); + uint32 frameTime = _system->get_msecs(); _logic->engine(); _logic->updateScreenParams(); // sets scrolling _screen->draw(); _mouse->animate(); - newTime = _system->get_msecs(); - /*if ((newTime - frameTime < 50) && (!SwordLogic::_scriptVars[NEW_PALETTE])) { - RenderScreenGDK(); - BlitMenusGDK(); - BlitMousePm(); - if (newTime - frameTime < 40) - _system->delay_msecs(40 - (newTime - frameTime)); - FlipScreens(); - }*/ + uint32 newTime = _system->get_msecs(); _sound->engine(); _screen->updateScreen(); - //- + _menu->refresh(MENU_TOP); _menu->refresh(MENU_BOT); - newTime = _system->get_msecs(); if (newTime - frameTime < 80) delay(80 - (newTime - frameTime)); else delay(0); - /*FlipScreens(); this is done in SwordScreen::updateScreen() now. - if (SwordLogic::_scriptVars[NEW_PALETTE]) { - SwordLogic::_scriptVars[NEW_PALETTE] = 0; - startFadePaletteUp(); - }*/ - _mouse->engine( _mouseX, _mouseY, _mouseState); _mouseState = 0; - if (_keyPressed == 63) - wantControlPanel = true; + + if (_systemVars.forceRestart) + retCode = CONTROL_RESTART_GAME; + else if (_keyPressed == 63) { + retCode = _control->runPanel(); + if (!retCode) + _screen->refreshPalette(); + } + // do something smart here to implement pausing the game. If we even want that, that is. - } while ((SwordLogic::_scriptVars[SCREEN] == SwordLogic::_scriptVars[NEW_SCREEN]) && - (!_systemVars.forceRestart) && (!wantControlPanel)); + } while ((SwordLogic::_scriptVars[SCREEN] == SwordLogic::_scriptVars[NEW_SCREEN]) && (retCode == 0)); - if (SwordLogic::_scriptVars[SCREEN] != 53) // we don't fade down after syria pan (53). - _screen->fadeDownPalette(); - while (_screen->stillFading()) { - _music->stream(); - _screen->updateScreen(); - delay(1000/12); + if (retCode == 0) { + if (SwordLogic::_scriptVars[SCREEN] != 53) // we don't fade down after syria pan (53). + _screen->fadeDownPalette(); + while (_screen->stillFading()) { + _music->stream(); + _screen->updateScreen(); + delay(1000/12); + } } _sound->quitScreen(); _screen->quitScreen(); // close graphic resources _objectMan->closeSection(SwordLogic::_scriptVars[SCREEN]); // close the section that PLAYER has just left, if it's empty now - } while ((!_systemVars.forceRestart) && (!wantControlPanel)); + } + return retCode; } void SwordEngine::delay(uint amount) { //copied and mutilated from sky.cpp diff --git a/sword1/sword1.h b/sword1/sword1.h index fa3d866454..73663515f5 100644 --- a/sword1/sword1.h +++ b/sword1/sword1.h @@ -35,6 +35,7 @@ class MemMan; class ObjectMan; class SwordMenu; class SwordMusic; +class SwordControl; struct SystemVars { // todo: move these to a better place @@ -64,7 +65,7 @@ private: void initialize(void); void checkCd(void); - void mainLoop(void); + uint8 mainLoop(void); void startPositions(int32 startNumber); uint16 _mouseX, _mouseY, _mouseState; @@ -82,5 +83,6 @@ private: SwordSound *_sound; SwordMenu *_menu; SwordMusic *_music; + SwordControl *_control; static const uint8 _cdList[TOTAL_SECTIONS]; }; |