diff options
-rw-r--r-- | sword2/debug.cpp | 4 | ||||
-rw-r--r-- | sword2/function.cpp | 6 | ||||
-rw-r--r-- | sword2/logic.cpp | 2 | ||||
-rw-r--r-- | sword2/protocol.cpp | 10 | ||||
-rw-r--r-- | sword2/router.cpp | 2 | ||||
-rw-r--r-- | sword2/sword2.cpp | 169 | ||||
-rw-r--r-- | sword2/sword2.h | 7 |
7 files changed, 82 insertions, 118 deletions
diff --git a/sword2/debug.cpp b/sword2/debug.cpp index 4cae752841..79c875cf71 100644 --- a/sword2/debug.cpp +++ b/sword2/debug.cpp @@ -104,12 +104,14 @@ void Debugger::buildDebugText(void) { makeDebugTextBlock(buf, 0, 105); } +#ifdef SWORD2_DEBUG // speed-up indicator - if (_vm->_renderSkip) { // see sword.cpp + if (_vm->_renderSkip) { // see sword2.cpp sprintf(buf, "SKIPPING FRAMES FOR SPEED-UP!"); makeDebugTextBlock(buf, 0, 120); } +#endif // debug info at top of screen - enabled/disabled as one complete unit diff --git a/sword2/function.cpp b/sword2/function.cpp index dd890ee610..4ffdd9e476 100644 --- a/sword2/function.cpp +++ b/sword2/function.cpp @@ -211,7 +211,7 @@ int32 Logic::fnSetValue(int32 *params) { return IR_CONT; } -#ifdef _SWORD2_DEBUG +#ifdef SWORD2_DEBUG #define BLACK 0 #define WHITE 1 #define RED 2 @@ -232,7 +232,7 @@ int32 Logic::fnFlash(int32 *params) { // params: 0 colour to flash -#ifdef _SWORD2_DEBUG +#ifdef SWORD2_DEBUG // what colour? switch (params[0]) { case WHITE: @@ -268,7 +268,7 @@ int32 Logic::fnColour(int32 *params) { // params 0: colour (see defines above) -#ifdef _SWORD2_DEBUG +#ifdef SWORD2_DEBUG // what colour? switch (params[0]) { case BLACK: diff --git a/sword2/logic.cpp b/sword2/logic.cpp index d1e28b46b8..1d4e71ec54 100644 --- a/sword2/logic.cpp +++ b/sword2/logic.cpp @@ -335,7 +335,7 @@ int32 Logic::fnAddToKillList(int32 *params) { // params: none // DON'T EVER KILL GEORGE! - if (_scriptVars[ID] == 8) + if (_scriptVars[ID] == CUR_PLAYER_ID) return IR_CONT; // Scan the list to see if it's already included diff --git a/sword2/protocol.cpp b/sword2/protocol.cpp index e928fd0e0a..99d6b6a392 100644 --- a/sword2/protocol.cpp +++ b/sword2/protocol.cpp @@ -75,7 +75,7 @@ ScreenHeader *Sword2Engine::fetchScreenHeader(byte *screenFile) { */ LayerHeader *Sword2Engine::fetchLayerHeader(byte *screenFile, uint16 layerNo) { -#ifdef _SWORD2_DEBUG +#ifdef SWORD2_DEBUG ScreenHeader *screenHead = fetchScreenHeader(screenFile); if (layerNo > screenHead->noLayers - 1) @@ -118,7 +118,7 @@ AnimHeader *Sword2Engine::fetchAnimHeader(byte *animFile) { CdtEntry *Sword2Engine::fetchCdtEntry(byte *animFile, uint16 frameNo) { AnimHeader *animHead = fetchAnimHeader(animFile); -#ifdef _SWORD2_DEBUG +#ifdef SWORD2_DEBUG if (frameNo > animHead->noAnimFrames - 1) error("fetchCdtEntry(animFile,%d) - anim only %d frames", frameNo, animHead->noAnimFrames); #endif @@ -144,7 +144,7 @@ FrameHeader *Sword2Engine::fetchFrameHeader(byte *animFile, uint16 frameNo) { Parallax *Sword2Engine::fetchBackgroundParallaxLayer(byte *screenFile, int layer) { MultiScreenHeader *mscreenHeader = (MultiScreenHeader *) (screenFile + sizeof(StandardHeader)); -#ifdef _SWORD2_DEBUG +#ifdef SWORD2_DEBUG if (mscreenHeader->bg_parallax[layer] == 0) error("fetchBackgroundParallaxLayer(%d) - No parallax layer exists", layer); #endif @@ -155,7 +155,7 @@ Parallax *Sword2Engine::fetchBackgroundParallaxLayer(byte *screenFile, int layer Parallax *Sword2Engine::fetchBackgroundLayer(byte *screenFile) { MultiScreenHeader *mscreenHeader = (MultiScreenHeader *) (screenFile + sizeof(StandardHeader)); -#ifdef _SWORD2_DEBUG +#ifdef SWORD2_DEBUG if (mscreenHeader->screen == 0) error("fetchBackgroundLayer (%d) - No background layer exists"); #endif @@ -166,7 +166,7 @@ Parallax *Sword2Engine::fetchBackgroundLayer(byte *screenFile) { Parallax *Sword2Engine::fetchForegroundParallaxLayer(byte *screenFile, int layer) { MultiScreenHeader *mscreenHeader = (MultiScreenHeader *) (screenFile + sizeof(StandardHeader)); -#ifdef _SWORD2_DEBUG +#ifdef SWORD2_DEBUG if (mscreenHeader->fg_parallax[layer] == 0) error("fetchForegroundParallaxLayer(%d) - No parallax layer exists", layer); #endif diff --git a/sword2/router.cpp b/sword2/router.cpp index 3bc04f4636..fee34aa3a5 100644 --- a/sword2/router.cpp +++ b/sword2/router.cpp @@ -1150,7 +1150,7 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) { } } while (_modularPath[p].dir < NO_DIRECTIONS); -#ifdef _SWORD2_DEBUG +#ifdef SWORD2_DEBUG if (lastRealDir == 99) error("slidyWalkAnimatorlast direction error"); #endif diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp index fdde1d7ea7..732b99b743 100644 --- a/sword2/sword2.cpp +++ b/sword2/sword2.cpp @@ -100,8 +100,6 @@ REGISTER_PLUGIN("Broken Sword II", Engine_SWORD2_gameList, Engine_SWORD2_create, namespace Sword2 { -Sword2Engine *g_sword2 = NULL; - Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst) : Engine(syst) { // Add default file directories File::addDefaultDirectory(_gameDataPath + "CLUSTERS/"); @@ -111,20 +109,24 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst) : Engine(syst) File::addDefaultDirectory(_gameDataPath + "sword2/"); File::addDefaultDirectory(_gameDataPath + "video/"); - g_sword2 = this; - _debugger = NULL; - _sound = NULL; - _graphics = NULL; _features = detector->_game.features; _targetName = detector->_targetName; + _bootParam = ConfMan.getInt("boot_param"); _saveSlot = ConfMan.getInt("save_slot"); + _debugger = NULL; + _graphics = NULL; + _sound = NULL; + _gui = NULL; + _fontRenderer = NULL; + _logic = NULL; + _resman = NULL; + _memory = NULL; + _keyboardEvent.pending = false; _mouseEvent.pending = false; - _mouseX = _mouseY = 0; - _lastPaletteRes = 0; _largestLayerArea = 0; @@ -149,6 +151,7 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst) : Engine(syst) memset(&_thisScreen, 0, sizeof(_thisScreen)); memset(_mouseList, 0, sizeof(_mouseList)); + _mouseX = _mouseY = 0; _mouseTouching = 0; _oldMouseTouching = 0; _menuSelectedPos = 0; @@ -164,26 +167,24 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst) : Engine(syst) _playerActivityDelay = 0; _realLuggageItem = 0; - // used to be a define, but now it's flexible _scrollFraction = 16; - _gamePaused = false; +#ifdef SWORD2_DEBUG _stepOneCycle = false; + _renderSkip = false; +#endif + + _gamePaused = false; _graphicsLevelFudged = false; - _debugger = NULL; - _graphics = NULL; - _sound = NULL; - _gui = NULL; - _fontRenderer = NULL; - _logic = NULL; - _resman = NULL; - _memory = NULL; + _gameCycle = 0; _quit = false; } Sword2Engine::~Sword2Engine() { + killMusic(); + delete _debugger; delete _graphics; delete _sound; @@ -223,7 +224,7 @@ void Sword2Engine::setupPersistentResources() { } void Sword2Engine::mainInit() { - // get some falling RAM and put it in your pocket, never let it slip + // Get some falling RAM and put it in your pocket, never let it slip // away _graphics = new Graphics(this, 640, 480); @@ -255,26 +256,15 @@ void Sword2Engine::mainInit() { // nor the scroll wheel. setEventFilter(RD_LEFTBUTTONUP | RD_RIGHTBUTTONUP | RD_WHEELUP | RD_WHEELDOWN); - // Initialise global script variables and player object setupPersistentResources(); - - // Set up font resource variables for this language version - - debug(5, "CALLING: initialiseFontResourceFlags"); initialiseFontResourceFlags(); - - // initialise the sound fx queue - - debug(5, "CALLING: Init_fx_queue"); initFxQueue(); - // all demos (not just web) if (_features & GF_DEMO) Logic::_scriptVars[DEMO] = 1; else Logic::_scriptVars[DEMO] = 0; - debug(5, "CALLING: readOptionSettings"); _gui->readOptionSettings(); if (_saveSlot != -1) { @@ -305,13 +295,7 @@ void Sword2Engine::mainInit() { } else startGame(); - debug(5, "CALLING: initialiseRenderCycle"); _graphics->initialiseRenderCycle(); - - _renderSkip = false; // Toggled on 'S' key, to render only - // 1 in 4 frames, to speed up game - - _gameCycle = 0; } void Sword2Engine::mainRun() { @@ -319,13 +303,7 @@ void Sword2Engine::mainRun() { if (_debugger->isAttached()) _debugger->onFrame(); - // the screen is build. Mostly because of first scroll - // cycle stuff - -#ifdef _SWORD2_DEBUG - // if we've just stepped forward one cycle while the - // game was paused - +#ifdef SWORD2_DEBUG if (_stepOneCycle) { pauseGame(); _stepOneCycle = false; @@ -349,7 +327,7 @@ void Sword2Engine::mainRun() { if (!Logic::_scriptVars[DEMO] && !_logic->_choosing) _logic->fnPlayCredits(NULL); break; -#ifdef _SWORD2_DEBUG +#ifdef SWORD2_DEBUG case ' ': if (_gamePaused) { _stepOneCycle = true; @@ -372,7 +350,7 @@ void Sword2Engine::mainRun() { gameCycle(); } - // We can't use this as termination condition for the looop, + // We can't use this as termination condition for the loop, // because we want the break to happen before updating the // screen again. @@ -382,14 +360,13 @@ void Sword2Engine::mainRun() { // creates the debug text blocks _debugger->buildDebugText(); -#ifdef _SWORD2_DEBUG +#ifdef SWORD2_DEBUG // if not in console & '_renderSkip' is set, only render // display once every 4 game-cycles - if (console_status || !_renderSkip || (_gameCycle % 4) == 0) - buildDisplay(); // create and flip the screen + if (!_renderSkip || (_gameCycle % 4) == 0) + buildDisplay(); #else - // create and flip the screen buildDisplay(); #endif } @@ -398,9 +375,6 @@ void Sword2Engine::mainRun() { void Sword2Engine::go() { mainInit(); mainRun(); - - // Stop music instantly! - killMusic(); } void Sword2Engine::closeGame() { @@ -503,29 +477,28 @@ void Sword2Engine::parseEvents() { } void Sword2Engine::gameCycle() { - // do one game cycle + // Do one game cycle, that is run the logic session until a full loop + // has been performed. - // got a screen to run? if (_logic->getRunList()) { - // run the logic session UNTIL a full loop has been performed do { - // reset the graphic 'BuildUnit' list before a new - // logic list (see fnRegisterFrame) - resetRenderLists(); + // Reset the 'BuildUnit' and mouse hot-spot lists + // before each new logic list. The service scripts + // will fill thrm through fnRegisterFrame() and + // fnRegisterMouse(). - // reset the mouse hot-spot list (see fnRegisterMouse - // and fnRegisterFrame) + resetRenderLists(); resetMouseList(); - // keep going as long as new lists keep getting put in - // - i.e. screen changes + // Keep going as long as new lists keep getting put in + // - i.e. screen changes. } while (_logic->processSession()); } else { - // start the console and print the start options perhaps? + // Start the console and print the start options perhaps? _debugger->attach("AWAITING START COMMAND: (Enter 's 1' then 'q' to start from beginning)"); } - // if this screen is wide, recompute the scroll offsets every cycle + // If this screen is wide, recompute the scroll offsets every cycle if (_thisScreen.scroll_flag) setScrolling(); @@ -534,48 +507,36 @@ void Sword2Engine::gameCycle() { } void Sword2Engine::startGame() { - // boot the game straight into a start script + // Boot the game straight into a start script. It's always George's + // script #1, but with different ScreenManager objects depending on + // if it's the demo or the full game, or if we're using a boot param. int screen_manager_id; debug(5, "startGame() STARTING:"); - // all demos not just web - if (Logic::_scriptVars[DEMO]) - screen_manager_id = 19; // DOCKS SECTION START - else - screen_manager_id = 949; // INTRO & PARIS START - - // FIXME this could be validated against startup.inf for valid numbers - // to stop people shooting themselves in the foot - - if (_bootParam != 0) - screen_manager_id = _bootParam; - - char *raw_script; - char *raw_data_ad; + if (!_bootParam) { + if (Logic::_scriptVars[DEMO]) + screen_manager_id = 19; // DOCKS SECTION START + else + screen_manager_id = 949; // INTRO & PARIS START + } else { + // FIXME this could be validated against startup.inf for valid + // numbers to stop people shooting themselves in the foot - // the required start-scripts are both script #1 in the respective - // ScreenManager objects + if (_bootParam != 0) + screen_manager_id = _bootParam; + } uint32 null_pc = 1; - // open george object, ready for start script to reference - raw_data_ad = (char *) _resman->openResource(CUR_PLAYER_ID); + char *raw_data_ad = (char *) _resman->openResource(CUR_PLAYER_ID); + char *raw_script = (char *) _resman->openResource(screen_manager_id); - // open the ScreenManager object - raw_script = (char *) _resman->openResource(screen_manager_id); - - // run the start script now (because no console) _logic->runScript(raw_script, raw_data_ad, &null_pc); - // close the ScreenManager object _resman->closeResource(screen_manager_id); - - // close george _resman->closeResource(CUR_PLAYER_ID); - - debug(5, "startGame() DONE."); } // FIXME: Move this to some better place? @@ -591,25 +552,21 @@ void Sword2Engine::sleepUntil(uint32 time) { } void Sword2Engine::pauseGame() { - // don't allow Pause while screen fading or while black + // Don't allow Pause while screen fading or while black if (_graphics->getFadeStatus() != RDFADE_NONE) return; pauseAllSound(); - // make a normal mouse - clearPointerText(); + // Make the mouse cursor normal. This is the only place where we are + // allowed to clear the luggage this way. - // this is the only place allowed to do it this way + clearPointerText(); _graphics->setLuggageAnim(NULL, 0); - - // blank cursor setMouse(0); - - // forces engine to choose a cursor _mouseTouching = 1; - // if level at max, turn down because palette-matching won't work + // If level at max, turn down because palette-matching won't work // when dimmed if (_gui->_currentGraphicsLevel == 3) { @@ -617,11 +574,15 @@ void Sword2Engine::pauseGame() { _graphicsLevelFudged = true; } - // don't dim it if we're single-stepping through frames +#ifdef SWORD2_DEBUG + // Don't dim it if we're single-stepping through frames // dim the palette during the pause if (!_stepOneCycle) _graphics->dimPalette(); +#else + _graphics->dimPalette(); +#endif _gamePaused = true; } @@ -632,7 +593,7 @@ void Sword2Engine::unpauseGame() { unpauseAllSound(); - // put back game screen palette; see build_display.cpp + // Put back game screen palette; see build_display.cpp setFullPalette(-1); // If graphics level at max, turn up again @@ -643,7 +604,7 @@ void Sword2Engine::unpauseGame() { _gamePaused = false; - // if mouse is about or we're in a chooser menu + // If mouse is about or we're in a chooser menu if (!_mouseStatus || _logic->_choosing) setMouse(NORMAL_MOUSE_ID); } diff --git a/sword2/sword2.h b/sword2/sword2.h index 48cd345149..2a8018ef6a 100644 --- a/sword2/sword2.h +++ b/sword2/sword2.h @@ -241,7 +241,11 @@ public: bool _wantSfxDebug; int32 _gameCycle; + +#ifdef SWORD2_DEBUG bool _renderSkip; + bool _stepOneCycle; +#endif int32 initBackground(int32 res, int32 new_palette); @@ -392,7 +396,6 @@ public: bool _gamePaused; bool _graphicsLevelFudged; - bool _stepOneCycle; // for use while game paused void startGame(); void gameCycle(); @@ -405,8 +408,6 @@ public: void initialiseFontResourceFlags(uint8 language); }; -extern Sword2Engine *g_sword2; - } // End of namespace Sword2 #endif |