Enclose all of the old graphics code within the INCLUDE_OLDGFX safeguard (defined in sci.h)

svn-id: r45459
This commit is contained in:
Filippos Karapetis 2009-10-28 13:20:30 +00:00
parent f28fe1b074
commit 04ab6bc9fc
43 changed files with 770 additions and 513 deletions

View file

@ -651,8 +651,10 @@ bool Console::cmdSci0Palette(int argc, const char **argv) {
return true; return true;
} }
#ifdef INCLUDE_OLDGFX
sci0_palette = atoi(argv[1]); sci0_palette = atoi(argv[1]);
cmdRedrawScreen(argc, argv); cmdRedrawScreen(argc, argv);
#endif
return false; return false;
} }
@ -775,16 +777,20 @@ bool Console::cmdList(int argc, const char **argv) {
} }
bool Console::cmdClearScreen(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_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)); gfxop_update_box(_vm->_gamestate->gfx_state, gfx_rect(0, 0, 320, 200));
#endif
return false; return false;
} }
bool Console::cmdRedrawScreen(int argc, const char **argv) { bool Console::cmdRedrawScreen(int argc, const char **argv) {
#ifdef INCLUDE_OLDGFX
_vm->_gamestate->visual->draw(Common::Point(0, 0)); _vm->_gamestate->visual->draw(Common::Point(0, 0));
gfxop_update_box(_vm->_gamestate->gfx_state, gfx_rect(0, 0, 320, 200)); gfxop_update_box(_vm->_gamestate->gfx_state, gfx_rect(0, 0, 320, 200));
gfxop_update(_vm->_gamestate->gfx_state); gfxop_update(_vm->_gamestate->gfx_state);
gfxop_sleep(_vm->_gamestate->gfx_state, 0); gfxop_sleep(_vm->_gamestate->gfx_state, 0);
#endif
return false; return false;
} }
@ -1008,10 +1014,12 @@ bool Console::cmdDrawPic(int argc, const char **argv) {
if (argc == 4) if (argc == 4)
flags = atoi(argv[3]); flags = atoi(argv[3]);
#ifdef INCLUDE_OLDGFX
gfxop_new_pic(_vm->_gamestate->gfx_state, atoi(argv[1]), flags, default_palette); 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_clear_box(_vm->_gamestate->gfx_state, gfx_rect(0, 0, 320, 200));
gfxop_update(_vm->_gamestate->gfx_state); gfxop_update(_vm->_gamestate->gfx_state);
gfxop_sleep(_vm->_gamestate->gfx_state, 0); gfxop_sleep(_vm->_gamestate->gfx_state, 0);
#endif
return false; return false;
} }
@ -1026,10 +1034,12 @@ bool Console::cmdDrawRect(int argc, const char **argv) {
int col = CLIP<int>(atoi(argv[5]), 0, 15); int col = CLIP<int>(atoi(argv[5]), 0, 15);
#ifdef INCLUDE_OLDGFX
gfxop_set_clip_zone(_vm->_gamestate->gfx_state, gfx_rect_fullscreen); 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]), 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]); atoi(argv[3]), atoi(argv[4])), _vm->_gamestate->ega_colors[col]);
gfxop_update(_vm->_gamestate->gfx_state); gfxop_update(_vm->_gamestate->gfx_state);
#endif
return false; return false;
} }
@ -1046,9 +1056,12 @@ bool Console::cmdDrawCel(int argc, const char **argv) {
int cel = atoi(argv[3]); int cel = atoi(argv[3]);
int palette = atoi(argv[4]); int palette = atoi(argv[4]);
#ifdef INCLUDE_OLDGFX
gfxop_set_clip_zone(_vm->_gamestate->gfx_state, gfx_rect_fullscreen); 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_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); gfxop_update(_vm->_gamestate->gfx_state);
#endif
return false; return false;
} }
@ -1061,6 +1074,7 @@ bool Console::cmdViewInfo(int argc, const char **argv) {
return true; return true;
} }
#ifdef INCLUDE_OLDGFX
int view = atoi(argv[1]); int view = atoi(argv[1]);
int palette = atoi(argv[2]); int palette = atoi(argv[2]);
int loops, i; int loops, i;
@ -1095,6 +1109,7 @@ bool Console::cmdViewInfo(int argc, const char **argv) {
} }
} }
} }
#endif
return true; return true;
} }
@ -1145,7 +1160,9 @@ bool Console::cmdUpdateZone(int argc, const char **argv) {
int width = atoi(argv[3]); int width = atoi(argv[3]);
int height = atoi(argv[4]); 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); _vm->_gamestate->gfx_state->driver->update(gfx_rect(x, y, width, height), Common::Point(x, y), GFX_BUFFER_FRONT);
#endif
return false; return false;
} }
@ -1158,6 +1175,7 @@ bool Console::cmdPropagateZone(int argc, const char **argv) {
return true; return true;
} }
#ifdef INCLUDE_OLDGFX
int x = atoi(argv[1]); int x = atoi(argv[1]);
int y = atoi(argv[2]); int y = atoi(argv[2]);
int width = atoi(argv[3]); 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_box(_vm->_gamestate->gfx_state, rect);
gfxop_update(_vm->_gamestate->gfx_state); gfxop_update(_vm->_gamestate->gfx_state);
gfxop_sleep(_vm->_gamestate->gfx_state, 0); gfxop_sleep(_vm->_gamestate->gfx_state, 0);
#endif
return false; return false;
} }
@ -1187,18 +1206,22 @@ bool Console::cmdFillScreen(int argc, const char **argv) {
int col = CLIP<int>(atoi(argv[1]), 0, 15); int col = CLIP<int>(atoi(argv[1]), 0, 15);
#ifdef INCLUDE_OLDGFX
gfxop_set_clip_zone(_vm->_gamestate->gfx_state, gfx_rect_fullscreen); 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_fill_box(_vm->_gamestate->gfx_state, gfx_rect_fullscreen, _vm->_gamestate->ega_colors[col]);
gfxop_update(_vm->_gamestate->gfx_state); gfxop_update(_vm->_gamestate->gfx_state);
#endif
return false; return false;
} }
bool Console::cmdCurrentPort(int argc, const char **argv) { bool Console::cmdCurrentPort(int argc, const char **argv) {
#ifdef INCLUDE_OLDGFX
if (!_vm->_gamestate->port) if (!_vm->_gamestate->port)
DebugPrintf("There is no port active currently.\n"); DebugPrintf("There is no port active currently.\n");
else else
DebugPrintf("Current port ID: %d\n", _vm->_gamestate->port->_ID); DebugPrintf("Current port ID: %d\n", _vm->_gamestate->port->_ID);
#endif
return true; return true;
} }
@ -1211,6 +1234,7 @@ bool Console::cmdPrintPort(int argc, const char **argv) {
return true; return true;
} }
#ifdef INCLUDE_OLDGFX
GfxPort *port; GfxPort *port;
if (!scumm_stricmp(argv[1], "current")) { if (!scumm_stricmp(argv[1], "current")) {
@ -1230,6 +1254,7 @@ bool Console::cmdPrintPort(int argc, const char **argv) {
port->print(0); port->print(0);
} }
} }
#endif
return true; return true;
} }
@ -1245,42 +1270,50 @@ bool Console::cmdParseGrammar(int argc, const char **argv) {
bool Console::cmdVisualState(int argc, const char **argv) { bool Console::cmdVisualState(int argc, const char **argv) {
DebugPrintf("State of the current visual widget:\n"); DebugPrintf("State of the current visual widget:\n");
#ifdef INCLUDE_OLDGFX
if (_vm->_gamestate->visual) if (_vm->_gamestate->visual)
_vm->_gamestate->visual->print(0); _vm->_gamestate->visual->print(0);
else else
DebugPrintf("The visual widget is uninitialized.\n"); DebugPrintf("The visual widget is uninitialized.\n");
#endif
return true; return true;
} }
bool Console::cmdFlushPorts(int argc, const char **argv) { bool Console::cmdFlushPorts(int argc, const char **argv) {
#ifdef INCLUDE_OLDGFX
_vm->_gamestate->_gui->hideCursor(); _vm->_gamestate->_gui->hideCursor();
DebugPrintf("Flushing dynamically allocated ports (for memory profiling)...\n"); DebugPrintf("Flushing dynamically allocated ports (for memory profiling)...\n");
delete _vm->_gamestate->visual; delete _vm->_gamestate->visual;
_vm->_gamestate->gfx_state->gfxResMan->freeAllResources(); _vm->_gamestate->gfx_state->gfxResMan->freeAllResources();
_vm->_gamestate->visual = NULL; _vm->_gamestate->visual = NULL;
#endif
return true; return true;
} }
bool Console::cmdDynamicViews(int argc, const char **argv) { bool Console::cmdDynamicViews(int argc, const char **argv) {
#ifdef INCLUDE_OLDGFX
DebugPrintf("List of active dynamic views:\n"); DebugPrintf("List of active dynamic views:\n");
if (_vm->_gamestate->dyn_views) if (_vm->_gamestate->dyn_views)
_vm->_gamestate->dyn_views->print(0); _vm->_gamestate->dyn_views->print(0);
else else
DebugPrintf("The list is empty.\n"); DebugPrintf("The list is empty.\n");
#endif
return true; return true;
} }
bool Console::cmdDroppedViews(int argc, const char **argv) { bool Console::cmdDroppedViews(int argc, const char **argv) {
#ifdef INCLUDE_OLDGFX
DebugPrintf("List of dropped dynamic views:\n"); DebugPrintf("List of dropped dynamic views:\n");
if (_vm->_gamestate->drop_views) if (_vm->_gamestate->drop_views)
_vm->_gamestate->drop_views->print(0); _vm->_gamestate->drop_views->print(0);
else else
DebugPrintf("The list is empty.\n"); DebugPrintf("The list is empty.\n");
#endif
return true; return true;
} }
@ -1293,7 +1326,9 @@ bool Console::cmdPriorityBands(int argc, const char **argv) {
} }
int zone = CLIP<int>(atoi(argv[1]), 0, 15); 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)); DebugPrintf("Zone %x starts at y=%d\n", zone, _find_priority_band(_vm->_gamestate, zone));
#endif
return true; return true;
} }
@ -1305,6 +1340,7 @@ bool Console::cmdStatusBarColors(int argc, const char **argv) {
return true; return true;
} }
#ifdef INCLUDE_OLDGFX
_vm->_gamestate->titlebar_port->_color = _vm->_gamestate->ega_colors[atoi(argv[1])]; _vm->_gamestate->titlebar_port->_color = _vm->_gamestate->ega_colors[atoi(argv[1])];
_vm->_gamestate->titlebar_port->_bgcolor = _vm->_gamestate->ega_colors[atoi(argv[2])]; _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, sciw_set_status_bar(_vm->_gamestate, _vm->_gamestate->titlebar_port, _vm->_gamestate->_statusBarText,
_vm->_gamestate->status_bar_foreground, _vm->_gamestate->status_bar_background); _vm->_gamestate->status_bar_foreground, _vm->_gamestate->status_bar_background);
gfxop_update(_vm->_gamestate->gfx_state); gfxop_update(_vm->_gamestate->gfx_state);
#endif
return false; return false;
} }

View file

@ -173,6 +173,7 @@ const char *convertSierraGameId(const char *gameName, uint32 *gameFlags) {
} }
int _reset_graphics_input(EngineState *s) { int _reset_graphics_input(EngineState *s) {
#ifdef INCLUDE_OLDGFX
Resource *resource; Resource *resource;
int font_nr; int font_nr;
gfx_color_t transparent = { PaletteEntry(), 0, -1, -1, 0 }; 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->dyn_views = NULL; // no DynViews
s->drop_views = NULL; // And, consequently, no list for dropped views 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; font_nr = -1;
do { do {
resource = s->resMan->testResource(ResourceId(kResourceTypeFont, ++font_nr)); 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 s->titlebar_port->_bgcolor.priority = 11; // Standard priority for the titlebar port
#endif #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; return 0;
} }
@ -289,12 +292,14 @@ int game_init_graphics(EngineState *s) {
static void _free_graphics_input(EngineState *s) { static void _free_graphics_input(EngineState *s) {
debug(2, "Freeing graphics"); debug(2, "Freeing graphics");
#ifdef INCLUDE_OLDGFX
delete s->visual; delete s->visual;
s->wm_port = s->titlebar_port = s->picture_port = NULL; s->wm_port = s->titlebar_port = s->picture_port = NULL;
s->visual = NULL; s->visual = NULL;
s->dyn_views = NULL; s->dyn_views = NULL;
s->port = NULL; s->port = NULL;
#endif
} }
int game_init_sound(EngineState *s, int sound_flags) { int game_init_sound(EngineState *s, int sound_flags) {
@ -406,8 +411,14 @@ int game_init(EngineState *s) {
s->parserIsValid = false; // Invalidate parser s->parserIsValid = false; // Invalidate parser
s->parser_event = NULL_REG; // Invalidate parser event s->parser_event = NULL_REG; // Invalidate parser event
#ifdef INCLUDE_OLDGFX
if (s->gfx_state && _reset_graphics_input(s)) if (s->gfx_state && _reset_graphics_input(s))
return 1; return 1;
#else
if (_reset_graphics_input(s))
return 1;
#endif
s->successor = NULL; // No successor s->successor = NULL; // No successor
s->_statusBarText.clear(); // Status bar is blank s->_statusBarText.clear(); // Status bar is blank

View file

@ -28,6 +28,7 @@
#include "sci/resource.h" #include "sci/resource.h"
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/engine/kernel_types.h" #include "sci/engine/kernel_types.h"
#include "sci/gfx/operations.h" // for gfxop_get_cel_parameters
namespace Sci { namespace Sci {
@ -728,4 +729,69 @@ bool Kernel::loadKernelNames() {
return true; 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 } // End of namespace Sci

View file

@ -26,6 +26,7 @@
#include "sci/sci.h" #include "sci/sci.h"
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/engine/kernel.h" #include "sci/engine/kernel.h"
#include "sci/gfx/operations.h"
#include "sci/gfx/gfx_widgets.h" #include "sci/gfx/gfx_widgets.h"
#include "sci/gfx/gfx_state_internal.h" // required for GfxPort, GfxVisual #include "sci/gfx/gfx_state_internal.h" // required for GfxPort, GfxVisual
#include "sci/console.h" #include "sci/console.h"

View file

@ -274,7 +274,9 @@ reg_t kGraph(EngineState *s, int argc, reg_t *argv) {
error("Unsupported kGraph() operation %04x", argv[0].toSint16()); error("Unsupported kGraph() operation %04x", argv[0].toSint16());
} }
#ifdef INCLUDE_OLDGFX
gfxop_update(s->gfx_state); gfxop_update(s->gfx_state);
#endif
return s->r_acc; return s->r_acc;
} }
@ -374,6 +376,8 @@ reg_t kIsItSkip(EngineState *s, int argc, reg_t *argv) {
int cel = argv[2].toSint16(); int cel = argv[2].toSint16();
int y = argv[3].toUint16(); int y = argv[3].toUint16();
int x = argv[4].toUint16(); int x = argv[4].toUint16();
#ifdef INCLUDE_OLDGFX
gfxr_view_t *res = NULL; gfxr_view_t *res = NULL;
gfx_pixmap_t *pxm = 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; y = pxm->index_height - 1;
return make_reg(0, pxm->index_data[y * pxm->index_width + x] == pxm->color_key); 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) { 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; int argBase = 0;
if ((argc == 2) || (argc == 4)) { if ((argc == 2) || (argc == 4)) {
screenMask = GFX_MASK_CONTROL; screenMask = SCI_SCREEN_MASK_CONTROL;
} else { } else {
screenMask = argv[0].toUint16(); screenMask = argv[0].toUint16();
argBase = 1; argBase = 1;

View file

@ -39,8 +39,12 @@ reg_t kAddMenu(EngineState *s, int argc, reg_t *argv) {
Common::String name = s->_segMan->getString(argv[0]); Common::String name = s->_segMan->getString(argv[0]);
Common::String contents = s->_segMan->getString(argv[1]); Common::String contents = s->_segMan->getString(argv[1]);
#ifdef INCLUDE_OLDGFX
s->_menubar->addMenu(s->gfx_state, name, s->_menubar->addMenu(s->gfx_state, name,
contents, s->titlebar_port->_font, argv[1]); contents, s->titlebar_port->_font, argv[1]);
#else
// TODO
#endif
return s->r_acc; return s->r_acc;
@ -104,10 +108,13 @@ static int _menu_go_down(Menubar *menubar, int menu_nr, int item_nr) {
return item_nr; return item_nr;
} }
#ifdef INCLUDE_OLDGFX
#define FULL_REDRAW \ #define FULL_REDRAW \
s->visual->draw(Common::Point(0, 0)); \ s->visual->draw(Common::Point(0, 0)); \
gfxop_update(s->gfx_state); gfxop_update(s->gfx_state);
#else
#define FULL_REDRAW
#endif
reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) { reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) {
SegManager *segMan = s->_segMan; SegManager *segMan = s->_segMan;
@ -128,7 +135,9 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) {
const int debug_parser = 0; const int debug_parser = 0;
#endif #endif
#ifdef INCLUDE_OLDGFX
gfxop_set_clip_zone(s->gfx_state, gfx_rect_fullscreen); 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 */ /* Check whether we can claim the event directly as a keyboard or said event */
if (type & (SCI_EVT_KEYBOARD | SCI_EVT_SAID)) { 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) { if (menu_mode) {
int old_item; int old_item;
int old_menu; int old_menu;
#ifdef INCLUDE_OLDGFX
GfxPort *port = sciw_new_menu(s, s->titlebar_port, s->_menubar, 0); GfxPort *port = sciw_new_menu(s, s->titlebar_port, s->_menubar, 0);
item_nr = -1; 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); sciw_set_menubar(s, s->titlebar_port, s->_menubar, menu_nr);
FULL_REDRAW; FULL_REDRAW;
#endif
old_item = -1; old_item = -1;
old_menu = -1; old_menu = -1;
@ -211,8 +223,10 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) {
switch (ev.data) { switch (ev.data) {
case '`': case '`':
#ifdef INCLUDE_OLDGFX
if (ev.buckybits & SCI_EVM_CTRL) if (ev.buckybits & SCI_EVM_CTRL)
s->visual->print(0); s->visual->print(0);
#endif
break; break;
case SCI_K_ESC: case SCI_K_ESC:
@ -263,7 +277,9 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) {
{ {
Common::Point curMousePos = s->_cursor->getPosition(); Common::Point curMousePos = s->_cursor->getPosition();
menu_mode = (curMousePos.y < 10); menu_mode = (curMousePos.y < 10);
#ifdef INCLUDE_OLDGFX
claimed = !menu_mode && !s->_menubar->mapPointer(curMousePos, menu_nr, item_nr, toCommonRect(port->_bounds)); claimed = !menu_mode && !s->_menubar->mapPointer(curMousePos, menu_nr, item_nr, toCommonRect(port->_bounds));
#endif
mouse_down = 0; mouse_down = 0;
} }
break; break;
@ -278,6 +294,7 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) {
} }
if (mouse_down) if (mouse_down)
#ifdef INCLUDE_OLDGFX
s->_menubar->mapPointer(s->_cursor->getPosition(), menu_nr, item_nr, toCommonRect(port->_bounds)); 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 */ 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 { else {
FULL_REDRAW; FULL_REDRAW;
} }
} /* ...if the menu changed. */ } /* ...if the menu changed. */
#endif
/* Remove the active menu item, if neccessary */ /* Remove the active menu item, if neccessary */
if (item_nr != old_item) { 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]), old_item, false);
port = sciw_toggle_item(port, &(s->_menubar->_menus[menu_nr]), item_nr, true); port = sciw_toggle_item(port, &(s->_menubar->_menus[menu_nr]), item_nr, true);
#endif
FULL_REDRAW; FULL_REDRAW;
} }
@ -309,6 +328,7 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) {
} /* while (menu_mode) */ } /* while (menu_mode) */
#ifdef INCLUDE_OLDGFX
if (port) { if (port) {
delete port; delete port;
port = NULL; 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); sciw_set_status_bar(s, s->titlebar_port, s->_statusBarText, s->status_bar_foreground, s->status_bar_background);
gfxop_update(s->gfx_state); gfxop_update(s->gfx_state);
} }
#endif
FULL_REDRAW; FULL_REDRAW;
} }

View file

@ -168,7 +168,9 @@ reg_t kDisposeClone(EngineState *s, int argc, reg_t *argv) {
victim_obj->markAsFreed(); victim_obj->markAsFreed();
#ifdef INCLUDE_OLDGFX
_k_view_list_mark_free(s, victim_addr); // Free on view list, if neccessary _k_view_list_mark_free(s, victim_addr); // Free on view list, if neccessary
#endif
return s->r_acc; return s->r_acc;
} }

View file

@ -748,9 +748,10 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
retval->execution_stack_base = 0; retval->execution_stack_base = 0;
// Now copy all current state information // Now copy all current state information
#ifdef INCLUDE_OLDGFX
// Graphics and input state: // Graphics and input state:
retval->gfx_state = s->gfx_state;
retval->old_screen = 0; retval->old_screen = 0;
#endif
temp = retval->_sound._songlib; temp = retval->_sound._songlib;
retval->_sound.sfx_init(retval->resMan, s->sfx_init_flags); 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->bp_list = s->bp_list;
retval->successor = NULL; retval->successor = NULL;
#ifdef INCLUDE_OLDGFX
retval->pic_priority_table = (int *)(retval->gfx_state->pic) ? retval->gfx_state->pic->priorityTable : NULL; retval->pic_priority_table = (int *)(retval->gfx_state->pic) ? retval->gfx_state->pic->priorityTable : NULL;
#endif
retval->_gameName = s->_gameName; retval->_gameName = s->_gameName;
retval->_sound._it = NULL; retval->_sound._it = NULL;

View file

@ -23,6 +23,8 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/engine/vm.h" #include "sci/engine/vm.h"
#include "sci/engine/script.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) { : resMan(res), _kernel(kernel), _voc(voc), _gui(gui), _cursor(cursor), _dirseeker(this) {
gfx_state = 0; gfx_state = 0;
old_screen = 0;
sfx_init_flags = 0; sfx_init_flags = 0;
sound_volume = 0; sound_volume = 0;
@ -50,12 +51,11 @@ EngineState::EngineState(ResourceManager *res, Kernel *kernel, Vocabulary *voc,
status_bar_foreground = 0; status_bar_foreground = 0;
status_bar_background = 0; status_bar_background = 0;
#ifdef INCLUDE_OLDGFX
old_screen = 0;
port = 0; port = 0;
memset(ega_colors, 0, sizeof(ega_colors)); memset(ega_colors, 0, sizeof(ega_colors));
visual = 0; visual = 0;
titlebar_port = 0; titlebar_port = 0;
wm_port = 0; wm_port = 0;
picture_port = 0; picture_port = 0;
@ -65,8 +65,8 @@ EngineState::EngineState(ResourceManager *res, Kernel *kernel, Vocabulary *voc,
pic_animate = 0; pic_animate = 0;
dyn_views = 0; dyn_views = 0;
drop_views = 0; drop_views = 0;
#endif
_menubar = 0; _menubar = 0;

View file

@ -134,7 +134,6 @@ public:
SciGuiCursor *_cursor; /* Cursor functions */ SciGuiCursor *_cursor; /* Cursor functions */
GfxState *gfx_state; /**< Graphics state and driver */ GfxState *gfx_state; /**< Graphics state and driver */
gfx_pixmap_t *old_screen; /**< Old screen content: Stored during kDrawPic() for kAnimate() */
SfxState _sound; /**< sound subsystem */ SfxState _sound; /**< sound subsystem */
int sfx_init_flags; /**< flags the sfx subsystem was initialised with */ int sfx_init_flags; /**< flags the sfx subsystem was initialised with */
@ -153,6 +152,9 @@ public:
int status_bar_foreground, status_bar_background; 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 */ GfxPort *port; /**< The currently active port */
gfx_color_t ega_colors[16]; /**< The 16 EGA colors- for SCI0(1) */ 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 *dyn_views; /**< Pointers to pic and dynamic view lists */
GfxList *drop_views; /**< A list Animate() can dump dropped dynviews into */ GfxList *drop_views; /**< A list Animate() can dump dropped dynviews into */
#endif
Menubar *_menubar; /**< The menu bar */ Menubar *_menubar; /**< The menu bar */
@ -296,6 +299,8 @@ private:
bool _usesCdTrack; bool _usesCdTrack;
}; };
#ifdef INCLUDE_OLDGFX
/** /**
* Retrieves the gfx_pixmap_color_t associated with a game color index. * Retrieves the gfx_pixmap_color_t associated with a game color index.
* @param s game state * @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 assert_primary_widget_lists(EngineState *s);
void reparentize_primary_widget_lists(EngineState *s, GfxPort *newport); void reparentize_primary_widget_lists(EngineState *s, GfxPort *newport);
#endif
} // End of namespace Sci } // End of namespace Sci
#endif // SCI_INCLUDE_ENGINE_H #endif // SCI_INCLUDE_ENGINE_H

View file

@ -23,13 +23,15 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#include "common/scummsys.h" #include "common/scummsys.h"
#include "common/system.h" #include "common/system.h"
#include "graphics/cursorman.h" #include "graphics/cursorman.h"
#include "graphics/primitives.h" #include "graphics/primitives.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "sci/sci.h"
#include "sci/gui/gui_screen.h" #include "sci/gui/gui_screen.h"
#include "sci/gfx/gfx_driver.h" #include "sci/gfx/gfx_driver.h"
#include "sci/gfx/gfx_tools.h" #include "sci/gfx/gfx_tools.h"
@ -199,3 +201,5 @@ void GfxDriver::animatePalette(int fromColor, int toColor, int stepCount) {
} }
} // End of namespace Sci } // End of namespace Sci
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#ifndef SCI_GFX_GFX_DRIVER_H #ifndef SCI_GFX_GFX_DRIVER_H
#define SCI_GFX_GFX_DRIVER_H #define SCI_GFX_GFX_DRIVER_H
@ -222,3 +225,5 @@ private:
} // End of namespace Sci } // End of namespace Sci
#endif // SCI_GFX_GFX_DRIVER_H #endif // SCI_GFX_GFX_DRIVER_H
#endif

View file

@ -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/engine/state.h"
#include "sci/gfx/operations.h" #include "sci/gfx/operations.h"
#include "sci/gfx/gfx_widgets.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 } // End of namespace Sci
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#ifndef SCI_INCLUDE_SCI_WIDGETS_H #ifndef SCI_INCLUDE_SCI_WIDGETS_H
#define 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 } // End of namespace Sci
#endif // SCI_INCLUDE_SCI_WIDGETS_H #endif // SCI_INCLUDE_SCI_WIDGETS_H
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
/* Required defines: /* Required defines:
** FUNCNAME: Function name ** FUNCNAME: Function name
** SIZETYPE: Type used for each pixel ** 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 } // End of namespace Sci
#endif

View file

@ -23,13 +23,15 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
// Resource manager core part // Resource manager core part
// FIXME/TODO: The name "(Graphics) resource manager", and the associated // FIXME/TODO: The name "(Graphics) resource manager", and the associated
// filenames, are misleading. This should be renamed to "Graphics manager" // filenames, are misleading. This should be renamed to "Graphics manager"
// or something like that. // or something like that.
#include "sci/sci.h"
#include "sci/gfx/gfx_resource.h" #include "sci/gfx/gfx_resource.h"
#include "sci/gfx/gfx_tools.h" #include "sci/gfx/gfx_tools.h"
#include "sci/gfx/gfx_resmgr.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 } // End of namespace Sci
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#ifndef SCI_GFX_GFX_RESMAN_H #ifndef SCI_GFX_GFX_RESMAN_H
#define SCI_GFX_GFX_RESMAN_H #define SCI_GFX_GFX_RESMAN_H
@ -282,3 +285,5 @@ private:
} // End of namespace Sci } // End of namespace Sci
#endif // SCI_GFX_GFX_RESMAN_H #endif // SCI_GFX_GFX_RESMAN_H
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_system.h"
#include "sci/gfx/gfx_resource.h" #include "sci/gfx/gfx_resource.h"
#include "sci/gfx/gfx_tools.h" #include "sci/gfx/gfx_tools.h"
@ -73,3 +76,5 @@ void gfxr_free_pic(gfxr_pic_t *pic) {
} }
} // End of namespace Sci } // End of namespace Sci
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
/** @file gfx_resource.h /** @file gfx_resource.h
* SCI Resource library. * SCI Resource library.
*/ */
@ -32,6 +35,7 @@
#include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_system.h"
#include "sci/gfx/gfx_driver.h" #include "sci/gfx/gfx_driver.h"
#include "sci/gui/gui_helpers.h"
#include "common/rect.h" #include "common/rect.h"
@ -75,15 +79,6 @@ extern PaletteEntry gfx_sci0_image_colors[][16];
*/ */
extern Palette* gfx_sci0_pic_colors; extern Palette* gfx_sci0_pic_colors;
enum ViewType {
kViewUnknown,
kViewEga,
kViewVga,
kViewVga11,
kViewAmiga
};
struct gfxr_pic0_params_t { struct gfxr_pic0_params_t {
gfx_line_mode_t line_mode; /* one of GFX_LINE_MODE_* */ gfx_line_mode_t line_mode; /* one of GFX_LINE_MODE_* */
gfx_brush_mode_t brush_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 } // End of namespace Sci
#endif // SCI_GFX_GFX_RESOURCE_H #endif // SCI_GFX_GFX_RESOURCE_H
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#ifndef SCI_GFX_GFX_STATE_INTERNAL_H #ifndef SCI_GFX_GFX_STATE_INTERNAL_H
#define SCI_GFX_GFX_STATE_INTERNAL_H #define SCI_GFX_GFX_STATE_INTERNAL_H
@ -410,3 +413,5 @@ public:
} // End of namespace Sci } // End of namespace Sci
#endif // SCI_GFX_GFX_STATE_INTERNAL_H #endif // SCI_GFX_GFX_STATE_INTERNAL_H
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
/* Graphics support functions for drivers and replacements for driver functions /* Graphics support functions for drivers and replacements for driver functions
** for use with the graphical state manager ** 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 } // End of namespace Sci
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#ifndef SCI_GFX_GFX_SYSTEM #ifndef SCI_GFX_GFX_SYSTEM
#define SCI_GFX_GFX_SYSTEM #define SCI_GFX_GFX_SYSTEM
@ -279,3 +282,5 @@ struct gfx_color_t {
} // End of namespace Sci } // End of namespace Sci
#endif // SCI_GFX_GFX_SYSTEM #endif // SCI_GFX_GFX_SYSTEM
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#include "sci/gfx/gfx_tools.h" #include "sci/gfx/gfx_tools.h"
namespace Sci { 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 } // End of namespace Sci
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#ifndef SCI_GFX_GFX_TOOLS_H #ifndef SCI_GFX_GFX_TOOLS_H
#define 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 } // End of namespace Sci
#endif // SCI_GFX_GFX_TOOLS_H #endif // SCI_GFX_GFX_TOOLS_H
#endif

View file

@ -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_gui.h" // for kWindowAutoRestore
#include "sci/gfx/gfx_widgets.h" #include "sci/gfx/gfx_widgets.h"
#include "sci/gfx/gfx_state_internal.h" #include "sci/gfx/gfx_state_internal.h"
@ -1769,3 +1771,5 @@ GfxDynView *gfxw_picviewize_dynview(GfxDynView *dynview) {
} }
} // End of namespace Sci } // End of namespace Sci
#endif

View file

@ -23,6 +23,8 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#ifndef SCI_GFX_GFX_WIDGETS_H #ifndef SCI_GFX_GFX_WIDGETS_H
#define 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 } // End of namespace Sci
#endif // SCI_GFX_GFX_WIDGETS_H #endif // SCI_GFX_GFX_WIDGETS_H
#endif

View file

@ -77,6 +77,7 @@ MenuItem::MenuItem() {
_tag = 0; _tag = 0;
} }
#ifdef INCLUDE_OLDGFX
int Menu::addMenuItem(GfxState *state, MenuType type, const char *left, const char *right, 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) { 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) { if (right) {
#ifdef INCLUDE_OLDGFX
gfxop_get_text_params(state, font, item->_keytext.c_str(), SIZE_INF, &width, &height, 0, NULL, NULL, NULL); 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; total_left_size = MENU_BOX_CENTER_PADDING + width;
} }
item->_enabled = 1; item->_enabled = 1;
item->_tag = tag; item->_tag = tag;
item->_textPos = text_pos; item->_textPos = text_pos;
#ifdef INCLUDE_OLDGFX
gfxop_get_text_params(state, font, left, SIZE_INF, &width, &height, 0, NULL, NULL, NULL); gfxop_get_text_params(state, font, left, SIZE_INF, &width, &height, 0, NULL, NULL, NULL);
#endif
_items.push_back(newItem); _items.push_back(newItem);
@ -133,7 +138,9 @@ void Menubar::addMenu(GfxState *state, const Common::String &title, const Common
menu._title = title; menu._title = title;
#ifdef INCLUDE_OLDGFX
gfxop_get_text_params(state, font, title.c_str(), SIZE_INF, &(menu._titleWidth), &height, 0, NULL, NULL, NULL); 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(); 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 = entries_base;
beginning.offset -= string_len + 1; beginning.offset -= string_len + 1;
#ifdef INCLUDE_OLDGFX
c_width = menu.addMenuItem(state, entrytype, left, NULL, font, 0, 0, tag, beginning); c_width = menu.addMenuItem(state, entrytype, left, NULL, font, 0, 0, tag, beginning);
#endif
if (c_width > max_width) if (c_width > max_width)
max_width = c_width; max_width = c_width;
@ -269,6 +278,8 @@ void Menubar::addMenu(GfxState *state, const Common::String &title, const Common
_menus.push_back(menu); _menus.push_back(menu);
} }
#endif
bool MenuItem::matchKey(int message, int modifiers) { bool MenuItem::matchKey(int message, int modifiers) {
if ((_key == message) && ((modifiers & (SCI_EVM_CTRL | SCI_EVM_ALT)) == _modifiers)) if ((_key == message) && ((modifiers & (SCI_EVM_CTRL | SCI_EVM_ALT)) == _modifiers))
return true; return true;

View file

@ -28,6 +28,7 @@
#ifndef SCI_GFX_SCI_MENUBAR_H #ifndef SCI_GFX_SCI_MENUBAR_H
#define 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/engine/vm_types.h"
#include "sci/gfx/operations.h" #include "sci/gfx/operations.h"
@ -138,8 +139,10 @@ public:
//protected: //protected:
// FIXME: This should be (partially) turned into a MenuItem constructor // 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 addMenuItem(GfxState *state, MenuType type, const char *left, const char *right,
int font, int key, int modifiers, int tag, reg_t text_pos); 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] font The font which is to be used for drawing
* @param[in] entries_base Segmented VM address of the entries string * @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); 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. * Sets the attributes for a menu item.

View file

@ -27,7 +27,9 @@
#include "sci/sci.h" #include "sci/sci.h"
#include "sci/gfx/operations.h" #include "sci/gfx/operations.h"
#ifdef INCLUDE_OLDGFX
#include "sci/gui32/font.h" #include "sci/gui32/font.h"
#endif
#include "sci/console.h" #include "sci/console.h"
#include "common/system.h" #include "common/system.h"
@ -35,6 +37,8 @@
namespace Sci { namespace Sci {
#ifdef INCLUDE_OLDGFX
#define PRECISE_PRIORITY_MAP // Duplicate all operations on the local priority map as appropriate #define PRECISE_PRIORITY_MAP // Duplicate all operations on the local priority map as appropriate
#undef GFXW_DEBUG_DIRTY #undef GFXW_DEBUG_DIRTY
@ -871,398 +875,6 @@ void gfxop_disable_dirty_frames(GfxState *state) {
state->disable_dirty = 1; state->disable_dirty = 1;
} }
// Pointer and IO ops
void gfxop_sleep(GfxState *state, uint32 msecs) {
uint32 time;
const uint32 wakeup_time = g_system->getMillis() + msecs;
while (true) {
// let backend process events and update the screen
gfxop_get_event(state, SCI_EVT_PEEK);
// TODO: we need to call SciGuiCursor::refreshPosition() before each screen update to limit the mouse cursor position
g_system->updateScreen();
time = g_system->getMillis();
if (time + 10 < wakeup_time) {
g_system->delayMillis(10);
} else {
if (time < wakeup_time)
g_system->delayMillis(wakeup_time - time);
break;
}
}
}
#define SCANCODE_ROWS_NR 3
struct scancode_row {
int offset;
const char *keys;
} scancode_rows[SCANCODE_ROWS_NR] = {
{0x10, "QWERTYUIOP[]"},
{0x1e, "ASDFGHJKL;'\\"},
{0x2c, "ZXCVBNM,./"}
};
static int _gfxop_scancode(int ch) {
// Calculates a PC keyboard scancode from a character */
int row;
int c = toupper((char)ch);
for (row = 0; row < SCANCODE_ROWS_NR; row++) {
const char *keys = scancode_rows[row].keys;
int offset = scancode_rows[row].offset;
while (*keys) {
if (*keys == c)
return offset << 8;
offset++;
keys++;
}
}
return ch;
}
int _gfxop_shiftify(int c) {
char shifted_numbers[] = ")!@#$%^&*(";
if (c < 256) {
c = toupper((char)c);
if (c >= 'A' && c <= 'Z')
return c;
if (c >= '0' && c <= '9')
return shifted_numbers[c-'0'];
switch (c) {
case SCI_K_TAB:
return SCI_K_SHIFT_TAB;
case ']':
return '}';
case '[':
return '{';
case '`':
return '~';
case '-':
return '_';
case '=':
return '+';
case ';':
return ':';
case '\'':
return '"';
case '\\':
return '|';
case ',':
return '<';
case '.':
return '>';
case '/':
return '?';
default:
return c; // No match
}
}
if (c >= SCI_K_F1 && c <= SCI_K_F10)
return c + 25;
return c;
}
static int _gfxop_numlockify(int c) {
switch (c) {
case SCI_K_DELETE:
return '.';
case SCI_K_INSERT:
return '0';
case SCI_K_END:
return '1';
case SCI_K_DOWN:
return '2';
case SCI_K_PGDOWN:
return '3';
case SCI_K_LEFT:
return '4';
case SCI_K_CENTER:
return '5';
case SCI_K_RIGHT:
return '6';
case SCI_K_HOME:
return '7';
case SCI_K_UP:
return '8';
case SCI_K_PGUP:
return '9';
default:
return c; // Unchanged
}
}
static sci_event_t scummvm_get_event(GfxDriver *drv) {
static int _modifierStates = 0; // FIXME: Avoid non-const global vars
sci_event_t input = { SCI_EVT_NONE, 0, 0, 0 };
Common::EventManager *em = g_system->getEventManager();
Common::Event ev;
bool found = em->pollEvent(ev);
Common::Point p = ev.mouse;
// Don't generate events for mouse movement
while (found && ev.type == Common::EVENT_MOUSEMOVE) {
found = em->pollEvent(ev);
}
if (found && !ev.synthetic && ev.type != Common::EVENT_MOUSEMOVE) {
int modifiers = em->getModifierState();
// We add the modifier key status to buckybits
// SDL sends a keydown event if a modifier key is turned on and a keyup event if it's off
//
// FIXME: This code is semi-bogus. It only records the modifier key being *pressed*.
// It does not track correctly whether capslock etc. is active. To do that, we
// would have to record the fact that the modifier was pressed in global var,
// and also watch for Common::EVENT_KEYUP events.
// But this is still not quite good enough, because not all events might
// pass through here (e.g. the GUI might be running with its own event loop).
//
// The best solution likely would be to add code to the EventManager class
// for tracking which keys are pressed and which are not...
if (ev.type == Common::EVENT_KEYDOWN || ev.type == Common::EVENT_KEYUP) {
switch (ev.kbd.keycode) {
case Common::KEYCODE_CAPSLOCK:
if (ev.type == Common::EVENT_KEYDOWN) {
_modifierStates |= SCI_EVM_CAPSLOCK;
} else {
_modifierStates &= ~SCI_EVM_CAPSLOCK;
}
break;
case Common::KEYCODE_NUMLOCK:
if (ev.type == Common::EVENT_KEYDOWN) {
_modifierStates |= SCI_EVM_NUMLOCK;
} else {
_modifierStates &= ~SCI_EVM_NUMLOCK;
}
break;
case Common::KEYCODE_SCROLLOCK:
if (ev.type == Common::EVENT_KEYDOWN) {
_modifierStates |= SCI_EVM_SCRLOCK;
} else {
_modifierStates &= ~SCI_EVM_SCRLOCK;
}
break;
default:
break;
}
}
//TODO: SCI_EVM_INSERT
input.buckybits =
((modifiers & Common::KBD_ALT) ? SCI_EVM_ALT : 0) |
((modifiers & Common::KBD_CTRL) ? SCI_EVM_CTRL : 0) |
((modifiers & Common::KBD_SHIFT) ? SCI_EVM_LSHIFT | SCI_EVM_RSHIFT : 0) |
_modifierStates;
switch (ev.type) {
// Keyboard events
case Common::EVENT_KEYDOWN:
input.data = ev.kbd.keycode;
input.character = ev.kbd.ascii;
// Debug console
if (ev.kbd.flags == Common::KBD_CTRL && ev.kbd.keycode == Common::KEYCODE_d) {
// Open debug console
Console *con = ((Sci::SciEngine*)g_engine)->getSciDebugger();
con->attach();
// Clear keyboard event
input.type = SCI_EVT_NONE;
input.character = 0;
input.data = 0;
input.buckybits = 0;
return input;
}
if (!(input.data & 0xFF00)) {
// Directly accept most common keys without conversion
input.type = SCI_EVT_KEYBOARD;
if (input.data == Common::KEYCODE_TAB) {
// Tab
input.type = SCI_EVT_KEYBOARD;
input.data = SCI_K_TAB;
if (input.buckybits & (SCI_EVM_LSHIFT | SCI_EVM_RSHIFT))
input.character = SCI_K_SHIFT_TAB;
else
input.character = SCI_K_TAB;
}
} else if ((input.data >= Common::KEYCODE_F1) && input.data <= Common::KEYCODE_F10) {
// F1-F10
input.type = SCI_EVT_KEYBOARD;
// SCI_K_F1 == 59 << 8
// SCI_K_SHIFT_F1 == 84 << 8
input.data = SCI_K_F1 + ((input.data - Common::KEYCODE_F1)<<8);
if (input.buckybits & (SCI_EVM_LSHIFT | SCI_EVM_RSHIFT))
input.character = input.data + 25;
else
input.character = input.data;
} else {
// Special keys that need conversion
input.type = SCI_EVT_KEYBOARD;
switch (ev.kbd.keycode) {
case Common::KEYCODE_UP:
input.data = SCI_K_UP;
break;
case Common::KEYCODE_DOWN:
input.data = SCI_K_DOWN;
break;
case Common::KEYCODE_RIGHT:
input.data = SCI_K_RIGHT;
break;
case Common::KEYCODE_LEFT:
input.data = SCI_K_LEFT;
break;
case Common::KEYCODE_INSERT:
input.data = SCI_K_INSERT;
break;
case Common::KEYCODE_HOME:
input.data = SCI_K_HOME;
break;
case Common::KEYCODE_END:
input.data = SCI_K_END;
break;
case Common::KEYCODE_PAGEUP:
input.data = SCI_K_PGUP;
break;
case Common::KEYCODE_PAGEDOWN:
input.data = SCI_K_PGDOWN;
break;
case Common::KEYCODE_DELETE:
input.data = SCI_K_DELETE;
break;
// Keypad keys
case Common::KEYCODE_KP8: // up
if (!(_modifierStates & SCI_EVM_NUMLOCK))
input.data = SCI_K_UP;
break;
case Common::KEYCODE_KP2: // down
if (!(_modifierStates & SCI_EVM_NUMLOCK))
input.data = SCI_K_DOWN;
break;
case Common::KEYCODE_KP6: // right
if (!(_modifierStates & SCI_EVM_NUMLOCK))
input.data = SCI_K_RIGHT;
break;
case Common::KEYCODE_KP4: // left
if (!(_modifierStates & SCI_EVM_NUMLOCK))
input.data = SCI_K_LEFT;
break;
case Common::KEYCODE_KP5: // center
if (!(_modifierStates & SCI_EVM_NUMLOCK))
input.data = SCI_K_CENTER;
break;
default:
input.type = SCI_EVT_NONE;
break;
}
input.character = input.data;
}
break;
// Mouse events
case Common::EVENT_LBUTTONDOWN:
input.type = SCI_EVT_MOUSE_PRESS;
input.data = 1;
break;
case Common::EVENT_RBUTTONDOWN:
input.type = SCI_EVT_MOUSE_PRESS;
input.data = 2;
break;
case Common::EVENT_LBUTTONUP:
input.type = SCI_EVT_MOUSE_RELEASE;
input.data = 1;
break;
case Common::EVENT_RBUTTONUP:
input.type = SCI_EVT_MOUSE_RELEASE;
input.data = 2;
break;
// Misc events
case Common::EVENT_QUIT:
input.type = SCI_EVT_QUIT;
break;
default:
break;
}
}
return input;
}
sci_event_t gfxop_get_event(GfxState *state, unsigned int mask) {
//sci_event_t error_event = { SCI_EVT_ERROR, 0, 0, 0 };
sci_event_t event = { 0, 0, 0, 0 };
// TODO: we need to call SciGuiCursor::refreshPosition() before each screen update to limit the mouse cursor position
// Update the screen here, since it's called very often
g_system->updateScreen();
// Get all queued events from graphics driver
do {
event = scummvm_get_event(state->driver);
if (event.type != SCI_EVT_NONE)
state->_events.push_back(event);
} while (event.type != SCI_EVT_NONE);
// Search for matching event in queue
Common::List<sci_event_t>::iterator iter = state->_events.begin();
while (iter != state->_events.end() && !((*iter).type & mask))
++iter;
if (iter != state->_events.end()) {
// Event found
event = *iter;
// If not peeking at the queue, remove the event
if (!(mask & SCI_EVT_PEEK)) {
state->_events.erase(iter);
}
} else {
// No event found: we must return a SCI_EVT_NONE event.
// Because event.type is SCI_EVT_NONE already here,
// there is no need to change it.
}
if (event.type == SCI_EVT_KEYBOARD) {
// Do we still have to translate the key?
event.character = event.data;
// Scancodify if appropriate
if (event.buckybits & SCI_EVM_ALT)
event.character = _gfxop_scancode(event.character);
// Shift if appropriate
else if (((event.buckybits & (SCI_EVM_RSHIFT | SCI_EVM_LSHIFT)) && !(event.buckybits & SCI_EVM_CAPSLOCK))
|| (!(event.buckybits & (SCI_EVM_RSHIFT | SCI_EVM_LSHIFT)) && (event.buckybits & SCI_EVM_CAPSLOCK)))
event.character = _gfxop_shiftify(event.character);
// Numlockify if appropriate
else if (event.buckybits & SCI_EVM_NUMLOCK)
event.data = _gfxop_numlockify(event.data);
}
return event;
}
// View operations // View operations
void gfxop_get_cel_parameters(GfxState *state, int nr, int loop, int cel, int *width, int *height, Common::Point *offset) { void gfxop_get_cel_parameters(GfxState *state, int nr, int loop, int cel, int *width, int *height, Common::Point *offset) {
@ -1593,4 +1205,401 @@ void gfxop_draw_pixmap(GfxState *state, gfx_pixmap_t *pxm, rect_t zone, Common::
200*state->driver->getMode()->scaleFactor), 0, NULL, NULL); 200*state->driver->getMode()->scaleFactor), 0, NULL, NULL);
} }
#endif // INCLUDE_OLDGFX
// Pointer and IO ops
void gfxop_sleep(GfxState *state, uint32 msecs) {
uint32 time;
const uint32 wakeup_time = g_system->getMillis() + msecs;
while (true) {
// let backend process events and update the screen
gfxop_get_event(state, SCI_EVT_PEEK);
// TODO: we need to call SciGuiCursor::refreshPosition() before each screen update to limit the mouse cursor position
g_system->updateScreen();
time = g_system->getMillis();
if (time + 10 < wakeup_time) {
g_system->delayMillis(10);
} else {
if (time < wakeup_time)
g_system->delayMillis(wakeup_time - time);
break;
}
}
}
#define SCANCODE_ROWS_NR 3
struct scancode_row {
int offset;
const char *keys;
} scancode_rows[SCANCODE_ROWS_NR] = {
{0x10, "QWERTYUIOP[]"},
{0x1e, "ASDFGHJKL;'\\"},
{0x2c, "ZXCVBNM,./"}
};
static int _gfxop_scancode(int ch) {
// Calculates a PC keyboard scancode from a character */
int row;
int c = toupper((char)ch);
for (row = 0; row < SCANCODE_ROWS_NR; row++) {
const char *keys = scancode_rows[row].keys;
int offset = scancode_rows[row].offset;
while (*keys) {
if (*keys == c)
return offset << 8;
offset++;
keys++;
}
}
return ch;
}
int _gfxop_shiftify(int c) {
char shifted_numbers[] = ")!@#$%^&*(";
if (c < 256) {
c = toupper((char)c);
if (c >= 'A' && c <= 'Z')
return c;
if (c >= '0' && c <= '9')
return shifted_numbers[c-'0'];
switch (c) {
case SCI_K_TAB:
return SCI_K_SHIFT_TAB;
case ']':
return '}';
case '[':
return '{';
case '`':
return '~';
case '-':
return '_';
case '=':
return '+';
case ';':
return ':';
case '\'':
return '"';
case '\\':
return '|';
case ',':
return '<';
case '.':
return '>';
case '/':
return '?';
default:
return c; // No match
}
}
if (c >= SCI_K_F1 && c <= SCI_K_F10)
return c + 25;
return c;
}
static int _gfxop_numlockify(int c) {
switch (c) {
case SCI_K_DELETE:
return '.';
case SCI_K_INSERT:
return '0';
case SCI_K_END:
return '1';
case SCI_K_DOWN:
return '2';
case SCI_K_PGDOWN:
return '3';
case SCI_K_LEFT:
return '4';
case SCI_K_CENTER:
return '5';
case SCI_K_RIGHT:
return '6';
case SCI_K_HOME:
return '7';
case SCI_K_UP:
return '8';
case SCI_K_PGUP:
return '9';
default:
return c; // Unchanged
}
}
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 };
Common::EventManager *em = g_system->getEventManager();
Common::Event ev;
bool found = em->pollEvent(ev);
Common::Point p = ev.mouse;
// Don't generate events for mouse movement
while (found && ev.type == Common::EVENT_MOUSEMOVE) {
found = em->pollEvent(ev);
}
if (found && !ev.synthetic && ev.type != Common::EVENT_MOUSEMOVE) {
int modifiers = em->getModifierState();
// We add the modifier key status to buckybits
// SDL sends a keydown event if a modifier key is turned on and a keyup event if it's off
//
// FIXME: This code is semi-bogus. It only records the modifier key being *pressed*.
// It does not track correctly whether capslock etc. is active. To do that, we
// would have to record the fact that the modifier was pressed in global var,
// and also watch for Common::EVENT_KEYUP events.
// But this is still not quite good enough, because not all events might
// pass through here (e.g. the GUI might be running with its own event loop).
//
// The best solution likely would be to add code to the EventManager class
// for tracking which keys are pressed and which are not...
if (ev.type == Common::EVENT_KEYDOWN || ev.type == Common::EVENT_KEYUP) {
switch (ev.kbd.keycode) {
case Common::KEYCODE_CAPSLOCK:
if (ev.type == Common::EVENT_KEYDOWN) {
_modifierStates |= SCI_EVM_CAPSLOCK;
} else {
_modifierStates &= ~SCI_EVM_CAPSLOCK;
}
break;
case Common::KEYCODE_NUMLOCK:
if (ev.type == Common::EVENT_KEYDOWN) {
_modifierStates |= SCI_EVM_NUMLOCK;
} else {
_modifierStates &= ~SCI_EVM_NUMLOCK;
}
break;
case Common::KEYCODE_SCROLLOCK:
if (ev.type == Common::EVENT_KEYDOWN) {
_modifierStates |= SCI_EVM_SCRLOCK;
} else {
_modifierStates &= ~SCI_EVM_SCRLOCK;
}
break;
default:
break;
}
}
//TODO: SCI_EVM_INSERT
input.buckybits =
((modifiers & Common::KBD_ALT) ? SCI_EVM_ALT : 0) |
((modifiers & Common::KBD_CTRL) ? SCI_EVM_CTRL : 0) |
((modifiers & Common::KBD_SHIFT) ? SCI_EVM_LSHIFT | SCI_EVM_RSHIFT : 0) |
_modifierStates;
switch (ev.type) {
// Keyboard events
case Common::EVENT_KEYDOWN:
input.data = ev.kbd.keycode;
input.character = ev.kbd.ascii;
// Debug console
if (ev.kbd.flags == Common::KBD_CTRL && ev.kbd.keycode == Common::KEYCODE_d) {
// Open debug console
Console *con = ((Sci::SciEngine*)g_engine)->getSciDebugger();
con->attach();
// Clear keyboard event
input.type = SCI_EVT_NONE;
input.character = 0;
input.data = 0;
input.buckybits = 0;
return input;
}
if (!(input.data & 0xFF00)) {
// Directly accept most common keys without conversion
input.type = SCI_EVT_KEYBOARD;
if (input.data == Common::KEYCODE_TAB) {
// Tab
input.type = SCI_EVT_KEYBOARD;
input.data = SCI_K_TAB;
if (input.buckybits & (SCI_EVM_LSHIFT | SCI_EVM_RSHIFT))
input.character = SCI_K_SHIFT_TAB;
else
input.character = SCI_K_TAB;
}
} else if ((input.data >= Common::KEYCODE_F1) && input.data <= Common::KEYCODE_F10) {
// F1-F10
input.type = SCI_EVT_KEYBOARD;
// SCI_K_F1 == 59 << 8
// SCI_K_SHIFT_F1 == 84 << 8
input.data = SCI_K_F1 + ((input.data - Common::KEYCODE_F1)<<8);
if (input.buckybits & (SCI_EVM_LSHIFT | SCI_EVM_RSHIFT))
input.character = input.data + 25;
else
input.character = input.data;
} else {
// Special keys that need conversion
input.type = SCI_EVT_KEYBOARD;
switch (ev.kbd.keycode) {
case Common::KEYCODE_UP:
input.data = SCI_K_UP;
break;
case Common::KEYCODE_DOWN:
input.data = SCI_K_DOWN;
break;
case Common::KEYCODE_RIGHT:
input.data = SCI_K_RIGHT;
break;
case Common::KEYCODE_LEFT:
input.data = SCI_K_LEFT;
break;
case Common::KEYCODE_INSERT:
input.data = SCI_K_INSERT;
break;
case Common::KEYCODE_HOME:
input.data = SCI_K_HOME;
break;
case Common::KEYCODE_END:
input.data = SCI_K_END;
break;
case Common::KEYCODE_PAGEUP:
input.data = SCI_K_PGUP;
break;
case Common::KEYCODE_PAGEDOWN:
input.data = SCI_K_PGDOWN;
break;
case Common::KEYCODE_DELETE:
input.data = SCI_K_DELETE;
break;
// Keypad keys
case Common::KEYCODE_KP8: // up
if (!(_modifierStates & SCI_EVM_NUMLOCK))
input.data = SCI_K_UP;
break;
case Common::KEYCODE_KP2: // down
if (!(_modifierStates & SCI_EVM_NUMLOCK))
input.data = SCI_K_DOWN;
break;
case Common::KEYCODE_KP6: // right
if (!(_modifierStates & SCI_EVM_NUMLOCK))
input.data = SCI_K_RIGHT;
break;
case Common::KEYCODE_KP4: // left
if (!(_modifierStates & SCI_EVM_NUMLOCK))
input.data = SCI_K_LEFT;
break;
case Common::KEYCODE_KP5: // center
if (!(_modifierStates & SCI_EVM_NUMLOCK))
input.data = SCI_K_CENTER;
break;
default:
input.type = SCI_EVT_NONE;
break;
}
input.character = input.data;
}
break;
// Mouse events
case Common::EVENT_LBUTTONDOWN:
input.type = SCI_EVT_MOUSE_PRESS;
input.data = 1;
break;
case Common::EVENT_RBUTTONDOWN:
input.type = SCI_EVT_MOUSE_PRESS;
input.data = 2;
break;
case Common::EVENT_LBUTTONUP:
input.type = SCI_EVT_MOUSE_RELEASE;
input.data = 1;
break;
case Common::EVENT_RBUTTONUP:
input.type = SCI_EVT_MOUSE_RELEASE;
input.data = 2;
break;
// Misc events
case Common::EVENT_QUIT:
input.type = SCI_EVT_QUIT;
break;
default:
break;
}
}
return input;
}
sci_event_t gfxop_get_event(GfxState *state, unsigned int mask) {
//sci_event_t error_event = { SCI_EVT_ERROR, 0, 0, 0 };
sci_event_t event = { 0, 0, 0, 0 };
// TODO: we need to call SciGuiCursor::refreshPosition() before each screen update to limit the mouse cursor position
// Update the screen here, since it's called very often
g_system->updateScreen();
// Get all queued events from graphics driver
do {
event = scummvm_get_event();
if (event.type != SCI_EVT_NONE)
state->_events.push_back(event);
} while (event.type != SCI_EVT_NONE);
// Search for matching event in queue
Common::List<sci_event_t>::iterator iter = state->_events.begin();
while (iter != state->_events.end() && !((*iter).type & mask))
++iter;
if (iter != state->_events.end()) {
// Event found
event = *iter;
// If not peeking at the queue, remove the event
if (!(mask & SCI_EVT_PEEK)) {
state->_events.erase(iter);
}
} else {
// No event found: we must return a SCI_EVT_NONE event.
// Because event.type is SCI_EVT_NONE already here,
// there is no need to change it.
}
if (event.type == SCI_EVT_KEYBOARD) {
// Do we still have to translate the key?
event.character = event.data;
// Scancodify if appropriate
if (event.buckybits & SCI_EVM_ALT)
event.character = _gfxop_scancode(event.character);
// Shift if appropriate
else if (((event.buckybits & (SCI_EVM_RSHIFT | SCI_EVM_LSHIFT)) && !(event.buckybits & SCI_EVM_CAPSLOCK))
|| (!(event.buckybits & (SCI_EVM_RSHIFT | SCI_EVM_LSHIFT)) && (event.buckybits & SCI_EVM_CAPSLOCK)))
event.character = _gfxop_shiftify(event.character);
// Numlockify if appropriate
else if (event.buckybits & SCI_EVM_NUMLOCK)
event.data = _gfxop_numlockify(event.data);
}
return event;
}
} // End of namespace Sci } // End of namespace Sci

View file

@ -28,15 +28,20 @@
#ifndef SCI_GFX_GFX_OPERATIONS_H #ifndef SCI_GFX_GFX_OPERATIONS_H
#define 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_resmgr.h"
#include "sci/gfx/gfx_tools.h" #include "sci/gfx/gfx_tools.h"
#include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_system.h"
#endif
#include "sci/uinput.h" #include "sci/uinput.h"
#include "common/list.h" #include "common/list.h"
namespace Sci { namespace Sci {
#ifdef INCLUDE_OLDGFX
struct TextFragment; struct TextFragment;
/* Threshold in color index mode to differentiate between visible and non-visible stuff. /* 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; typedef Common::List<rect_t> DirtyRectList;
#endif // INCLUDE_OLDGFX
struct GfxState { struct GfxState {
#ifdef INCLUDE_OLDGFX
rect_t clip_zone_unscaled; /**< The current UNSCALED clipping zone */ 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 */ 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 pic_nr; /**< Number of the current pic */
int palette_nr; /**< Palette 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 */ gfxr_pic_t *pic, *pic_unscaled; /**< The background picture and its unscaled equivalent */
rect_t pic_port_bounds; /**< Picture port bounds */ rect_t pic_port_bounds; /**< Picture port bounds */
DirtyRectList _dirtyRects; /**< Dirty rectangles */ DirtyRectList _dirtyRects; /**< Dirty rectangles */
#endif
Common::List<sci_event_t> _events;
}; };
#ifdef INCLUDE_OLDGFX
/** @name Fundamental operations */ /** @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 */ /** @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); 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 } // End of namespace Sci
#endif // SCI_GFX_GFX_OPERATIONS_H #endif // SCI_GFX_GFX_OPERATIONS_H

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#include "sci/gfx/palette.h" #include "sci/gfx/palette.h"
#include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_system.h"
@ -323,3 +326,5 @@ Palette *Palette::copy() {
} // End of namespace Sci } // End of namespace Sci
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#ifndef SCI_GFX_PALETTE_H #ifndef SCI_GFX_PALETTE_H
#define SCI_GFX_PALETTE_H #define SCI_GFX_PALETTE_H
@ -122,3 +125,5 @@ private:
} // End of namespace Sci } // End of namespace Sci
#endif // SCI_GFX_PALETTE_H #endif // SCI_GFX_PALETTE_H
#endif

View file

@ -124,6 +124,14 @@ enum controlStateFlags {
kControlStateDitherFramed = 0x1000 ///< 0001 0000 0000 0000 - widgets surrounded by a dithered frame (used in kgraphics) 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 } // End of namespace Sci
#endif #endif

View file

@ -23,6 +23,8 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_system.h"
#include "sci/gfx/gfx_resource.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 } // End of namespace Sci
#endif

View file

@ -23,10 +23,12 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#include "graphics/cursorman.h" #include "graphics/cursorman.h"
#include "common/util.h" #include "common/util.h"
#include "sci/sci.h"
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/debug.h" // for g_debug_sleeptime_factor #include "sci/debug.h" // for g_debug_sleeptime_factor
#include "sci/resource.h" #include "sci/resource.h"
@ -264,67 +266,6 @@ void _k_redraw_box(EngineState *s, int x1, int y1, int x2, int y2) {
#endif #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) { static Common::Rect nsrect_clip(EngineState *s, int y, Common::Rect retval, int priority) {
int pri_top; int pri_top;
@ -2820,3 +2761,5 @@ bool SciGui32::debugShowMap(int mapNo) {
} }
} // End of namespace Sci } // End of namespace Sci
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#ifndef SCI_GUI32_GUI32_H #ifndef SCI_GUI32_GUI32_H
#define SCI_GUI32_GUI32_H #define SCI_GUI32_GUI32_H
@ -135,3 +138,5 @@ private:
} // End of namespace Sci } // End of namespace Sci
#endif #endif
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
#include "common/endian.h" #include "common/endian.h"
#include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_system.h"
#include "sci/gfx/gfx_resource.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 } // End of namespace Sci
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
/* SCI1 palette resource defrobnicator */ /* SCI1 palette resource defrobnicator */
#include "common/file.h" #include "common/file.h"
@ -133,3 +136,5 @@ Palette *gfxr_read_pal1_amiga(Common::File &file) {
} }
} // End of namespace Sci } // End of namespace Sci
#endif

View file

@ -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 <time.h> // for time() to seed rand() via srand()
#include "common/endian.h" #include "common/endian.h"
#include "sci/gfx/gfx_resource.h" #include "sci/gfx/gfx_resource.h"
#include "sci/gfx/gfx_tools.h" #include "sci/gfx/gfx_tools.h"
#include "sci/sci.h" // for kDebugLevelSci0Pic
namespace Sci { namespace Sci {
@ -1533,3 +1535,5 @@ void gfxr_dither_pic0(gfxr_pic_t *pic, DitherMode dmode) {
} }
} // End of namespace Sci } // End of namespace Sci
#endif

View file

@ -23,6 +23,9 @@
* *
*/ */
#include "sci/sci.h" // for INCLUDE_OLDGFX
#ifdef INCLUDE_OLDGFX
// SCI 1 view resource defrobnicator // SCI 1 view resource defrobnicator
#include "common/endian.h" #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 } // End of namespace Sci
#endif

View file

@ -34,7 +34,7 @@
#include "sound/audiostream.h" #include "sound/audiostream.h"
#include "sound/mixer.h" // for SoundHandle #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/decompressor.h"
#include "sci/sci.h" #include "sci/sci.h"

View file

@ -35,8 +35,10 @@
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/engine/kernel.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/gfx/gfx_state_internal.h" // required for GfxContainer, GfxPort, GfxVisual
#include "sci/gui32/gui32.h" #include "sci/gui32/gui32.h"
#include "sci/gui/gui.h"
#include "sci/gui/gui_palette.h" #include "sci/gui/gui_palette.h"
#include "sci/gui/gui_cursor.h" #include "sci/gui/gui_cursor.h"
#include "sci/gui/gui_screen.h" #include "sci/gui/gui_screen.h"
@ -141,7 +143,9 @@ Common::Error SciEngine::run() {
ConfMan.registerDefault("undither", "true"); ConfMan.registerDefault("undither", "true");
screen->unditherSetState(ConfMan.getBool("undither")); screen->unditherSetState(ConfMan.getBool("undither"));
#ifdef INCLUDE_OLDGFX
gfxop_init(&gfx_state, _resMan, screen, palette, 1); gfxop_init(&gfx_state, _resMan, screen, palette, 1);
#endif
if (game_init_graphics(_gamestate)) { // Init interpreter graphics if (game_init_graphics(_gamestate)) { // Init interpreter graphics
warning("Game initialization failed: Error in GFX subsystem. Aborting..."); warning("Game initialization failed: Error in GFX subsystem. Aborting...");
@ -168,7 +172,9 @@ Common::Error SciEngine::run() {
delete screen; delete screen;
delete _gamestate; delete _gamestate;
#ifdef INCLUDE_OLDGFX
gfxop_exit(&gfx_state); gfxop_exit(&gfx_state);
#endif
return Common::kNoError; return Common::kNoError;
} }

View file

@ -31,6 +31,8 @@
namespace Sci { namespace Sci {
#define INCLUDE_OLDGFX
class Console; class Console;
struct EngineState; struct EngineState;
class Kernel; class Kernel;