From f755311114121ce67efc17db4a67996382affc47 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 4 Nov 2009 11:52:11 +0000 Subject: priority_first and priority_last are not used by the new drawing code, thus the new code didn't handle priority changes by kGraph() svn-id: r45658 --- engines/sci/console.cpp | 3 ++- engines/sci/engine/game.cpp | 9 +++------ engines/sci/engine/kernel.h | 13 ------------- engines/sci/engine/kgraphics.cpp | 3 +-- engines/sci/engine/savegame.cpp | 5 ++++- engines/sci/engine/state.cpp | 6 +++--- engines/sci/engine/state.h | 6 +++--- engines/sci/gui/gui.cpp | 8 ++++++++ engines/sci/gui/gui.h | 2 ++ engines/sci/gui32/gui32.cpp | 17 +++++++++++++++++ engines/sci/gui32/gui32.h | 2 ++ engines/sci/sci.cpp | 2 +- 12 files changed, 46 insertions(+), 30 deletions(-) (limited to 'engines') diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index e81b1a4120..b95158126d 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -1319,6 +1319,7 @@ bool Console::cmdDroppedViews(int argc, const char **argv) { } bool Console::cmdPriorityBands(int argc, const char **argv) { +#ifdef INCLUDE_OLDGFX if (argc != 2) { DebugPrintf("Priority bands start at y=%d. They end at y=%d\n", _vm->_gamestate->priority_first, _vm->_gamestate->priority_last); DebugPrintf("Use %s to print the start of priority for the specified priority band (0 - 15)\n", argv[0]); @@ -1326,7 +1327,7 @@ bool Console::cmdPriorityBands(int argc, const char **argv) { } int zone = CLIP(atoi(argv[1]), 0, 15); -#ifdef INCLUDE_OLDGFX + DebugPrintf("Zone %x starts at y=%d\n", zone, _find_priority_band(_vm->_gamestate, zone)); #endif diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 8ec2026997..94e49ab33f 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -162,8 +162,8 @@ const char *convertSierraGameId(const char *gameName, uint32 *gameFlags) { return strdup(sierraId.c_str()); } -int _reset_graphics_input(EngineState *s) { #ifdef INCLUDE_OLDGFX +int _reset_graphics_input(EngineState *s) { Resource *resource; int font_nr; gfx_color_t transparent = { PaletteEntry(), 0, -1, -1, 0 }; @@ -261,8 +261,6 @@ int _reset_graphics_input(EngineState *s) { #if 0 s->titlebar_port->_bgcolor.mask |= GFX_MASK_PRIORITY; s->titlebar_port->_bgcolor.priority = 11; // Standard priority for the titlebar port -#endif - #endif s->priority_first = 42; // Priority zone 0 ends here @@ -279,6 +277,8 @@ int game_init_graphics(EngineState *s) { return _reset_graphics_input(s); } +#endif + static void _free_graphics_input(EngineState *s) { debug(2, "Freeing graphics"); @@ -406,9 +406,6 @@ int game_init(EngineState *s) { #ifdef INCLUDE_OLDGFX if (s->gfx_state && _reset_graphics_input(s)) return 1; -#else - if (_reset_graphics_input(s)) - return 1; #endif s->successor = NULL; // No successor diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index 15e7489aff..9294b6a172 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -221,19 +221,6 @@ int _find_priority_band(EngineState *s, int band); */ int _find_view_priority(EngineState *s, int y); -#define SCI0_VIEW_PRIORITY_14_ZONES(y) (((y) < s->priority_first)? 0 : (((y) >= s->priority_last)? 14 : 1\ - + ((((y) - s->priority_first) * 14) / (s->priority_last - s->priority_first)))) - -#define SCI0_PRIORITY_BAND_FIRST_14_ZONES(nr) ((((nr) == 0)? 0 : \ - ((s->priority_first) + (((nr)-1) * (s->priority_last - s->priority_first)) / 14))) - -#define SCI0_VIEW_PRIORITY(y) (((y) < s->priority_first)? 0 : (((y) >= s->priority_last)? 14 : 1\ - + ((((y) - s->priority_first) * 15) / (s->priority_last - s->priority_first)))) - -#define SCI0_PRIORITY_BAND_FIRST(nr) ((((nr) == 0)? 0 : \ - ((s->priority_first) + (((nr)-1) * (s->priority_last - s->priority_first)) / 15))) - - /******************** Dynamic view list functions ********************/ diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index e81378a9b1..24a0737aa8 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -268,8 +268,7 @@ reg_t kGraph(EngineState *s, int argc, reg_t *argv) { case K_GRAPH_ADJUST_PRIORITY: debugC(2, kDebugLevelGraphics, "adjust_priority(%d, %d)\n", argv[1].toSint16(), argv[2].toSint16()); - s->priority_first = argv[1].toSint16() - 10; - s->priority_last = argv[2].toSint16() - 10; + s->_gui->modifyPriorityBands(argv[1].toSint16() - 10, argv[2].toSint16() - 10); break; case K_GRAPH_SAVE_UPSCALEDHIRES_BOX: diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 9f3aa118b4..fd8cb6e142 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -658,8 +658,9 @@ void SegManager::reconstructScripts(EngineState *s) { } } } - +#ifdef INCLUDE_OLDGFX int _reset_graphics_input(EngineState *s); +#endif static void reconstruct_sounds(EngineState *s) { Song *seeker; @@ -770,7 +771,9 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { retval->gc_countdown = GC_INTERVAL - 1; retval->sys_strings_segment = retval->_segMan->findSegmentByType(SEG_TYPE_SYS_STRINGS); retval->sys_strings = (SystemStrings *)GET_SEGMENT(*retval->_segMan, retval->sys_strings_segment, SEG_TYPE_SYS_STRINGS); +#ifdef INCLUDE_OLDGFX _reset_graphics_input(retval); +#endif // Time state: retval->last_wait_time = g_system->getMillis(); diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index cfb70d6399..5925698e49 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -61,12 +61,12 @@ EngineState::EngineState(ResourceManager *res, Kernel *kernel, Vocabulary *voc, dyn_views = 0; drop_views = 0; -#endif - - _menubar = 0; priority_first = 0; priority_last = 0; +#endif + + _menubar = 0; last_wait_time = 0; diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h index 72a0737ef0..9e517adf4b 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -169,12 +169,12 @@ public: GfxList *dyn_views; /**< Pointers to pic and dynamic view lists */ GfxList *drop_views; /**< A list Animate() can dump dropped dynviews into */ -#endif - - Menubar *_menubar; /**< The menu bar */ int priority_first; /**< The line where priority zone 0 ends */ int priority_last; /**< The line where the highest priority zone starts */ +#endif + + Menubar *_menubar; /**< The menu bar */ uint32 game_start_time; /**< The time at which the interpreter was started */ uint32 last_wait_time; /**< The last time the game invoked Wait() */ diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp index 5027c0df2c..d565d20c49 100644 --- a/engines/sci/gui/gui.cpp +++ b/engines/sci/gui/gui.cpp @@ -101,6 +101,14 @@ void SciGui::initPriorityBands() { } } +void SciGui::modifyPriorityBands(int top, int bottom) { + if (_usesOldGfxFunctions) { + _gfx->PriorityBandsInit(15, top, bottom); + } else { + _gfx->PriorityBandsInit(14, top, bottom); + } +} + void SciGui::wait(int16 ticks) { uint32 time; diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h index cb3ff189a9..878f676553 100644 --- a/engines/sci/gui/gui.h +++ b/engines/sci/gui/gui.h @@ -143,6 +143,8 @@ public: virtual void portraitShow(Common::String resourceName, Common::Point position, uint16 resourceNum, uint16 noun, uint16 verb, uint16 cond, uint16 seq); virtual void portraitUnload(uint16 portraitId); + virtual void modifyPriorityBands(int top, int bottom); + virtual bool debugUndither(bool flag); virtual bool debugShowMap(int mapNo); diff --git a/engines/sci/gui32/gui32.cpp b/engines/sci/gui32/gui32.cpp index 5b6900f6eb..edb901054c 100644 --- a/engines/sci/gui32/gui32.cpp +++ b/engines/sci/gui32/gui32.cpp @@ -75,6 +75,18 @@ namespace Sci { _s->visual->draw(gfxw_point_zero); \ gfxop_update(_s->gfx_state); +#define SCI0_VIEW_PRIORITY_14_ZONES(y) (((y) < s->priority_first)? 0 : (((y) >= s->priority_last)? 14 : 1\ + + ((((y) - s->priority_first) * 14) / (s->priority_last - s->priority_first)))) + +#define SCI0_PRIORITY_BAND_FIRST_14_ZONES(nr) ((((nr) == 0)? 0 : \ + ((s->priority_first) + (((nr)-1) * (s->priority_last - s->priority_first)) / 14))) + +#define SCI0_VIEW_PRIORITY(y) (((y) < s->priority_first)? 0 : (((y) >= s->priority_last)? 14 : 1\ + + ((((y) - s->priority_first) * 15) / (s->priority_last - s->priority_first)))) + +#define SCI0_PRIORITY_BAND_FIRST(nr) ((((nr) == 0)? 0 : \ + ((s->priority_first) + (((nr)-1) * (s->priority_last - s->priority_first)) / 15))) + #if 0 // Used for debugging #define FULL_INSPECTION()\ @@ -2996,6 +3008,11 @@ void SciGui32::moveCursor(Common::Point pos) { gfxop_get_event(_s->gfx_state, SCI_EVT_PEEK); } +void SciGui32::modifyPriorityBands(int top, int bottom) { + _s->priority_first = top; + _s->priority_last = bottom; +} + bool SciGui32::debugUndither(bool flag) { return true; } diff --git a/engines/sci/gui32/gui32.h b/engines/sci/gui32/gui32.h index a0dae12f0e..d8a49542bb 100644 --- a/engines/sci/gui32/gui32.h +++ b/engines/sci/gui32/gui32.h @@ -109,6 +109,8 @@ public: void setCursorPos(Common::Point pos); void moveCursor(Common::Point pos); + void modifyPriorityBands(int top, int bottom); + bool debugUndither(bool flag); bool debugShowMap(int mapNo); diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index efd14252b3..9c6a67eaa0 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -168,12 +168,12 @@ Common::Error SciEngine::run() { #ifdef INCLUDE_OLDGFX gfxop_init(&gfx_state, _resMan, screen, palette, 1); -#endif if (game_init_graphics(_gamestate)) { // Init interpreter graphics warning("Game initialization failed: Error in GFX subsystem. Aborting..."); return Common::kUnknownError; } +#endif if (game_init_sound(_gamestate, 0)) { warning("Game initialization failed: Error in sound subsystem. Aborting..."); -- cgit v1.2.3