diff options
Diffstat (limited to 'engines/sci/engine')
| -rw-r--r-- | engines/sci/engine/game.cpp | 25 | ||||
| -rw-r--r-- | engines/sci/engine/kernel.cpp | 66 | ||||
| -rw-r--r-- | engines/sci/engine/kevent.cpp | 1 | ||||
| -rw-r--r-- | engines/sci/engine/kgraphics.cpp | 10 | ||||
| -rw-r--r-- | engines/sci/engine/kmenu.cpp | 25 | ||||
| -rw-r--r-- | engines/sci/engine/kscripts.cpp | 2 | ||||
| -rw-r--r-- | engines/sci/engine/savegame.cpp | 5 | ||||
| -rw-r--r-- | engines/sci/engine/state.cpp | 10 | ||||
| -rw-r--r-- | engines/sci/engine/state.h | 9 |
9 files changed, 136 insertions, 17 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 76dda57518..7131168afc 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -173,6 +173,7 @@ const char *convertSierraGameId(const char *gameName, uint32 *gameFlags) { } int _reset_graphics_input(EngineState *s) { +#ifdef INCLUDE_OLDGFX Resource *resource; int font_nr; gfx_color_t transparent = { PaletteEntry(), 0, -1, -1, 0 }; @@ -216,13 +217,6 @@ int _reset_graphics_input(EngineState *s) { s->dyn_views = NULL; // no DynViews s->drop_views = NULL; // And, consequently, no list for dropped views - s->priority_first = 42; // Priority zone 0 ends here - - if (s->usesOldGfxFunctions()) - s->priority_last = 200; - else - s->priority_last = 190; - font_nr = -1; do { resource = s->resMan->testResource(ResourceId(kResourceTypeFont, ++font_nr)); @@ -279,6 +273,15 @@ int _reset_graphics_input(EngineState *s) { s->titlebar_port->_bgcolor.priority = 11; // Standard priority for the titlebar port #endif +#endif + + s->priority_first = 42; // Priority zone 0 ends here + + if (s->usesOldGfxFunctions()) + s->priority_last = 200; + else + s->priority_last = 190; + return 0; } @@ -289,12 +292,14 @@ int game_init_graphics(EngineState *s) { static void _free_graphics_input(EngineState *s) { debug(2, "Freeing graphics"); +#ifdef INCLUDE_OLDGFX delete s->visual; s->wm_port = s->titlebar_port = s->picture_port = NULL; s->visual = NULL; s->dyn_views = NULL; s->port = NULL; +#endif } int game_init_sound(EngineState *s, int sound_flags) { @@ -406,8 +411,14 @@ int game_init(EngineState *s) { s->parserIsValid = false; // Invalidate parser s->parser_event = NULL_REG; // Invalidate parser event + +#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 s->_statusBarText.clear(); // Status bar is blank diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index a7c6527bc4..fdbcaa7a5f 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -28,6 +28,7 @@ #include "sci/resource.h" #include "sci/engine/state.h" #include "sci/engine/kernel_types.h" +#include "sci/gfx/operations.h" // for gfxop_get_cel_parameters namespace Sci { @@ -728,4 +729,69 @@ bool Kernel::loadKernelNames() { return true; } +Common::Rect set_base(EngineState *s, reg_t object) { + SegManager *segMan = s->_segMan; + int x, y, original_y, z, ystep, xsize = 0, ysize = 0; + int xbase, ybase, xend, yend; + int view, loop, cel; + int oldloop, oldcel; + int xmod = 0, ymod = 0; + Common::Rect retval; + + x = (int16)GET_SEL32V(segMan, object, x); + original_y = y = (int16)GET_SEL32V(segMan, object, y); + + if (s->_kernel->_selectorCache.z > -1) + z = (int16)GET_SEL32V(segMan, object, z); + else + z = 0; + + y -= z; // Subtract z offset + + ystep = (int16)GET_SEL32V(segMan, object, yStep); + + view = (int16)GET_SEL32V(segMan, object, view); + int l = GET_SEL32V(segMan, object, loop); + oldloop = loop = (l & 0x80) ? l - 256 : l; + int c = GET_SEL32V(segMan, object, cel); + oldcel = cel = (c & 0x80) ? c - 256 : c; + + Common::Point offset = Common::Point(0, 0); + + if (loop != oldloop) { + loop = 0; + PUT_SEL32V(segMan, object, loop, 0); + debugC(2, kDebugLevelGraphics, "Resetting loop for %04x:%04x!\n", PRINT_REG(object)); + } + + if (cel != oldcel) { + cel = 0; + PUT_SEL32V(segMan, object, cel, 0); + } + +#ifdef INCLUDE_OLDGFX + gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &xsize, &ysize, &offset); +#else + // TODO +#endif + + xmod = offset.x; + ymod = offset.y; + + xbase = x - xmod - (xsize >> 1); + xend = xbase + xsize; + yend = y /* - ymod */ + 1; + ybase = yend - ystep; + + debugC(2, kDebugLevelBaseSetter, "(%d,%d)+/-(%d,%d), (%d x %d) -> (%d, %d) to (%d, %d)\n", + x, y, xmod, ymod, xsize, ysize, xbase, ybase, xend, yend); + + retval.left = xbase; + retval.top = ybase; + retval.right = xend; + retval.bottom = yend; + + return retval; +} + } // End of namespace Sci diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp index 27158fac8c..1560bb1be7 100644 --- a/engines/sci/engine/kevent.cpp +++ b/engines/sci/engine/kevent.cpp @@ -26,6 +26,7 @@ #include "sci/sci.h" #include "sci/engine/state.h" #include "sci/engine/kernel.h" +#include "sci/gfx/operations.h" #include "sci/gfx/gfx_widgets.h" #include "sci/gfx/gfx_state_internal.h" // required for GfxPort, GfxVisual #include "sci/console.h" diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index e1f5dd8469..61419828fd 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -274,7 +274,9 @@ reg_t kGraph(EngineState *s, int argc, reg_t *argv) { error("Unsupported kGraph() operation %04x", argv[0].toSint16()); } +#ifdef INCLUDE_OLDGFX gfxop_update(s->gfx_state); +#endif return s->r_acc; } @@ -374,6 +376,8 @@ reg_t kIsItSkip(EngineState *s, int argc, reg_t *argv) { int cel = argv[2].toSint16(); int y = argv[3].toUint16(); int x = argv[4].toUint16(); + +#ifdef INCLUDE_OLDGFX gfxr_view_t *res = NULL; gfx_pixmap_t *pxm = NULL; @@ -391,6 +395,10 @@ reg_t kIsItSkip(EngineState *s, int argc, reg_t *argv) { y = pxm->index_height - 1; return make_reg(0, pxm->index_data[y * pxm->index_width + x] == pxm->color_key); +#else + // TODO + return NULL_REG; +#endif } reg_t kCelHigh(EngineState *s, int argc, reg_t *argv) { @@ -438,7 +446,7 @@ reg_t kOnControl(EngineState *s, int argc, reg_t *argv) { int argBase = 0; if ((argc == 2) || (argc == 4)) { - screenMask = GFX_MASK_CONTROL; + screenMask = SCI_SCREEN_MASK_CONTROL; } else { screenMask = argv[0].toUint16(); argBase = 1; diff --git a/engines/sci/engine/kmenu.cpp b/engines/sci/engine/kmenu.cpp index d63ffc2ca2..74496db800 100644 --- a/engines/sci/engine/kmenu.cpp +++ b/engines/sci/engine/kmenu.cpp @@ -39,8 +39,12 @@ reg_t kAddMenu(EngineState *s, int argc, reg_t *argv) { Common::String name = s->_segMan->getString(argv[0]); Common::String contents = s->_segMan->getString(argv[1]); +#ifdef INCLUDE_OLDGFX s->_menubar->addMenu(s->gfx_state, name, contents, s->titlebar_port->_font, argv[1]); +#else + // TODO +#endif return s->r_acc; @@ -104,10 +108,13 @@ static int _menu_go_down(Menubar *menubar, int menu_nr, int item_nr) { return item_nr; } +#ifdef INCLUDE_OLDGFX #define FULL_REDRAW \ s->visual->draw(Common::Point(0, 0)); \ gfxop_update(s->gfx_state); - +#else +#define FULL_REDRAW +#endif reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) { SegManager *segMan = s->_segMan; @@ -128,7 +135,9 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) { const int debug_parser = 0; #endif +#ifdef INCLUDE_OLDGFX gfxop_set_clip_zone(s->gfx_state, gfx_rect_fullscreen); +#endif /* Check whether we can claim the event directly as a keyboard or said event */ if (type & (SCI_EVT_KEYBOARD | SCI_EVT_SAID)) { @@ -181,6 +190,8 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) { if (menu_mode) { int old_item; int old_menu; + +#ifdef INCLUDE_OLDGFX GfxPort *port = sciw_new_menu(s, s->titlebar_port, s->_menubar, 0); item_nr = -1; @@ -193,6 +204,7 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) { sciw_set_menubar(s, s->titlebar_port, s->_menubar, menu_nr); FULL_REDRAW; +#endif old_item = -1; old_menu = -1; @@ -211,8 +223,10 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) { switch (ev.data) { case '`': +#ifdef INCLUDE_OLDGFX if (ev.buckybits & SCI_EVM_CTRL) s->visual->print(0); +#endif break; case SCI_K_ESC: @@ -263,7 +277,9 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) { { Common::Point curMousePos = s->_cursor->getPosition(); menu_mode = (curMousePos.y < 10); +#ifdef INCLUDE_OLDGFX claimed = !menu_mode && !s->_menubar->mapPointer(curMousePos, menu_nr, item_nr, toCommonRect(port->_bounds)); +#endif mouse_down = 0; } break; @@ -278,6 +294,7 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) { } if (mouse_down) +#ifdef INCLUDE_OLDGFX s->_menubar->mapPointer(s->_cursor->getPosition(), menu_nr, item_nr, toCommonRect(port->_bounds)); if ((item_nr > -1 && old_item == -1) || (menu_nr != old_menu)) { /* Update menu */ @@ -294,13 +311,15 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) { else { FULL_REDRAW; } - } /* ...if the menu changed. */ +#endif /* Remove the active menu item, if neccessary */ if (item_nr != old_item) { +#ifdef INCLUDE_OLDGFX port = sciw_toggle_item(port, &(s->_menubar->_menus[menu_nr]), old_item, false); port = sciw_toggle_item(port, &(s->_menubar->_menus[menu_nr]), item_nr, true); +#endif FULL_REDRAW; } @@ -309,6 +328,7 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) { } /* while (menu_mode) */ +#ifdef INCLUDE_OLDGFX if (port) { delete port; port = NULL; @@ -316,6 +336,7 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) { sciw_set_status_bar(s, s->titlebar_port, s->_statusBarText, s->status_bar_foreground, s->status_bar_background); gfxop_update(s->gfx_state); } +#endif FULL_REDRAW; } diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index 6d0433d62a..52e66e7fb5 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -168,7 +168,9 @@ reg_t kDisposeClone(EngineState *s, int argc, reg_t *argv) { victim_obj->markAsFreed(); +#ifdef INCLUDE_OLDGFX _k_view_list_mark_free(s, victim_addr); // Free on view list, if neccessary +#endif return s->r_acc; } diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index fa8cfaf2f7..dd9e09d229 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -748,9 +748,10 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { retval->execution_stack_base = 0; // Now copy all current state information +#ifdef INCLUDE_OLDGFX // Graphics and input state: - retval->gfx_state = s->gfx_state; retval->old_screen = 0; +#endif temp = retval->_sound._songlib; retval->_sound.sfx_init(retval->resMan, s->sfx_init_flags); @@ -781,7 +782,9 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { retval->bp_list = s->bp_list; retval->successor = NULL; +#ifdef INCLUDE_OLDGFX retval->pic_priority_table = (int *)(retval->gfx_state->pic) ? retval->gfx_state->pic->priorityTable : NULL; +#endif retval->_gameName = s->_gameName; retval->_sound._it = NULL; diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index 1d0eb18a7d..3e5abe7015 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -23,6 +23,8 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX + #include "sci/engine/state.h" #include "sci/engine/vm.h" #include "sci/engine/script.h" @@ -34,7 +36,6 @@ EngineState::EngineState(ResourceManager *res, Kernel *kernel, Vocabulary *voc, : resMan(res), _kernel(kernel), _voc(voc), _gui(gui), _cursor(cursor), _dirseeker(this) { gfx_state = 0; - old_screen = 0; sfx_init_flags = 0; sound_volume = 0; @@ -50,12 +51,11 @@ EngineState::EngineState(ResourceManager *res, Kernel *kernel, Vocabulary *voc, status_bar_foreground = 0; status_bar_background = 0; +#ifdef INCLUDE_OLDGFX + old_screen = 0; port = 0; - memset(ega_colors, 0, sizeof(ega_colors)); - visual = 0; - titlebar_port = 0; wm_port = 0; picture_port = 0; @@ -65,8 +65,8 @@ EngineState::EngineState(ResourceManager *res, Kernel *kernel, Vocabulary *voc, pic_animate = 0; dyn_views = 0; - drop_views = 0; +#endif _menubar = 0; diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h index a6ddd4019a..cb02e13614 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -134,7 +134,6 @@ public: SciGuiCursor *_cursor; /* Cursor functions */ GfxState *gfx_state; /**< Graphics state and driver */ - gfx_pixmap_t *old_screen; /**< Old screen content: Stored during kDrawPic() for kAnimate() */ SfxState _sound; /**< sound subsystem */ int sfx_init_flags; /**< flags the sfx subsystem was initialised with */ @@ -153,6 +152,9 @@ public: int status_bar_foreground, status_bar_background; +#ifdef INCLUDE_OLDGFX + gfx_pixmap_t *old_screen; /**< Old screen content: Stored during kDrawPic() for kAnimate() */ + GfxPort *port; /**< The currently active port */ gfx_color_t ega_colors[16]; /**< The 16 EGA colors- for SCI0(1) */ @@ -169,6 +171,7 @@ 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 */ @@ -296,6 +299,8 @@ private: bool _usesCdTrack; }; +#ifdef INCLUDE_OLDGFX + /** * Retrieves the gfx_pixmap_color_t associated with a game color index. * @param s game state @@ -310,6 +315,8 @@ void graph_restore_box(EngineState *s, reg_t handle); void assert_primary_widget_lists(EngineState *s); void reparentize_primary_widget_lists(EngineState *s, GfxPort *newport); +#endif + } // End of namespace Sci #endif // SCI_INCLUDE_ENGINE_H |
