diff options
Diffstat (limited to 'engines/sci')
43 files changed, 710 insertions, 453 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 3cff8ca840..6dea5b6668 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -651,8 +651,10 @@ bool Console::cmdSci0Palette(int argc, const char **argv) { return true; } +#ifdef INCLUDE_OLDGFX sci0_palette = atoi(argv[1]); cmdRedrawScreen(argc, argv); +#endif return false; } @@ -775,16 +777,20 @@ bool Console::cmdList(int argc, const char **argv) { } bool Console::cmdClearScreen(int argc, const char **argv) { +#ifdef INCLUDE_OLDGFX gfxop_clear_box(_vm->_gamestate->gfx_state, gfx_rect(0, 0, 320, 200)); gfxop_update_box(_vm->_gamestate->gfx_state, gfx_rect(0, 0, 320, 200)); +#endif return false; } bool Console::cmdRedrawScreen(int argc, const char **argv) { +#ifdef INCLUDE_OLDGFX _vm->_gamestate->visual->draw(Common::Point(0, 0)); gfxop_update_box(_vm->_gamestate->gfx_state, gfx_rect(0, 0, 320, 200)); gfxop_update(_vm->_gamestate->gfx_state); gfxop_sleep(_vm->_gamestate->gfx_state, 0); +#endif return false; } @@ -1008,10 +1014,12 @@ bool Console::cmdDrawPic(int argc, const char **argv) { if (argc == 4) flags = atoi(argv[3]); +#ifdef INCLUDE_OLDGFX gfxop_new_pic(_vm->_gamestate->gfx_state, atoi(argv[1]), flags, default_palette); gfxop_clear_box(_vm->_gamestate->gfx_state, gfx_rect(0, 0, 320, 200)); gfxop_update(_vm->_gamestate->gfx_state); gfxop_sleep(_vm->_gamestate->gfx_state, 0); +#endif return false; } @@ -1026,10 +1034,12 @@ bool Console::cmdDrawRect(int argc, const char **argv) { int col = CLIP<int>(atoi(argv[5]), 0, 15); +#ifdef INCLUDE_OLDGFX gfxop_set_clip_zone(_vm->_gamestate->gfx_state, gfx_rect_fullscreen); gfxop_fill_box(_vm->_gamestate->gfx_state, gfx_rect(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]), atoi(argv[4])), _vm->_gamestate->ega_colors[col]); gfxop_update(_vm->_gamestate->gfx_state); +#endif return false; } @@ -1046,9 +1056,12 @@ bool Console::cmdDrawCel(int argc, const char **argv) { int cel = atoi(argv[3]); int palette = atoi(argv[4]); + +#ifdef INCLUDE_OLDGFX gfxop_set_clip_zone(_vm->_gamestate->gfx_state, gfx_rect_fullscreen); gfxop_draw_cel(_vm->_gamestate->gfx_state, view, loop, cel, Common::Point(160, 100), _vm->_gamestate->ega_colors[0], palette); gfxop_update(_vm->_gamestate->gfx_state); +#endif return false; } @@ -1061,6 +1074,7 @@ bool Console::cmdViewInfo(int argc, const char **argv) { return true; } +#ifdef INCLUDE_OLDGFX int view = atoi(argv[1]); int palette = atoi(argv[2]); int loops, i; @@ -1095,6 +1109,7 @@ bool Console::cmdViewInfo(int argc, const char **argv) { } } } +#endif return true; } @@ -1145,7 +1160,9 @@ bool Console::cmdUpdateZone(int argc, const char **argv) { int width = atoi(argv[3]); int height = atoi(argv[4]); +#ifdef INCLUDE_OLDGFX _vm->_gamestate->gfx_state->driver->update(gfx_rect(x, y, width, height), Common::Point(x, y), GFX_BUFFER_FRONT); +#endif return false; } @@ -1158,6 +1175,7 @@ bool Console::cmdPropagateZone(int argc, const char **argv) { return true; } +#ifdef INCLUDE_OLDGFX int x = atoi(argv[1]); int y = atoi(argv[2]); int width = atoi(argv[3]); @@ -1173,6 +1191,7 @@ bool Console::cmdPropagateZone(int argc, const char **argv) { gfxop_update_box(_vm->_gamestate->gfx_state, rect); gfxop_update(_vm->_gamestate->gfx_state); gfxop_sleep(_vm->_gamestate->gfx_state, 0); +#endif return false; } @@ -1187,18 +1206,22 @@ bool Console::cmdFillScreen(int argc, const char **argv) { int col = CLIP<int>(atoi(argv[1]), 0, 15); +#ifdef INCLUDE_OLDGFX gfxop_set_clip_zone(_vm->_gamestate->gfx_state, gfx_rect_fullscreen); gfxop_fill_box(_vm->_gamestate->gfx_state, gfx_rect_fullscreen, _vm->_gamestate->ega_colors[col]); gfxop_update(_vm->_gamestate->gfx_state); +#endif return false; } bool Console::cmdCurrentPort(int argc, const char **argv) { +#ifdef INCLUDE_OLDGFX if (!_vm->_gamestate->port) DebugPrintf("There is no port active currently.\n"); else DebugPrintf("Current port ID: %d\n", _vm->_gamestate->port->_ID); +#endif return true; } @@ -1211,6 +1234,7 @@ bool Console::cmdPrintPort(int argc, const char **argv) { return true; } +#ifdef INCLUDE_OLDGFX GfxPort *port; if (!scumm_stricmp(argv[1], "current")) { @@ -1230,6 +1254,7 @@ bool Console::cmdPrintPort(int argc, const char **argv) { port->print(0); } } +#endif return true; } @@ -1245,42 +1270,50 @@ bool Console::cmdParseGrammar(int argc, const char **argv) { bool Console::cmdVisualState(int argc, const char **argv) { DebugPrintf("State of the current visual widget:\n"); +#ifdef INCLUDE_OLDGFX if (_vm->_gamestate->visual) _vm->_gamestate->visual->print(0); else DebugPrintf("The visual widget is uninitialized.\n"); +#endif return true; } bool Console::cmdFlushPorts(int argc, const char **argv) { +#ifdef INCLUDE_OLDGFX _vm->_gamestate->_gui->hideCursor(); DebugPrintf("Flushing dynamically allocated ports (for memory profiling)...\n"); delete _vm->_gamestate->visual; _vm->_gamestate->gfx_state->gfxResMan->freeAllResources(); _vm->_gamestate->visual = NULL; +#endif return true; } bool Console::cmdDynamicViews(int argc, const char **argv) { +#ifdef INCLUDE_OLDGFX DebugPrintf("List of active dynamic views:\n"); if (_vm->_gamestate->dyn_views) _vm->_gamestate->dyn_views->print(0); else DebugPrintf("The list is empty.\n"); +#endif return true; } bool Console::cmdDroppedViews(int argc, const char **argv) { +#ifdef INCLUDE_OLDGFX DebugPrintf("List of dropped dynamic views:\n"); if (_vm->_gamestate->drop_views) _vm->_gamestate->drop_views->print(0); else DebugPrintf("The list is empty.\n"); +#endif return true; } @@ -1293,7 +1326,9 @@ bool Console::cmdPriorityBands(int argc, const char **argv) { } int zone = CLIP<int>(atoi(argv[1]), 0, 15); +#ifdef INCLUDE_OLDGFX DebugPrintf("Zone %x starts at y=%d\n", zone, _find_priority_band(_vm->_gamestate, zone)); +#endif return true; } @@ -1305,6 +1340,7 @@ bool Console::cmdStatusBarColors(int argc, const char **argv) { return true; } +#ifdef INCLUDE_OLDGFX _vm->_gamestate->titlebar_port->_color = _vm->_gamestate->ega_colors[atoi(argv[1])]; _vm->_gamestate->titlebar_port->_bgcolor = _vm->_gamestate->ega_colors[atoi(argv[2])]; @@ -1314,6 +1350,7 @@ bool Console::cmdStatusBarColors(int argc, const char **argv) { sciw_set_status_bar(_vm->_gamestate, _vm->_gamestate->titlebar_port, _vm->_gamestate->_statusBarText, _vm->_gamestate->status_bar_foreground, _vm->_gamestate->status_bar_background); gfxop_update(_vm->_gamestate->gfx_state); +#endif return false; } 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 diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp index 1ab8381022..41205a0ecc 100644 --- a/engines/sci/gfx/gfx_driver.cpp +++ b/engines/sci/gfx/gfx_driver.cpp @@ -23,13 +23,15 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #include "common/scummsys.h" #include "common/system.h" #include "graphics/cursorman.h" #include "graphics/primitives.h" #include "graphics/surface.h" -#include "sci/sci.h" #include "sci/gui/gui_screen.h" #include "sci/gfx/gfx_driver.h" #include "sci/gfx/gfx_tools.h" @@ -199,3 +201,5 @@ void GfxDriver::animatePalette(int fromColor, int toColor, int stepCount) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_driver.h b/engines/sci/gfx/gfx_driver.h index 5fb6b35ef3..f0809a6ba1 100644 --- a/engines/sci/gfx/gfx_driver.h +++ b/engines/sci/gfx/gfx_driver.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #ifndef SCI_GFX_GFX_DRIVER_H #define SCI_GFX_GFX_DRIVER_H @@ -222,3 +225,5 @@ private: } // End of namespace Sci #endif // SCI_GFX_GFX_DRIVER_H + +#endif diff --git a/engines/sci/gfx/gfx_gui.cpp b/engines/sci/gfx/gfx_gui.cpp index fa4106d613..2cfe0f3a39 100644 --- a/engines/sci/gfx/gfx_gui.cpp +++ b/engines/sci/gfx/gfx_gui.cpp @@ -23,7 +23,9 @@ * */ -#include "sci/sci.h" +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #include "sci/engine/state.h" #include "sci/gfx/operations.h" #include "sci/gfx/gfx_widgets.h" @@ -660,3 +662,5 @@ void _k_view_list_mark_free(EngineState *s, reg_t off) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_gui.h b/engines/sci/gfx/gfx_gui.h index c8cb8650b0..be724ae873 100644 --- a/engines/sci/gfx/gfx_gui.h +++ b/engines/sci/gfx/gfx_gui.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #ifndef SCI_INCLUDE_SCI_WIDGETS_H #define SCI_INCLUDE_SCI_WIDGETS_H @@ -218,3 +221,5 @@ GfxPort *sciw_toggle_item(GfxPort *menu_port, Menu *menu, int selection, } // End of namespace Sci #endif // SCI_INCLUDE_SCI_WIDGETS_H + +#endif diff --git a/engines/sci/gfx/gfx_pixmap_scale.cpp b/engines/sci/gfx/gfx_pixmap_scale.cpp index 5b126f71d2..d542683cee 100644 --- a/engines/sci/gfx/gfx_pixmap_scale.cpp +++ b/engines/sci/gfx/gfx_pixmap_scale.cpp @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + /* Required defines: ** FUNCNAME: Function name ** SIZETYPE: Type used for each pixel @@ -126,3 +129,5 @@ void gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode) { } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp index 27858aa1b6..f78f5980e9 100644 --- a/engines/sci/gfx/gfx_resmgr.cpp +++ b/engines/sci/gfx/gfx_resmgr.cpp @@ -23,13 +23,15 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + // Resource manager core part // FIXME/TODO: The name "(Graphics) resource manager", and the associated // filenames, are misleading. This should be renamed to "Graphics manager" // or something like that. -#include "sci/sci.h" #include "sci/gfx/gfx_resource.h" #include "sci/gfx/gfx_tools.h" #include "sci/gfx/gfx_resmgr.h" @@ -526,3 +528,5 @@ gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_resmgr.h b/engines/sci/gfx/gfx_resmgr.h index 17598b0b53..5b3b728702 100644 --- a/engines/sci/gfx/gfx_resmgr.h +++ b/engines/sci/gfx/gfx_resmgr.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #ifndef SCI_GFX_GFX_RESMAN_H #define SCI_GFX_GFX_RESMAN_H @@ -282,3 +285,5 @@ private: } // End of namespace Sci #endif // SCI_GFX_GFX_RESMAN_H + +#endif diff --git a/engines/sci/gfx/gfx_resource.cpp b/engines/sci/gfx/gfx_resource.cpp index 4eae7942c5..fe2373e4e2 100644 --- a/engines/sci/gfx/gfx_resource.cpp +++ b/engines/sci/gfx/gfx_resource.cpp @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_resource.h" #include "sci/gfx/gfx_tools.h" @@ -73,3 +76,5 @@ void gfxr_free_pic(gfxr_pic_t *pic) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_resource.h b/engines/sci/gfx/gfx_resource.h index 56fb16295a..d3f1c727a5 100644 --- a/engines/sci/gfx/gfx_resource.h +++ b/engines/sci/gfx/gfx_resource.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + /** @file gfx_resource.h * SCI Resource library. */ @@ -32,6 +35,7 @@ #include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_driver.h" +#include "sci/gui/gui_helpers.h" #include "common/rect.h" @@ -75,15 +79,6 @@ extern PaletteEntry gfx_sci0_image_colors[][16]; */ extern Palette* gfx_sci0_pic_colors; - -enum ViewType { - kViewUnknown, - kViewEga, - kViewVga, - kViewVga11, - kViewAmiga -}; - struct gfxr_pic0_params_t { gfx_line_mode_t line_mode; /* one of GFX_LINE_MODE_* */ gfx_brush_mode_t brush_mode; @@ -290,3 +285,5 @@ gfx_pixmap_t *gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *reso } // End of namespace Sci #endif // SCI_GFX_GFX_RESOURCE_H + +#endif diff --git a/engines/sci/gfx/gfx_state_internal.h b/engines/sci/gfx/gfx_state_internal.h index 5334971e23..ec8219dc46 100644 --- a/engines/sci/gfx/gfx_state_internal.h +++ b/engines/sci/gfx/gfx_state_internal.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #ifndef SCI_GFX_GFX_STATE_INTERNAL_H #define SCI_GFX_GFX_STATE_INTERNAL_H @@ -410,3 +413,5 @@ public: } // End of namespace Sci #endif // SCI_GFX_GFX_STATE_INTERNAL_H + +#endif diff --git a/engines/sci/gfx/gfx_support.cpp b/engines/sci/gfx/gfx_support.cpp index 867e555907..8efe59b855 100644 --- a/engines/sci/gfx/gfx_support.cpp +++ b/engines/sci/gfx/gfx_support.cpp @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + /* Graphics support functions for drivers and replacements for driver functions ** for use with the graphical state manager */ @@ -274,3 +277,5 @@ void gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, rec } } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_system.h b/engines/sci/gfx/gfx_system.h index 31b799b8fe..d57c68552e 100644 --- a/engines/sci/gfx/gfx_system.h +++ b/engines/sci/gfx/gfx_system.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #ifndef SCI_GFX_GFX_SYSTEM #define SCI_GFX_GFX_SYSTEM @@ -279,3 +282,5 @@ struct gfx_color_t { } // End of namespace Sci #endif // SCI_GFX_GFX_SYSTEM + +#endif diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp index eef89ded1b..0ea488fe1d 100644 --- a/engines/sci/gfx/gfx_tools.cpp +++ b/engines/sci/gfx/gfx_tools.cpp @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #include "sci/gfx/gfx_tools.h" namespace Sci { @@ -156,3 +159,5 @@ gfx_pixmap_t *gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_tools.h b/engines/sci/gfx/gfx_tools.h index 2d15b51022..06543532e8 100644 --- a/engines/sci/gfx/gfx_tools.h +++ b/engines/sci/gfx/gfx_tools.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #ifndef SCI_GFX_GFX_TOOLS_H #define SCI_GFX_GFX_TOOLS_H @@ -184,3 +187,5 @@ void gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, } // End of namespace Sci #endif // SCI_GFX_GFX_TOOLS_H + +#endif diff --git a/engines/sci/gfx/gfx_widgets.cpp b/engines/sci/gfx/gfx_widgets.cpp index f667381fdc..d260e66cfc 100644 --- a/engines/sci/gfx/gfx_widgets.cpp +++ b/engines/sci/gfx/gfx_widgets.cpp @@ -23,7 +23,9 @@ * */ -#include "sci/sci.h" +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #include "sci/gfx/gfx_gui.h" // for kWindowAutoRestore #include "sci/gfx/gfx_widgets.h" #include "sci/gfx/gfx_state_internal.h" @@ -1769,3 +1771,5 @@ GfxDynView *gfxw_picviewize_dynview(GfxDynView *dynview) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_widgets.h b/engines/sci/gfx/gfx_widgets.h index 6369eabd19..d30af8ce4e 100644 --- a/engines/sci/gfx/gfx_widgets.h +++ b/engines/sci/gfx/gfx_widgets.h @@ -23,6 +23,8 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX #ifndef SCI_GFX_GFX_WIDGETS_H #define SCI_GFX_GFX_WIDGETS_H @@ -471,3 +473,5 @@ void gfxw_port_auto_restore_background(GfxVisual *visual, GfxPort *window, } // End of namespace Sci #endif // SCI_GFX_GFX_WIDGETS_H + +#endif diff --git a/engines/sci/gfx/menubar.cpp b/engines/sci/gfx/menubar.cpp index 62120097ab..cf3c3a7414 100644 --- a/engines/sci/gfx/menubar.cpp +++ b/engines/sci/gfx/menubar.cpp @@ -77,6 +77,7 @@ MenuItem::MenuItem() { _tag = 0; } +#ifdef INCLUDE_OLDGFX int Menu::addMenuItem(GfxState *state, MenuType type, const char *left, const char *right, int font, int key, int modifiers, int tag, reg_t text_pos) { @@ -107,14 +108,18 @@ int Menu::addMenuItem(GfxState *state, MenuType type, const char *left, const ch } if (right) { +#ifdef INCLUDE_OLDGFX gfxop_get_text_params(state, font, item->_keytext.c_str(), SIZE_INF, &width, &height, 0, NULL, NULL, NULL); +#endif total_left_size = MENU_BOX_CENTER_PADDING + width; } item->_enabled = 1; item->_tag = tag; item->_textPos = text_pos; +#ifdef INCLUDE_OLDGFX gfxop_get_text_params(state, font, left, SIZE_INF, &width, &height, 0, NULL, NULL, NULL); +#endif _items.push_back(newItem); @@ -133,7 +138,9 @@ void Menubar::addMenu(GfxState *state, const Common::String &title, const Common menu._title = title; +#ifdef INCLUDE_OLDGFX gfxop_get_text_params(state, font, title.c_str(), SIZE_INF, &(menu._titleWidth), &height, 0, NULL, NULL, NULL); +#endif const char *entries_p = entries.c_str(); @@ -169,7 +176,9 @@ void Menubar::addMenu(GfxState *state, const Common::String &title, const Common beginning = entries_base; beginning.offset -= string_len + 1; +#ifdef INCLUDE_OLDGFX c_width = menu.addMenuItem(state, entrytype, left, NULL, font, 0, 0, tag, beginning); +#endif if (c_width > max_width) max_width = c_width; @@ -269,6 +278,8 @@ void Menubar::addMenu(GfxState *state, const Common::String &title, const Common _menus.push_back(menu); } +#endif + bool MenuItem::matchKey(int message, int modifiers) { if ((_key == message) && ((modifiers & (SCI_EVM_CTRL | SCI_EVM_ALT)) == _modifiers)) return true; diff --git a/engines/sci/gfx/menubar.h b/engines/sci/gfx/menubar.h index 5a440a480b..4c7281a36d 100644 --- a/engines/sci/gfx/menubar.h +++ b/engines/sci/gfx/menubar.h @@ -28,6 +28,7 @@ #ifndef SCI_GFX_SCI_MENUBAR_H #define SCI_GFX_SCI_MENUBAR_H +#include "sci/sci.h" // for INCLUDE_OLDGFX #include "sci/engine/vm_types.h" #include "sci/gfx/operations.h" @@ -138,8 +139,10 @@ public: //protected: // FIXME: This should be (partially) turned into a MenuItem constructor +#ifdef INCLUDE_OLDGFX int addMenuItem(GfxState *state, MenuType type, const char *left, const char *right, int font, int key, int modifiers, int tag, reg_t text_pos); +#endif }; @@ -171,8 +174,9 @@ public: * @param[in] font The font which is to be used for drawing * @param[in] entries_base Segmented VM address of the entries string */ +#ifdef INCLUDE_OLDGFX void addMenu(GfxState *state, const Common::String &title, const Common::String &entries, int font, reg_t entries_base); - +#endif /** * Sets the attributes for a menu item. diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index a89968598b..d50341887d 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -27,7 +27,9 @@ #include "sci/sci.h" #include "sci/gfx/operations.h" +#ifdef INCLUDE_OLDGFX #include "sci/gui32/font.h" +#endif #include "sci/console.h" #include "common/system.h" @@ -35,6 +37,8 @@ namespace Sci { +#ifdef INCLUDE_OLDGFX + #define PRECISE_PRIORITY_MAP // Duplicate all operations on the local priority map as appropriate #undef GFXW_DEBUG_DIRTY @@ -871,6 +875,341 @@ void gfxop_disable_dirty_frames(GfxState *state) { state->disable_dirty = 1; } +// View operations + +void gfxop_get_cel_parameters(GfxState *state, int nr, int loop, int cel, int *width, int *height, Common::Point *offset) { + gfxr_view_t *view = NULL; + gfx_pixmap_t *pxm = NULL; + + view = state->gfxResMan->getView(nr, &loop, &cel, 0); + + if (!view) + error("[GFX] Attempt to get cel parameters for invalid view %d", nr); + + pxm = view->loops[loop].cels[cel]; + *width = pxm->index_width; + *height = pxm->index_height; + offset->x = pxm->xoffset; + offset->y = pxm->yoffset; +} + +static void _gfxop_draw_cel_buffer(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int static_buf, int palette) { + int priority = (color.mask & GFX_MASK_PRIORITY) ? color.priority : -1; + int control = (color.mask & GFX_MASK_CONTROL) ? color.control : -1; + gfxr_view_t *view = NULL; + gfx_pixmap_t *pxm = NULL; + int old_x, old_y; + + view = state->gfxResMan->getView(nr, &loop, &cel, palette); + + if (!view) { + warning("[GFX] Attempt to draw loop/cel %d/%d in invalid view %d\n", loop, cel, nr); + return; + } + pxm = view->loops[loop].cels[cel]; + + old_x = pos.x -= pxm->xoffset; + old_y = pos.y -= pxm->yoffset; + + pos.x *= state->driver->getMode()->scaleFactor; + pos.y *= state->driver->getMode()->scaleFactor; + + if (!static_buf) + _gfxop_add_dirty(state, gfx_rect(old_x, old_y, pxm->index_width, pxm->index_height)); + + _gfxop_draw_pixmap(state->driver, pxm, priority, control, gfx_rect(0, 0, pxm->width, pxm->height), + gfx_rect(pos.x, pos.y, pxm->width, pxm->height), state->clip_zone, static_buf , state->control_map, + static_buf ? state->static_priority_map : state->priority_map); +} + +void gfxop_draw_cel(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette) { + _gfxop_draw_cel_buffer(state, nr, loop, cel, pos, color, 0, palette); +} + +void gfxop_draw_cel_static(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette) { + rect_t oldclip = state->clip_zone; + + state->clip_zone = gfx_rect_fullscreen; + _gfxop_scale_rect(&(state->clip_zone), state->driver->getMode()); + gfxop_draw_cel_static_clipped(state, nr, loop, cel, pos, color, palette); + // Except that the area it's clipped against is... unusual ;-) + state->clip_zone = oldclip; +} + +void gfxop_draw_cel_static_clipped(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette) { + _gfxop_draw_cel_buffer(state, nr, loop, cel, pos, color, 1, palette); +} + +// Pic operations + +static void _gfxop_set_pic(GfxState *state) { + gfx_copy_pixmap_box_i(state->control_map, state->pic->control_map, gfx_rect(0, 0, 320, 200)); + gfx_copy_pixmap_box_i(state->priority_map, state->pic_unscaled->priority_map, gfx_rect(0, 0, 320, 200)); + gfx_copy_pixmap_box_i(state->static_priority_map, state->pic_unscaled->priority_map, gfx_rect(0, 0, 320, 200)); + + // Reset global palette to this PIC's palette + // FIXME: The _gfxop_install_pixmap call below updates the OSystem palette. + // This is too soon, since it causes brief palette corruption until the + // screen is updated too. (Possibly related: EngineState::pic_not_valid .) + if (state->pic->visual_map->palette) { + state->pic->visual_map->palette->forceInto(SCREEN_PALETTE); + _gfxop_install_pixmap(state->driver, state->pic->visual_map); + } + + state->driver->setStaticBuffer(state->pic->visual_map, state->pic->priority_map); +} + +void gfxop_new_pic(GfxState *state, int nr, int flags, int default_palette) { + state->gfxResMan->tagResources(); + state->tag_mode = 1; + state->palette_nr = default_palette; + state->pic = state->gfxResMan->getPic(nr, GFX_MASK_VISUAL, flags, default_palette, true); + + if (state->driver->getMode()->scaleFactor == 1 && state->driver->getMode()->scaleFactor == 1) { + state->pic_unscaled = state->pic; + } else { + state->pic_unscaled = state->gfxResMan->getPic(nr, GFX_MASK_VISUAL, flags, default_palette, false); + } + + if (!state->pic || !state->pic_unscaled) { + warning("Could not retrieve background pic %d", nr); + if (state->pic) { + warning(" -- Inconsistency: scaled pic _was_ retrieved!"); + } + + if (state->pic_unscaled) { + warning(" -- Inconsistency: unscaled pic _was_ retrieved!"); + } + + error("Error occured in gfxop_new_pic()"); + state->pic = state->pic_unscaled = NULL; + } + + state->pic_nr = nr; + + _gfxop_set_pic(state); +} + +void gfxop_add_to_pic(GfxState *state, int nr, int flags, int default_palette) { + if (!state->pic) + error("Attempt to add to pic with no pic active"); + + state->pic = state->gfxResMan->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); + + if (!state->pic) + error("Could not add pic #%d to pic #%d", state->pic_nr, nr); + + state->pic_unscaled = state->gfxResMan->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); + + _gfxop_set_pic(state); +} + +// Text operations + +void gfxop_get_text_params(GfxState *state, int font_nr, const char *text, int maxwidth, int *width, int *height, int text_flags, + int *lines_nr, int *lineheight, int *lastline_width) { + Common::Array<TextFragment> fragments; + bool textsplits; + gfx_bitmap_font_t *font; + + font = state->gfxResMan->getFont(font_nr); + + if (!font) + error("Attempt to calculate text size with invalid font #%d", font_nr); + + textsplits = gfxr_font_calculate_size(fragments, font, maxwidth, text, width, height, lineheight, lastline_width, text_flags); + + if (!textsplits) + error("Could not calculate text size"); + + if (lines_nr) + *lines_nr = fragments.size(); +} + +TextHandle *gfxop_new_text(GfxState *state, int font_nr, const Common::String &text, int maxwidth, gfx_alignment_t halign, + gfx_alignment_t valign, gfx_color_t color1, gfx_color_t color2, gfx_color_t bg_color, int flags) { + TextHandle *handle; + gfx_bitmap_font_t *font; + + // mapping text colors to palette + gfxop_set_color(state, &color1, color1); + gfxop_set_color(state, &color2, color2); + gfxop_set_color(state, &bg_color, bg_color); + + font = state->gfxResMan->getFont(font_nr); + + if (!font) { + error("Attempt to draw text with invalid font #%d", font_nr); + return NULL; + } + + handle = new TextHandle(); + + handle->_text = text; + handle->halign = halign; + handle->valign = valign; + handle->line_height = font->line_height; + + bool result = gfxr_font_calculate_size(handle->lines, font, maxwidth, handle->_text.c_str(), &(handle->width), &(handle->height), + NULL, NULL, flags); + + if (!result) { + error("Could not calculate text parameters in font #%d", font_nr); + delete handle; + return NULL; + } + + if (flags & kFontNoNewlines) { + handle->lines.resize(1); + handle->lines[0].length = text.size(); + } + + handle->text_pixmaps.resize(handle->lines.size()); + + for (uint i = 0; i < handle->lines.size(); i++) { + int chars_nr = handle->lines[i].length; + + handle->text_pixmaps[i] = gfxr_draw_font(font, handle->lines[i].offset, chars_nr, + (color1.mask & GFX_MASK_VISUAL) ? &color1.visual : NULL, + (color2.mask & GFX_MASK_VISUAL) ? &color2.visual : NULL, + (bg_color.mask & GFX_MASK_VISUAL) ? &bg_color.visual : NULL); + + if (!handle->text_pixmaps[i]) { + error("Failed to draw text pixmap for line %d/%d", i, handle->lines.size()); + delete handle; + return NULL; + } + } + + handle->font = font; + + handle->priority = (color1.mask & GFX_MASK_PRIORITY) ? color1.priority : -1; + handle->control = (color1.mask & GFX_MASK_CONTROL) ? color1.control : -1; + + return handle; +} + +TextHandle::TextHandle() { + line_height = 0; + font = 0; + + width = height = 0; + + priority = control = 0; + halign = valign = ALIGN_BOTTOM; +} + +TextHandle::~TextHandle() { + for (uint j = 0; j < text_pixmaps.size(); j++) + if (text_pixmaps[j]) + gfx_free_pixmap(text_pixmaps[j]); +} + +void gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { + int line_height; + rect_t pos; + + if (!handle) + error("Attempt to draw text with NULL handle"); + + if (handle->lines.empty()) { + debugC(2, kDebugLevelGraphics, "Skipping draw_text operation because number of lines is zero\n"); + return; + } + + _gfxop_scale_rect(&zone, state->driver->getMode()); + + line_height = handle->line_height * state->driver->getMode()->scaleFactor; + + pos.y = zone.y; + + switch (handle->valign) { + + case ALIGN_TOP: + break; + + case ALIGN_CENTER: + pos.y += (zone.height - (line_height * handle->lines.size())) >> 1; + break; + + case ALIGN_BOTTOM: + pos.y += (zone.height - (line_height * handle->lines.size())); + break; + + default: + error("Invalid vertical alignment %d", handle->valign); + } + + for (uint i = 0; i < handle->lines.size(); i++) { + + gfx_pixmap_t *pxm = handle->text_pixmaps[i]; + + if (!pxm->data) { + gfx_xlate_pixmap(pxm, state->driver->getMode()); + } + if (!pxm) + error("Could not find text pixmap %d/%d", i, handle->lines.size()); + + pos.x = zone.x; + + switch (handle->halign) { + + case ALIGN_LEFT: + break; + + case ALIGN_CENTER: + pos.x += (zone.width - pxm->width) >> 1; + break; + + case ALIGN_RIGHT: + pos.x += (zone.width - pxm->width); + break; + + default: + error("Invalid vertical alignment %d", handle->valign); + } + + pos.width = pxm->width; + pos.height = pxm->height; + + _gfxop_add_dirty(state, pos); + _gfxop_draw_pixmap(state->driver, pxm, handle->priority, handle->control, + gfx_rect(0, 0, pxm->width, pxm->height), pos, state->clip_zone, 0, state->control_map, state->priority_map); + + pos.y += line_height; + } +} + +gfx_pixmap_t *gfxop_grab_pixmap(GfxState *state, rect_t area) { + gfx_pixmap_t *pixmap = NULL; + rect_t resultzone; // Ignored for this application + + _gfxop_scale_rect(&area, state->driver->getMode()); + _gfxop_grab_pixmap(state, &pixmap, area.x, area.y, area.width, area.height, 0, &resultzone); + + return pixmap; +} + +void gfxop_draw_pixmap(GfxState *state, gfx_pixmap_t *pxm, rect_t zone, Common::Point pos) { + rect_t target = gfx_rect(pos.x, pos.y, zone.width, zone.height); + + if (!pxm) + error("Attempt to draw NULL pixmap"); + + _gfxop_add_dirty(state, target); + + _gfxop_scale_rect(&zone, state->driver->getMode()); + _gfxop_scale_rect(&target, state->driver->getMode()); + + return _gfxop_draw_pixmap(state->driver, pxm, -1, -1, zone, target, gfx_rect(0, 0, 320*state->driver->getMode()->scaleFactor, + 200*state->driver->getMode()->scaleFactor), 0, NULL, NULL); +} + + + +#endif // INCLUDE_OLDGFX + + // Pointer and IO ops void gfxop_sleep(GfxState *state, uint32 msecs) { @@ -1003,7 +1342,7 @@ static int _gfxop_numlockify(int c) { } } -static sci_event_t scummvm_get_event(GfxDriver *drv) { +static sci_event_t scummvm_get_event() { static int _modifierStates = 0; // FIXME: Avoid non-const global vars sci_event_t input = { SCI_EVT_NONE, 0, 0, 0 }; @@ -1216,7 +1555,7 @@ sci_event_t gfxop_get_event(GfxState *state, unsigned int mask) { // Get all queued events from graphics driver do { - event = scummvm_get_event(state->driver); + event = scummvm_get_event(); if (event.type != SCI_EVT_NONE) state->_events.push_back(event); } while (event.type != SCI_EVT_NONE); @@ -1263,334 +1602,4 @@ sci_event_t gfxop_get_event(GfxState *state, unsigned int mask) { return event; } -// View operations - -void gfxop_get_cel_parameters(GfxState *state, int nr, int loop, int cel, int *width, int *height, Common::Point *offset) { - gfxr_view_t *view = NULL; - gfx_pixmap_t *pxm = NULL; - - view = state->gfxResMan->getView(nr, &loop, &cel, 0); - - if (!view) - error("[GFX] Attempt to get cel parameters for invalid view %d", nr); - - pxm = view->loops[loop].cels[cel]; - *width = pxm->index_width; - *height = pxm->index_height; - offset->x = pxm->xoffset; - offset->y = pxm->yoffset; -} - -static void _gfxop_draw_cel_buffer(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int static_buf, int palette) { - int priority = (color.mask & GFX_MASK_PRIORITY) ? color.priority : -1; - int control = (color.mask & GFX_MASK_CONTROL) ? color.control : -1; - gfxr_view_t *view = NULL; - gfx_pixmap_t *pxm = NULL; - int old_x, old_y; - - view = state->gfxResMan->getView(nr, &loop, &cel, palette); - - if (!view) { - warning("[GFX] Attempt to draw loop/cel %d/%d in invalid view %d\n", loop, cel, nr); - return; - } - pxm = view->loops[loop].cels[cel]; - - old_x = pos.x -= pxm->xoffset; - old_y = pos.y -= pxm->yoffset; - - pos.x *= state->driver->getMode()->scaleFactor; - pos.y *= state->driver->getMode()->scaleFactor; - - if (!static_buf) - _gfxop_add_dirty(state, gfx_rect(old_x, old_y, pxm->index_width, pxm->index_height)); - - _gfxop_draw_pixmap(state->driver, pxm, priority, control, gfx_rect(0, 0, pxm->width, pxm->height), - gfx_rect(pos.x, pos.y, pxm->width, pxm->height), state->clip_zone, static_buf , state->control_map, - static_buf ? state->static_priority_map : state->priority_map); -} - -void gfxop_draw_cel(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette) { - _gfxop_draw_cel_buffer(state, nr, loop, cel, pos, color, 0, palette); -} - -void gfxop_draw_cel_static(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette) { - rect_t oldclip = state->clip_zone; - - state->clip_zone = gfx_rect_fullscreen; - _gfxop_scale_rect(&(state->clip_zone), state->driver->getMode()); - gfxop_draw_cel_static_clipped(state, nr, loop, cel, pos, color, palette); - // Except that the area it's clipped against is... unusual ;-) - state->clip_zone = oldclip; -} - -void gfxop_draw_cel_static_clipped(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette) { - _gfxop_draw_cel_buffer(state, nr, loop, cel, pos, color, 1, palette); -} - -// Pic operations - -static void _gfxop_set_pic(GfxState *state) { - gfx_copy_pixmap_box_i(state->control_map, state->pic->control_map, gfx_rect(0, 0, 320, 200)); - gfx_copy_pixmap_box_i(state->priority_map, state->pic_unscaled->priority_map, gfx_rect(0, 0, 320, 200)); - gfx_copy_pixmap_box_i(state->static_priority_map, state->pic_unscaled->priority_map, gfx_rect(0, 0, 320, 200)); - - // Reset global palette to this PIC's palette - // FIXME: The _gfxop_install_pixmap call below updates the OSystem palette. - // This is too soon, since it causes brief palette corruption until the - // screen is updated too. (Possibly related: EngineState::pic_not_valid .) - if (state->pic->visual_map->palette) { - state->pic->visual_map->palette->forceInto(SCREEN_PALETTE); - _gfxop_install_pixmap(state->driver, state->pic->visual_map); - } - - state->driver->setStaticBuffer(state->pic->visual_map, state->pic->priority_map); -} - -void gfxop_new_pic(GfxState *state, int nr, int flags, int default_palette) { - state->gfxResMan->tagResources(); - state->tag_mode = 1; - state->palette_nr = default_palette; - state->pic = state->gfxResMan->getPic(nr, GFX_MASK_VISUAL, flags, default_palette, true); - - if (state->driver->getMode()->scaleFactor == 1 && state->driver->getMode()->scaleFactor == 1) { - state->pic_unscaled = state->pic; - } else { - state->pic_unscaled = state->gfxResMan->getPic(nr, GFX_MASK_VISUAL, flags, default_palette, false); - } - - if (!state->pic || !state->pic_unscaled) { - warning("Could not retrieve background pic %d", nr); - if (state->pic) { - warning(" -- Inconsistency: scaled pic _was_ retrieved!"); - } - - if (state->pic_unscaled) { - warning(" -- Inconsistency: unscaled pic _was_ retrieved!"); - } - - error("Error occured in gfxop_new_pic()"); - state->pic = state->pic_unscaled = NULL; - } - - state->pic_nr = nr; - - _gfxop_set_pic(state); -} - -void gfxop_add_to_pic(GfxState *state, int nr, int flags, int default_palette) { - if (!state->pic) - error("Attempt to add to pic with no pic active"); - - state->pic = state->gfxResMan->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); - - if (!state->pic) - error("Could not add pic #%d to pic #%d", state->pic_nr, nr); - - state->pic_unscaled = state->gfxResMan->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); - - _gfxop_set_pic(state); -} - -// Text operations - -void gfxop_get_text_params(GfxState *state, int font_nr, const char *text, int maxwidth, int *width, int *height, int text_flags, - int *lines_nr, int *lineheight, int *lastline_width) { - Common::Array<TextFragment> fragments; - bool textsplits; - gfx_bitmap_font_t *font; - - font = state->gfxResMan->getFont(font_nr); - - if (!font) - error("Attempt to calculate text size with invalid font #%d", font_nr); - - textsplits = gfxr_font_calculate_size(fragments, font, maxwidth, text, width, height, lineheight, lastline_width, text_flags); - - if (!textsplits) - error("Could not calculate text size"); - - if (lines_nr) - *lines_nr = fragments.size(); -} - -TextHandle *gfxop_new_text(GfxState *state, int font_nr, const Common::String &text, int maxwidth, gfx_alignment_t halign, - gfx_alignment_t valign, gfx_color_t color1, gfx_color_t color2, gfx_color_t bg_color, int flags) { - TextHandle *handle; - gfx_bitmap_font_t *font; - - // mapping text colors to palette - gfxop_set_color(state, &color1, color1); - gfxop_set_color(state, &color2, color2); - gfxop_set_color(state, &bg_color, bg_color); - - font = state->gfxResMan->getFont(font_nr); - - if (!font) { - error("Attempt to draw text with invalid font #%d", font_nr); - return NULL; - } - - handle = new TextHandle(); - - handle->_text = text; - handle->halign = halign; - handle->valign = valign; - handle->line_height = font->line_height; - - bool result = gfxr_font_calculate_size(handle->lines, font, maxwidth, handle->_text.c_str(), &(handle->width), &(handle->height), - NULL, NULL, flags); - - if (!result) { - error("Could not calculate text parameters in font #%d", font_nr); - delete handle; - return NULL; - } - - if (flags & kFontNoNewlines) { - handle->lines.resize(1); - handle->lines[0].length = text.size(); - } - - handle->text_pixmaps.resize(handle->lines.size()); - - for (uint i = 0; i < handle->lines.size(); i++) { - int chars_nr = handle->lines[i].length; - - handle->text_pixmaps[i] = gfxr_draw_font(font, handle->lines[i].offset, chars_nr, - (color1.mask & GFX_MASK_VISUAL) ? &color1.visual : NULL, - (color2.mask & GFX_MASK_VISUAL) ? &color2.visual : NULL, - (bg_color.mask & GFX_MASK_VISUAL) ? &bg_color.visual : NULL); - - if (!handle->text_pixmaps[i]) { - error("Failed to draw text pixmap for line %d/%d", i, handle->lines.size()); - delete handle; - return NULL; - } - } - - handle->font = font; - - handle->priority = (color1.mask & GFX_MASK_PRIORITY) ? color1.priority : -1; - handle->control = (color1.mask & GFX_MASK_CONTROL) ? color1.control : -1; - - return handle; -} - -TextHandle::TextHandle() { - line_height = 0; - font = 0; - - width = height = 0; - - priority = control = 0; - halign = valign = ALIGN_BOTTOM; -} - -TextHandle::~TextHandle() { - for (uint j = 0; j < text_pixmaps.size(); j++) - if (text_pixmaps[j]) - gfx_free_pixmap(text_pixmaps[j]); -} - -void gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { - int line_height; - rect_t pos; - - if (!handle) - error("Attempt to draw text with NULL handle"); - - if (handle->lines.empty()) { - debugC(2, kDebugLevelGraphics, "Skipping draw_text operation because number of lines is zero\n"); - return; - } - - _gfxop_scale_rect(&zone, state->driver->getMode()); - - line_height = handle->line_height * state->driver->getMode()->scaleFactor; - - pos.y = zone.y; - - switch (handle->valign) { - - case ALIGN_TOP: - break; - - case ALIGN_CENTER: - pos.y += (zone.height - (line_height * handle->lines.size())) >> 1; - break; - - case ALIGN_BOTTOM: - pos.y += (zone.height - (line_height * handle->lines.size())); - break; - - default: - error("Invalid vertical alignment %d", handle->valign); - } - - for (uint i = 0; i < handle->lines.size(); i++) { - - gfx_pixmap_t *pxm = handle->text_pixmaps[i]; - - if (!pxm->data) { - gfx_xlate_pixmap(pxm, state->driver->getMode()); - } - if (!pxm) - error("Could not find text pixmap %d/%d", i, handle->lines.size()); - - pos.x = zone.x; - - switch (handle->halign) { - - case ALIGN_LEFT: - break; - - case ALIGN_CENTER: - pos.x += (zone.width - pxm->width) >> 1; - break; - - case ALIGN_RIGHT: - pos.x += (zone.width - pxm->width); - break; - - default: - error("Invalid vertical alignment %d", handle->valign); - } - - pos.width = pxm->width; - pos.height = pxm->height; - - _gfxop_add_dirty(state, pos); - _gfxop_draw_pixmap(state->driver, pxm, handle->priority, handle->control, - gfx_rect(0, 0, pxm->width, pxm->height), pos, state->clip_zone, 0, state->control_map, state->priority_map); - - pos.y += line_height; - } -} - -gfx_pixmap_t *gfxop_grab_pixmap(GfxState *state, rect_t area) { - gfx_pixmap_t *pixmap = NULL; - rect_t resultzone; // Ignored for this application - - _gfxop_scale_rect(&area, state->driver->getMode()); - _gfxop_grab_pixmap(state, &pixmap, area.x, area.y, area.width, area.height, 0, &resultzone); - - return pixmap; -} - -void gfxop_draw_pixmap(GfxState *state, gfx_pixmap_t *pxm, rect_t zone, Common::Point pos) { - rect_t target = gfx_rect(pos.x, pos.y, zone.width, zone.height); - - if (!pxm) - error("Attempt to draw NULL pixmap"); - - _gfxop_add_dirty(state, target); - - _gfxop_scale_rect(&zone, state->driver->getMode()); - _gfxop_scale_rect(&target, state->driver->getMode()); - - return _gfxop_draw_pixmap(state->driver, pxm, -1, -1, zone, target, gfx_rect(0, 0, 320*state->driver->getMode()->scaleFactor, - 200*state->driver->getMode()->scaleFactor), 0, NULL, NULL); -} - } // End of namespace Sci diff --git a/engines/sci/gfx/operations.h b/engines/sci/gfx/operations.h index 1e3dd41b52..2f98bfbd2e 100644 --- a/engines/sci/gfx/operations.h +++ b/engines/sci/gfx/operations.h @@ -28,15 +28,20 @@ #ifndef SCI_GFX_GFX_OPERATIONS_H #define SCI_GFX_GFX_OPERATIONS_H +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX #include "sci/gfx/gfx_resmgr.h" #include "sci/gfx/gfx_tools.h" #include "sci/gfx/gfx_system.h" +#endif #include "sci/uinput.h" #include "common/list.h" namespace Sci { +#ifdef INCLUDE_OLDGFX + struct TextFragment; /* Threshold in color index mode to differentiate between visible and non-visible stuff. @@ -86,8 +91,10 @@ enum gfx_box_shade_t { typedef Common::List<rect_t> DirtyRectList; +#endif // INCLUDE_OLDGFX struct GfxState { +#ifdef INCLUDE_OLDGFX rect_t clip_zone_unscaled; /**< The current UNSCALED clipping zone */ rect_t clip_zone; /**< The current SCALED clipping zone; a cached scaled version of clip_zone_unscaled */ @@ -109,15 +116,18 @@ struct GfxState { int pic_nr; /**< Number of the current pic */ int palette_nr; /**< Palette number of the current pic */ - Common::List<sci_event_t> _events; - gfxr_pic_t *pic, *pic_unscaled; /**< The background picture and its unscaled equivalent */ rect_t pic_port_bounds; /**< Picture port bounds */ DirtyRectList _dirtyRects; /**< Dirty rectangles */ +#endif + + Common::List<sci_event_t> _events; }; +#ifdef INCLUDE_OLDGFX + /** @name Fundamental operations */ /** @{ */ @@ -306,30 +316,6 @@ void gfxop_set_color(GfxState *state, gfx_color_t *color, int r, int g, int b, /** @} */ -/** @name Pointer and IO ops */ -/** @{ */ - -/** - * Suspends program execution for the specified amount of milliseconds. - * - * The mouse pointer will be redrawn continually, if applicable - * - * @param[in] state The state affected - * @param[in] msecs The amount of milliseconds to wait - */ -void gfxop_sleep(GfxState *state, uint32 msecs); - -/** - * Retrieves the next input event from the driver. - * - * @param[in] state The affected state - * @param[in] mask The event mask to poll from (see uinput.h) - * @return The next event in the driver's event queue, or a NONE event - * if no event matching the mask was found. - */ -sci_event_t gfxop_get_event(GfxState *state, unsigned int mask); -/** @} */ - /** @name View operations */ /** @{ */ @@ -537,6 +523,33 @@ void gfxdr_add_dirty(DirtyRectList &list, rect_t box); int _gfxop_clip(rect_t *rect, rect_t clipzone); /** @} */ +#endif // INCLUDE_OLDGFX + +/** @name Pointer and IO ops */ +/** @{ */ + +/** + * Suspends program execution for the specified amount of milliseconds. + * + * The mouse pointer will be redrawn continually, if applicable + * + * @param[in] state The state affected + * @param[in] msecs The amount of milliseconds to wait + */ +void gfxop_sleep(GfxState *state, uint32 msecs); + +/** + * Retrieves the next input event from the driver. + * + * @param[in] state The affected state + * @param[in] mask The event mask to poll from (see uinput.h) + * @return The next event in the driver's event queue, or a NONE event + * if no event matching the mask was found. + */ +sci_event_t gfxop_get_event(GfxState *state, unsigned int mask); +/** @} */ + + } // End of namespace Sci #endif // SCI_GFX_GFX_OPERATIONS_H diff --git a/engines/sci/gfx/palette.cpp b/engines/sci/gfx/palette.cpp index eb3382c5de..62e70e2a6d 100644 --- a/engines/sci/gfx/palette.cpp +++ b/engines/sci/gfx/palette.cpp @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #include "sci/gfx/palette.h" #include "sci/gfx/gfx_system.h" @@ -323,3 +326,5 @@ Palette *Palette::copy() { } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/palette.h b/engines/sci/gfx/palette.h index 82a447e001..b74eebd72e 100644 --- a/engines/sci/gfx/palette.h +++ b/engines/sci/gfx/palette.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #ifndef SCI_GFX_PALETTE_H #define SCI_GFX_PALETTE_H @@ -122,3 +125,5 @@ private: } // End of namespace Sci #endif // SCI_GFX_PALETTE_H + +#endif diff --git a/engines/sci/gui/gui_helpers.h b/engines/sci/gui/gui_helpers.h index efc9548dcb..191b7039a1 100644 --- a/engines/sci/gui/gui_helpers.h +++ b/engines/sci/gui/gui_helpers.h @@ -124,6 +124,14 @@ enum controlStateFlags { kControlStateDitherFramed = 0x1000 ///< 0001 0000 0000 0000 - widgets surrounded by a dithered frame (used in kgraphics) }; +enum ViewType { + kViewUnknown, + kViewEga, + kViewVga, + kViewVga11, + kViewAmiga +}; + } // End of namespace Sci #endif diff --git a/engines/sci/gui32/font.cpp b/engines/sci/gui32/font.cpp index 6fe4b7508b..aa5370bce7 100644 --- a/engines/sci/gui32/font.cpp +++ b/engines/sci/gui32/font.cpp @@ -23,6 +23,8 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX #include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_resource.h" @@ -241,3 +243,5 @@ gfx_pixmap_t *gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int cha } } // End of namespace Sci + +#endif diff --git a/engines/sci/gui32/gui32.cpp b/engines/sci/gui32/gui32.cpp index ae493708cf..f85917b083 100644 --- a/engines/sci/gui32/gui32.cpp +++ b/engines/sci/gui32/gui32.cpp @@ -23,10 +23,12 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #include "graphics/cursorman.h" #include "common/util.h" -#include "sci/sci.h" #include "sci/engine/state.h" #include "sci/debug.h" // for g_debug_sleeptime_factor #include "sci/resource.h" @@ -264,67 +266,6 @@ void _k_redraw_box(EngineState *s, int x1, int y1, int x2, int y2) { #endif } -Common::Rect set_base(EngineState *s, reg_t object) { - SegManager *segMan = s->_segMan; - int x, y, original_y, z, ystep, xsize, ysize; - 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); - } - - gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &xsize, &ysize, &offset); - - 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; -} - static Common::Rect nsrect_clip(EngineState *s, int y, Common::Rect retval, int priority) { int pri_top; @@ -2820,3 +2761,5 @@ bool SciGui32::debugShowMap(int mapNo) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gui32/gui32.h b/engines/sci/gui32/gui32.h index 99ab6df889..43ce35fc29 100644 --- a/engines/sci/gui32/gui32.h +++ b/engines/sci/gui32/gui32.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #ifndef SCI_GUI32_GUI32_H #define SCI_GUI32_GUI32_H @@ -135,3 +138,5 @@ private: } // End of namespace Sci #endif + +#endif diff --git a/engines/sci/gui32/res_font.cpp b/engines/sci/gui32/res_font.cpp index 376d911d18..7c82b6581b 100644 --- a/engines/sci/gui32/res_font.cpp +++ b/engines/sci/gui32/res_font.cpp @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #include "common/endian.h" #include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_resource.h" @@ -133,3 +136,5 @@ gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gui32/res_pal.cpp b/engines/sci/gui32/res_pal.cpp index d686220453..a4319afcd6 100644 --- a/engines/sci/gui32/res_pal.cpp +++ b/engines/sci/gui32/res_pal.cpp @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + /* SCI1 palette resource defrobnicator */ #include "common/file.h" @@ -133,3 +136,5 @@ Palette *gfxr_read_pal1_amiga(Common::File &file) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gui32/res_pic.cpp b/engines/sci/gui32/res_pic.cpp index fde3425d73..10f26c213f 100644 --- a/engines/sci/gui32/res_pic.cpp +++ b/engines/sci/gui32/res_pic.cpp @@ -23,13 +23,15 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #include <time.h> // for time() to seed rand() via srand() #include "common/endian.h" #include "sci/gfx/gfx_resource.h" #include "sci/gfx/gfx_tools.h" -#include "sci/sci.h" // for kDebugLevelSci0Pic namespace Sci { @@ -1533,3 +1535,5 @@ void gfxr_dither_pic0(gfxr_pic_t *pic, DitherMode dmode) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gui32/res_view.cpp b/engines/sci/gui32/res_view.cpp index e4f6148fc0..ac50a71927 100644 --- a/engines/sci/gui32/res_view.cpp +++ b/engines/sci/gui32/res_view.cpp @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + // SCI 1 view resource defrobnicator #include "common/endian.h" @@ -301,3 +304,5 @@ gfx_pixmap_t *gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *reso } } // End of namespace Sci + +#endif diff --git a/engines/sci/resource.h b/engines/sci/resource.h index 2aaaa7d37f..6f00425402 100644 --- a/engines/sci/resource.h +++ b/engines/sci/resource.h @@ -34,7 +34,7 @@ #include "sound/audiostream.h" #include "sound/mixer.h" // for SoundHandle -#include "gfx/gfx_resource.h" // for ViewType +#include "gui/gui_helpers.h" // for ViewType #include "sci/decompressor.h" #include "sci/sci.h" diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 9f3a291733..1f38071a20 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -35,8 +35,10 @@ #include "sci/engine/state.h" #include "sci/engine/kernel.h" +#include "sci/gfx/operations.h" // fog GfxState #include "sci/gfx/gfx_state_internal.h" // required for GfxContainer, GfxPort, GfxVisual #include "sci/gui32/gui32.h" +#include "sci/gui/gui.h" #include "sci/gui/gui_palette.h" #include "sci/gui/gui_cursor.h" #include "sci/gui/gui_screen.h" @@ -141,7 +143,9 @@ Common::Error SciEngine::run() { ConfMan.registerDefault("undither", "true"); screen->unditherSetState(ConfMan.getBool("undither")); +#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..."); @@ -168,7 +172,9 @@ Common::Error SciEngine::run() { delete screen; delete _gamestate; +#ifdef INCLUDE_OLDGFX gfxop_exit(&gfx_state); +#endif return Common::kNoError; } diff --git a/engines/sci/sci.h b/engines/sci/sci.h index 884e895ffe..12143fa9e9 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -31,6 +31,8 @@ namespace Sci { +#define INCLUDE_OLDGFX + class Console; struct EngineState; class Kernel; |