aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/kgraphics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci/engine/kgraphics.cpp')
-rw-r--r--engines/sci/engine/kgraphics.cpp77
1 files changed, 40 insertions, 37 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index ffc14716a5..ab5cd57c34 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -203,8 +203,8 @@ int _find_priority_band(EngineState *s, int nr) {
}
reg_t graph_save_box(EngineState *s, rect_t area) {
- reg_t handle = kalloc(s, "graph_save_box()", sizeof(gfxw_snapshot_t *));
- gfxw_snapshot_t **ptr = (gfxw_snapshot_t **)kmem(s, handle);
+ reg_t handle = kalloc(s->segmentManager, "graph_save_box()", sizeof(gfxw_snapshot_t *));
+ gfxw_snapshot_t **ptr = (gfxw_snapshot_t **)kmem(s->segmentManager, handle);
// FIXME: gfxw_make_snapshot returns a pointer. Now why do we store a
// pointer to real memory inside the SCI heap?
@@ -225,7 +225,7 @@ void graph_restore_box(EngineState *s, reg_t handle) {
return;
}
- ptr = (gfxw_snapshot_t **)kmem(s, handle);
+ ptr = (gfxw_snapshot_t **)kmem(s->segmentManager, handle);
if (!ptr) {
warning("Attempt to restore invalid handle %04x:%04x", PRINT_REG(handle));
@@ -265,11 +265,11 @@ void graph_restore_box(EngineState *s, reg_t handle) {
free(*ptr);
*ptr = NULL;
- kfree(s, handle);
+ kfree(s->segmentManager, handle);
}
PaletteEntry get_pic_color(EngineState *s, int color) {
- if (!s->resmgr->isVGA())
+ if (!s->resourceManager->isVGA())
return s->ega_colors[color].visual;
if (color == -1 || color == 255) // -1 occurs in Eco Quest 1. Not sure if this is the best approach, but it seems to work
@@ -286,7 +286,7 @@ PaletteEntry get_pic_color(EngineState *s, int color) {
static gfx_color_t graph_map_color(EngineState *s, int color, int priority, int control) {
gfx_color_t retval;
- if (!s->resmgr->isVGA()) {
+ if (!s->resourceManager->isVGA()) {
retval = s->ega_colors[(color >=0 && color < 16)? color : 0];
gfxop_set_color(s->gfx_state, &retval, (color < 0) ? -1 : retval.visual.r, retval.visual.g, retval.visual.b,
(color == -1) ? 255 : 0, priority, control);
@@ -302,11 +302,13 @@ static gfx_color_t graph_map_color(EngineState *s, int color, int priority, int
}
reg_t kSetCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) {
+ SciVersion version = s->resourceManager->sciVersion();
+
switch (argc) {
case 1 :
- if (s->_version < SCI_VERSION_1_LATE) {
+ if (version < SCI_VERSION_1_LATE) {
GFX_ASSERT(gfxop_set_pointer_cursor(s->gfx_state, argv[0].toSint16()));
- } else if (s->_version < SCI_VERSION_1_1) {
+ } else if (version < SCI_VERSION_1_1) {
if (argv[0].toSint16() <= 1) {
// Newer (SCI1.1) semantics: show/hide cursor
CursorMan.showMouse(argv[0].toSint16() != 0);
@@ -320,10 +322,10 @@ reg_t kSetCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
break;
case 2 :
- if (s->_version < SCI_VERSION_1_LATE) {
+ if (version < SCI_VERSION_1_LATE) {
GFX_ASSERT(gfxop_set_pointer_cursor(s->gfx_state,
argv[1].toSint16() == 0 ? GFXOP_NO_POINTER : argv[0].toSint16()));
- } else if (s->_version < SCI_VERSION_1_1) {
+ } else if (version < SCI_VERSION_1_1) {
// Pre-SCI1.1: set cursor according to the first parameter, and toggle its
// visibility based on the second parameter
// Some late SCI1 games actually use the SCI1.1 version of this call (EcoQuest 1
@@ -502,7 +504,7 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) {
case K_GRAPH_GET_COLORS_NR:
- return make_reg(0, !s->resmgr->isVGA() ? 0x10 : 0x100);
+ return make_reg(0, !s->resourceManager->isVGA() ? 0x10 : 0x100);
break;
case K_GRAPH_DRAW_LINE: {
@@ -691,13 +693,14 @@ void _k_dirloop(reg_t obj, uint16 angle, EngineState *s, int funct_nr, int argc,
int signal = GET_SEL32V(obj, signal);
int loop;
int maxloops;
+ bool oldScriptHeader = (s->resourceManager->sciVersion() == SCI_VERSION_0_EARLY);
if (signal & _K_VIEW_SIG_FLAG_DOESNT_TURN)
return;
angle %= 360;
- if (!((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader()) {
+ if (!oldScriptHeader) {
if (angle < 45)
loop = 3;
else if (angle < 136)
@@ -827,7 +830,7 @@ reg_t kCanBeHere(EngineState *s, int funct_nr, int argc, reg_t *argv) {
while (widget) {
if (widget->_ID && (widget->signal & _K_VIEW_SIG_FLAG_STOPUPD)
&& ((widget->_ID != obj.segment) || (widget->_subID != obj.offset))
- && is_object(s, make_reg(widget->_ID, widget->_subID)))
+ && is_object(s->segmentManager, make_reg(widget->_ID, widget->_subID)))
if (collides_with(s, abs_zone, make_reg(widget->_ID, widget->_subID), 1, GASEOUS_VIEW_MASK_ACTIVE, funct_nr, argc, argv))
return not_register(s, NULL_REG);
@@ -853,7 +856,7 @@ reg_t kCanBeHere(EngineState *s, int funct_nr, int argc, reg_t *argv) {
reg_t other_obj = node->value;
debugC(2, kDebugLevelBresen, " comparing against %04x:%04x\n", PRINT_REG(other_obj));
- if (!is_object(s, other_obj)) {
+ if (!is_object(s->segmentManager, other_obj)) {
warning("CanBeHere() cliplist contains non-object %04x:%04x", PRINT_REG(other_obj));
} else if (other_obj != obj) { // Clipping against yourself is not recommended
@@ -1134,7 +1137,7 @@ Common::Rect set_base(EngineState *s, reg_t object) {
void _k_base_setter(EngineState *s, reg_t object) {
Common::Rect absrect = set_base(s, object);
- if (lookup_selector(s, object, ((SciEngine*)g_engine)->getKernel()->_selectorMap.brLeft, NULL, NULL) != kSelectorVariable)
+ if (lookup_selector(s->segmentManager, object, ((SciEngine*)g_engine)->getKernel()->_selectorMap.brLeft, NULL, NULL) != kSelectorVariable)
return; // non-fatal
// Note: there was a check here for a very old version of SCI, which supposedly needed
@@ -1142,7 +1145,7 @@ void _k_base_setter(EngineState *s, reg_t object) {
// does not exist (earliest one was KQ4 SCI, version 0.000.274). This code is left here
// for reference only
#if 0
- if (s->_version <= SCI_VERSION_0)
+ if (s->resourceManager->sciVersion() <= SCI_VERSION_0)
--absrect.top; // Compensate for early SCI OB1 'bug'
#endif
@@ -1239,7 +1242,7 @@ Common::Rect get_nsrect(EngineState *s, reg_t object, byte clip) {
static void _k_set_now_seen(EngineState *s, reg_t object) {
Common::Rect absrect = get_nsrect(s, object, 0);
- if (lookup_selector(s, object, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsTop, NULL, NULL) != kSelectorVariable) {
+ if (lookup_selector(s->segmentManager, object, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsTop, NULL, NULL) != kSelectorVariable) {
return;
} // This isn't fatal
@@ -1329,7 +1332,7 @@ static void _k_draw_control(EngineState *s, reg_t obj, int inverse);
static void _k_disable_delete_for_now(EngineState *s, reg_t obj) {
reg_t text_pos = GET_SEL32(obj, text);
- char *text = text_pos.isNull() ? NULL : (char *)s->seg_manager->dereference(text_pos, NULL);
+ char *text = text_pos.isNull() ? NULL : (char *)s->segmentManager->dereference(text_pos, NULL);
int type = GET_SEL32V(obj, type);
int state = GET_SEL32V(obj, state);
@@ -1353,7 +1356,7 @@ static void _k_disable_delete_for_now(EngineState *s, reg_t obj) {
* that game - bringing the save/load dialog on a par with SCI0.
*/
if (type == K_CONTROL_BUTTON && text && (s->_gameName == "sq4") &&
- s->_version < SCI_VERSION_1_1 && !strcmp(text, " Delete ")) {
+ s->resourceManager->sciVersion() < SCI_VERSION_1_1 && !strcmp(text, " Delete ")) {
PUT_SEL32V(obj, state, (state | kControlStateDisabled) & ~kControlStateEnabled);
}
}
@@ -1418,7 +1421,7 @@ reg_t kEditControl(EngineState *s, int funct_nr, int argc, reg_t *argv) {
reg_t text_pos = GET_SEL32(obj, text);
int display_offset = 0;
- char *text = (char *)s->seg_manager->dereference(text_pos, NULL);
+ char *text = (char *)s->segmentManager->dereference(text_pos, NULL);
int textlen;
if (!text) {
@@ -1580,7 +1583,7 @@ static void _k_draw_control(EngineState *s, reg_t obj, int inverse) {
int font_nr = GET_SEL32V(obj, font);
reg_t text_pos = GET_SEL32(obj, text);
- const char *text = text_pos.isNull() ? NULL : (char *)s->seg_manager->dereference(text_pos, NULL);
+ const char *text = text_pos.isNull() ? NULL : (char *)s->segmentManager->dereference(text_pos, NULL);
int view = GET_SEL32V(obj, view);
int cel = sign_extend_byte(GET_SEL32V(obj, cel));
int loop = sign_extend_byte(GET_SEL32V(obj, loop));
@@ -1702,7 +1705,7 @@ static void draw_rect_to_control_map(EngineState *s, Common::Rect abs_zone) {
static void draw_obj_to_control_map(EngineState *s, GfxDynView *view) {
reg_t obj = make_reg(view->_ID, view->_subID);
- if (!is_object(s, obj))
+ if (!is_object(s->segmentManager, obj))
warning("View %d does not contain valid object reference %04x:%04x", view->_ID, PRINT_REG(obj));
reg_t* sp = view->signalp.getPointer(s);
@@ -1725,7 +1728,7 @@ static void _k_view_list_do_postdraw(EngineState *s, GfxList *list) {
* if ((widget->signal & (_K_VIEW_SIG_FLAG_PRIVATE | _K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_NO_UPDATE)) == _K_VIEW_SIG_FLAG_PRIVATE) {
*/
if ((widget->signal & (_K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_NO_UPDATE)) == 0) {
- int has_nsrect = lookup_selector(s, obj, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsBottom, NULL, NULL) == kSelectorVariable;
+ int has_nsrect = lookup_selector(s->segmentManager, obj, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsBottom, NULL, NULL) == kSelectorVariable;
if (has_nsrect) {
int temp;
@@ -1747,7 +1750,7 @@ static void _k_view_list_do_postdraw(EngineState *s, GfxList *list) {
}
#ifdef DEBUG_LSRECT
else
- fprintf(stderr, "Not lsRecting %04x:%04x because %d\n", PRINT_REG(obj), lookup_selector(s, obj, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsBottom, NULL, NULL));
+ fprintf(stderr, "Not lsRecting %04x:%04x because %d\n", PRINT_REG(obj), lookup_selector(s->segmentManager, obj, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsBottom, NULL, NULL));
#endif
if (widget->signal & _K_VIEW_SIG_FLAG_HIDDEN)
@@ -1806,7 +1809,7 @@ int _k_view_list_dispose_loop(EngineState *s, List *list, GfxDynView *widget, in
reg_t obj = make_reg(widget->_ID, widget->_subID);
reg_t under_bits = NULL_REG;
- if (!is_object(s, obj)) {
+ if (!is_object(s->segmentManager, obj)) {
error("Non-object %04x:%04x present in view list during delete time", PRINT_REG(obj));
obj = NULL_REG;
} else {
@@ -1815,7 +1818,7 @@ int _k_view_list_dispose_loop(EngineState *s, List *list, GfxDynView *widget, in
reg_t mem_handle = *ubp;
if (mem_handle.segment) {
- if (!kfree(s, mem_handle)) {
+ if (!kfree(s->segmentManager, mem_handle)) {
*ubp = make_reg(0, widget->under_bits = 0);
} else {
warning("Treating viewobj %04x:%04x as no longer present", PRINT_REG(obj));
@@ -1824,7 +1827,7 @@ int _k_view_list_dispose_loop(EngineState *s, List *list, GfxDynView *widget, in
}
}
}
- if (is_object(s, obj)) {
+ if (is_object(s->segmentManager, obj)) {
if (invoke_selector(INV_SEL(obj, delete_, kContinueOnInvalidSelector), 0))
warning("Object at %04x:%04x requested deletion, but does not have a delete funcselector", PRINT_REG(obj));
if (_k_animate_ran) {
@@ -1924,7 +1927,7 @@ static GfxDynView *_k_make_dynview_obj(EngineState *s, reg_t obj, int options, i
}
ObjVarRef under_bitsp;
- if (lookup_selector(s, obj, ((SciEngine*)g_engine)->getKernel()->_selectorMap.underBits, &(under_bitsp), NULL) != kSelectorVariable) {
+ if (lookup_selector(s->segmentManager, obj, ((SciEngine*)g_engine)->getKernel()->_selectorMap.underBits, &(under_bitsp), NULL) != kSelectorVariable) {
under_bitsp.obj = NULL_REG;
under_bits = NULL_REG;
debugC(2, kDebugLevelGraphics, "Object at %04x:%04x has no underBits\n", PRINT_REG(obj));
@@ -1932,7 +1935,7 @@ static GfxDynView *_k_make_dynview_obj(EngineState *s, reg_t obj, int options, i
under_bits = *under_bitsp.getPointer(s);
ObjVarRef signalp;
- if (lookup_selector(s, obj, ((SciEngine*)g_engine)->getKernel()->_selectorMap.signal, &(signalp), NULL) != kSelectorVariable) {
+ if (lookup_selector(s->segmentManager, obj, ((SciEngine*)g_engine)->getKernel()->_selectorMap.signal, &(signalp), NULL) != kSelectorVariable) {
signalp.obj = NULL_REG;
signal = 0;
debugC(2, kDebugLevelGraphics, "Object at %04x:%04x has no signal selector\n", PRINT_REG(obj));
@@ -2025,7 +2028,7 @@ static void _k_prepare_view_list(EngineState *s, GfxList *list, int options) {
while (view) {
reg_t obj = make_reg(view->_ID, view->_subID);
int priority, _priority;
- int has_nsrect = (view->_ID <= 0) ? 0 : lookup_selector(s, obj, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsBottom, NULL, NULL) == kSelectorVariable;
+ int has_nsrect = (view->_ID <= 0) ? 0 : lookup_selector(s->segmentManager, obj, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsBottom, NULL, NULL) == kSelectorVariable;
int oldsignal = view->signal;
_k_set_now_seen(s, obj);
@@ -2503,7 +2506,7 @@ reg_t kNewWindow(EngineState *s, int funct_nr, int argc, reg_t *argv) {
int16 bgColor = (argc > 8 + argextra) ? argv[8 + argextra].toSint16() : 255;
if (bgColor >= 0) {
- if (!s->resmgr->isVGA())
+ if (!s->resourceManager->isVGA())
bgcolor.visual = get_pic_color(s, MIN<int>(bgColor, 15));
else
bgcolor.visual = get_pic_color(s, bgColor);
@@ -2529,7 +2532,7 @@ reg_t kNewWindow(EngineState *s, int funct_nr, int argc, reg_t *argv) {
black.alpha = 0;
black.control = -1;
black.priority = -1;
- lWhite.visual = get_pic_color(s, !s->resmgr->isVGA() ? 15 : 255);
+ lWhite.visual = get_pic_color(s, !s->resourceManager->isVGA() ? 15 : 255);
lWhite.mask = GFX_MASK_VISUAL;
lWhite.alpha = 0;
lWhite.priority = -1;
@@ -3150,7 +3153,7 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
bg_color = port->_bgcolor;
// TODO: in SCI1VGA the default colors for text and background are #0 (black)
// SCI0 case should be checked
- if (s->resmgr->isVGA()) {
+ if (s->resourceManager->isVGA()) {
// This priority check fixes the colors in the menus in KQ5
// TODO/FIXME: Is this correct?
if (color0.priority >= 0)
@@ -3192,10 +3195,10 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
temp = argv[argpt++].toSint16();
debugC(2, kDebugLevelGraphics, "Display: set_color(%d)\n", temp);
- if (!s->resmgr->isVGA() && temp >= 0 && temp <= 15)
+ if (!s->resourceManager->isVGA() && temp >= 0 && temp <= 15)
color0 = (s->ega_colors[temp]);
else
- if (s->resmgr->isVGA() && temp >= 0 && temp < 256) {
+ if (s->resourceManager->isVGA() && temp >= 0 && temp < 256) {
color0.visual = get_pic_color(s, temp);
color0.mask = GFX_MASK_VISUAL;
} else
@@ -3209,10 +3212,10 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
temp = argv[argpt++].toSint16();
debugC(2, kDebugLevelGraphics, "Display: set_bg_color(%d)\n", temp);
- if (!s->resmgr->isVGA() && temp >= 0 && temp <= 15)
+ if (!s->resourceManager->isVGA() && temp >= 0 && temp <= 15)
bg_color = s->ega_colors[temp];
else
- if (s->resmgr->isVGA() && temp >= 0 && temp <= 256) {
+ if (s->resourceManager->isVGA() && temp >= 0 && temp <= 256) {
bg_color.visual = get_pic_color(s, temp);
bg_color.mask = GFX_MASK_VISUAL;
} else