diff options
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/kernel.h | 50 | ||||
-rw-r--r-- | engines/sci/engine/kevent.cpp | 50 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 66 | ||||
-rw-r--r-- | engines/sci/engine/klists.cpp | 10 | ||||
-rw-r--r-- | engines/sci/engine/kmenu.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/kmovement.cpp | 124 | ||||
-rw-r--r-- | engines/sci/engine/kpathing.cpp | 30 | ||||
-rw-r--r-- | engines/sci/engine/ksound.cpp | 178 | ||||
-rw-r--r-- | engines/sci/engine/kstring.cpp | 15 | ||||
-rw-r--r-- | engines/sci/engine/state.cpp | 8 |
10 files changed, 270 insertions, 269 deletions
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index 943e258d08..f5d003d670 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -150,33 +150,37 @@ enum SelectorInvocation { kContinueOnInvalidSelector = 1 }; -#define GET_SEL32(_o_, _slc_) read_selector(segMan, _o_, ((SciEngine*)g_engine)->getKernel()->_selectorCache._slc_, __FILE__, __LINE__) -#define GET_SEL32V(_o_, _slc_) (GET_SEL32(_o_, _slc_).offset) -/* Retrieves a selector from an object -** Parameters: (reg_t) object: The address of the object which the selector should be read from -** (selector_name) selector: The selector to read -** Returns : (int16/uint16/reg_t) The selector value -** This macro halts on error. 'selector' must be a selector name registered in vm.h's -** SelectorCache and mapped in script.cpp. -*/ - -#define PUT_SEL32(_o_, _slc_, _val_) write_selector(segMan, _o_, ((SciEngine*)g_engine)->getKernel()->_selectorCache._slc_, _val_, __FILE__, __LINE__) -#define PUT_SEL32V(_o_, _slc_, _val_) PUT_SEL32(_o_, _slc_, make_reg(0, _val_)) -/* Writes a selector value to an object -** Parameters: (reg_t) object: The address of the object which the selector should be written to -** (selector_name) selector: The selector to read -** (int16) value: The value to write -** Returns : (void) -** This macro halts on error. 'selector' must be a selector name registered in vm.h's -** SelectorCache and mapped in script.cpp. -*/ +/** + * Retrieves a selector from an object. + * @param segMan the segment mananger + * @param _obj_ the address of the object which the selector should be read from + * @param _slc_ the selector to read + * @return the selector value as a reg_t + * This macro halts on error. 'selector' must be a selector name registered in vm.h's + * SelectorCache and mapped in script.cpp. + */ +#define GET_SEL32(segMan, _obj_, _slc_) read_selector(segMan, _obj_, ((SciEngine*)g_engine)->getKernel()->_selectorCache._slc_, __FILE__, __LINE__) +#define GET_SEL32V(segMan, _obj_, _slc_) (GET_SEL32(segMan, _obj_, _slc_).offset) +/** + * Writes a selector value to an object. + * @param segMan the segment mananger + * @param _obj_ the address of the object which the selector should be written to + * @param _slc_ the selector to read + * @param _val_ the value to write + * This macro halts on error. 'selector' must be a selector name registered in vm.h's + * SelectorCache and mapped in script.cpp. + */ +#define PUT_SEL32(segMan, _obj_, _slc_, _val_) write_selector(segMan, _obj_, ((SciEngine*)g_engine)->getKernel()->_selectorCache._slc_, _val_, __FILE__, __LINE__) +#define PUT_SEL32V(segMan, _obj_, _slc_, _val_) PUT_SEL32(segMan, _obj_, _slc_, make_reg(0, _val_)) + +/** + * Kludge for use with invoke_selector(). Used for compatibility with compilers + * that cannot handle vararg macros. + */ #define INV_SEL(_object_, _selector_, _noinvalid_) \ s, _object_, s->_kernel->_selectorCache._selector_, _noinvalid_, argv, argc, __FILE__, __LINE__ -/* Kludge for use with invoke_selector(). Used for compatibility with compilers that can't -** handle vararg macros. -*/ reg_t read_selector(SegManager *segMan, reg_t object, Selector selector_id, const char *fname, int line); diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp index 64167285a7..27158fac8c 100644 --- a/engines/sci/engine/kevent.cpp +++ b/engines/sci/engine/kevent.cpp @@ -49,11 +49,11 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) { // If there's a simkey pending, and the game wants a keyboard event, use the // simkey instead of a normal event if (g_debug_simulated_key && (mask & SCI_EVT_KEYBOARD)) { - PUT_SEL32V(obj, type, SCI_EVT_KEYBOARD); // Keyboard event - PUT_SEL32V(obj, message, g_debug_simulated_key); - PUT_SEL32V(obj, modifiers, SCI_EVM_NUMLOCK); // Numlock on - PUT_SEL32V(obj, x, mousePos.x); - PUT_SEL32V(obj, y, mousePos.y); + PUT_SEL32V(segMan, obj, type, SCI_EVT_KEYBOARD); // Keyboard event + PUT_SEL32V(segMan, obj, message, g_debug_simulated_key); + PUT_SEL32V(segMan, obj, modifiers, SCI_EVM_NUMLOCK); // Numlock on + PUT_SEL32V(segMan, obj, x, mousePos.x); + PUT_SEL32V(segMan, obj, y, mousePos.y); g_debug_simulated_key = 0; return make_reg(0, 1); } @@ -64,8 +64,8 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) { s->parser_event = NULL_REG; // Invalidate parser event - PUT_SEL32V(obj, x, mousePos.x); - PUT_SEL32V(obj, y, mousePos.y); + PUT_SEL32V(segMan, obj, x, mousePos.x); + PUT_SEL32V(segMan, obj, y, mousePos.y); //s->_gui->moveCursor(s->gfx_state->pointer_pos.x, s->gfx_state->pointer_pos.y); @@ -84,12 +84,12 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) { g_debugState.seeking = kDebugSeekNothing; g_debugState.runningStep = 0; } else { - PUT_SEL32V(obj, type, SCI_EVT_KEYBOARD); // Keyboard event + PUT_SEL32V(segMan, obj, type, SCI_EVT_KEYBOARD); // Keyboard event s->r_acc = make_reg(0, 1); - PUT_SEL32V(obj, message, e.character); + PUT_SEL32V(segMan, obj, message, e.character); // We only care about the translated // character - PUT_SEL32V(obj, modifiers, e.buckybits&modifier_mask); + PUT_SEL32V(segMan, obj, modifiers, e.buckybits&modifier_mask); } break; @@ -115,9 +115,9 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) { break; } - PUT_SEL32V(obj, type, e.type); - PUT_SEL32V(obj, message, 0); - PUT_SEL32V(obj, modifiers, (e.buckybits | extra_bits)&modifier_mask); + PUT_SEL32V(segMan, obj, type, e.type); + PUT_SEL32V(segMan, obj, message, 0); + PUT_SEL32V(segMan, obj, modifiers, (e.buckybits | extra_bits)&modifier_mask); s->r_acc = make_reg(0, 1); } break; @@ -158,9 +158,9 @@ reg_t kMapKeyToDir(EngineState *s, int argc, reg_t *argv) { reg_t obj = argv[0]; SegManager *segMan = s->_segMan; - if (GET_SEL32V(obj, type) == SCI_EVT_KEYBOARD) { // Keyboard + if (GET_SEL32V(segMan, obj, type) == SCI_EVT_KEYBOARD) { // Keyboard int mover = -1; - switch (GET_SEL32V(obj, message)) { + switch (GET_SEL32V(segMan, obj, message)) { case SCI_K_HOME: mover = 8; break; @@ -194,8 +194,8 @@ reg_t kMapKeyToDir(EngineState *s, int argc, reg_t *argv) { } if (mover >= 0) { - PUT_SEL32V(obj, type, SCI_EVT_JOYSTICK); - PUT_SEL32V(obj, message, mover); + PUT_SEL32V(segMan, obj, type, SCI_EVT_JOYSTICK); + PUT_SEL32V(segMan, obj, message, mover); return make_reg(0, 1); } else return NULL_REG; @@ -209,13 +209,13 @@ reg_t kGlobalToLocal(EngineState *s, int argc, reg_t *argv) { SegManager *segMan = s->_segMan; if (obj.segment) { - int16 x = GET_SEL32V(obj, x); - int16 y = GET_SEL32V(obj, y); + int16 x = GET_SEL32V(segMan, obj, x); + int16 y = GET_SEL32V(segMan, obj, y); s->_gui->globalToLocal(&x, &y); - PUT_SEL32V(obj, x, x); - PUT_SEL32V(obj, y, y); + PUT_SEL32V(segMan, obj, x, x); + PUT_SEL32V(segMan, obj, y, y); } return s->r_acc; @@ -227,13 +227,13 @@ reg_t kLocalToGlobal(EngineState *s, int argc, reg_t *argv) { SegManager *segMan = s->_segMan; if (obj.segment) { - int16 x = GET_SEL32V(obj, x); - int16 y = GET_SEL32V(obj, y); + int16 x = GET_SEL32V(segMan, obj, x); + int16 y = GET_SEL32V(segMan, obj, y); s->_gui->localToGlobal(&x, &y); - PUT_SEL32V(obj, x, x); - PUT_SEL32V(obj, y, y); + PUT_SEL32V(segMan, obj, x, x); + PUT_SEL32V(segMan, obj, y, y); } return s->r_acc; diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 25685ee448..6fa7ecabb7 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -61,8 +61,8 @@ enum { void _k_dirloop(reg_t obj, uint16 angle, EngineState *s, int argc, reg_t *argv) { SegManager *segMan = s->_segMan; - int view = GET_SEL32V(obj, view); - int signal = GET_SEL32V(obj, signal); + int view = GET_SEL32V(segMan, obj, view); + int signal = GET_SEL32V(segMan, obj, signal); int loop; int maxloops; bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY); @@ -100,7 +100,7 @@ void _k_dirloop(reg_t obj, uint16 angle, EngineState *s, int argc, reg_t *argv) if ((loop > 1) && (maxloops < 4)) return; - PUT_SEL32V(obj, loop, loop); + PUT_SEL32V(segMan, obj, loop, loop); } static reg_t kSetCursorSci0(EngineState *s, int argc, reg_t *argv) { @@ -443,7 +443,7 @@ reg_t kCelWide(EngineState *s, int argc, reg_t *argv) { reg_t kNumLoops(EngineState *s, int argc, reg_t *argv) { SegManager *segMan = s->_segMan; reg_t obj = argv[0]; - int view = GET_SEL32V(obj, view); + int view = GET_SEL32V(segMan, obj, view); int loops_nr = gfxop_lookup_view_get_loops(s->gfx_state, view); if (loops_nr < 0) { @@ -459,8 +459,8 @@ reg_t kNumLoops(EngineState *s, int argc, reg_t *argv) { reg_t kNumCels(EngineState *s, int argc, reg_t *argv) { SegManager *segMan = s->_segMan; reg_t obj = argv[0]; - int loop = GET_SEL32V(obj, loop); - int view = GET_SEL32V(obj, view); + int loop = GET_SEL32V(segMan, obj, loop); + int view = GET_SEL32V(segMan, obj, view); int cel = 0xffff; gfxop_check_cel(s->gfx_state, view, &loop, &cel); @@ -544,10 +544,10 @@ reg_t kBaseSetter(EngineState *s, int argc, reg_t *argv) { Common::Rect absrect = set_base(s, object); SegManager *segMan = s->_segMan; - PUT_SEL32V(object, brLeft, absrect.left); - PUT_SEL32V(object, brRight, absrect.right); - PUT_SEL32V(object, brTop, absrect.top); - PUT_SEL32V(object, brBottom, absrect.bottom); + PUT_SEL32V(segMan, object, brLeft, absrect.left); + PUT_SEL32V(segMan, object, brRight, absrect.right); + PUT_SEL32V(segMan, object, brTop, absrect.top); + PUT_SEL32V(segMan, object, brBottom, absrect.bottom); } return s->r_acc; @@ -620,12 +620,12 @@ reg_t kPalVary(EngineState *s, int argc, reg_t *argv) { } static void disableCertainButtons(SegManager *segMan, Common::String gameName, reg_t obj) { - reg_t text_pos = GET_SEL32(obj, text); + reg_t text_pos = GET_SEL32(segMan, obj, text); Common::String text; if (!text_pos.isNull()) text = segMan->getString(text_pos); - int type = GET_SEL32V(obj, type); - int state = GET_SEL32V(obj, state); + int type = GET_SEL32V(segMan, obj, type); + int state = GET_SEL32V(segMan, obj, state); /* * WORKAROUND: The function is a "prevent the user from doing something @@ -649,25 +649,25 @@ static void disableCertainButtons(SegManager *segMan, Common::String gameName, r // NOTE: This _only_ works with the English version if (type == SCI_CONTROLS_TYPE_BUTTON && (gameName == "sq4") && getSciVersion() < SCI_VERSION_1_1 && text == " Delete ") { - PUT_SEL32V(obj, state, (state | kControlStateDisabled) & ~kControlStateEnabled); + PUT_SEL32V(segMan, obj, state, (state | kControlStateDisabled) & ~kControlStateEnabled); } // Disable the "Change Directory" button, as we don't allow the game engine to // change the directory where saved games are placed // NOTE: This _only_ works with the English version if (type == SCI_CONTROLS_TYPE_BUTTON && text == "Change\r\nDirectory") { - PUT_SEL32V(obj, state, (state | kControlStateDisabled) & ~kControlStateEnabled); + PUT_SEL32V(segMan, obj, state, (state | kControlStateDisabled) & ~kControlStateEnabled); } } void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) { SegManager *segMan = s->_segMan; - int16 type = GET_SEL32V(controlObject, type); - int16 style = GET_SEL32V(controlObject, state); - int16 x = GET_SEL32V(controlObject, nsLeft); - int16 y = GET_SEL32V(controlObject, nsTop); - GuiResourceId fontId = GET_SEL32V(controlObject, font); - reg_t textReference = GET_SEL32(controlObject, text); + int16 type = GET_SEL32V(segMan, controlObject, type); + int16 style = GET_SEL32V(segMan, controlObject, state); + int16 x = GET_SEL32V(segMan, controlObject, nsLeft); + int16 y = GET_SEL32V(segMan, controlObject, nsTop); + GuiResourceId fontId = GET_SEL32V(segMan, controlObject, font); + reg_t textReference = GET_SEL32(segMan, controlObject, text); Common::String text; Common::Rect rect; GuiTextAlignment alignment; @@ -681,7 +681,7 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) { const char **listEntries = NULL; bool isAlias = false; - kGraphCreateRect(x, y, GET_SEL32V(controlObject, nsRight), GET_SEL32V(controlObject, nsBottom), &rect); + kGraphCreateRect(x, y, GET_SEL32V(segMan, controlObject, nsRight), GET_SEL32V(segMan, controlObject, nsBottom), &rect); if (!textReference.isNull()) text = segMan->getString(textReference); @@ -693,25 +693,25 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) { return; case SCI_CONTROLS_TYPE_TEXT: - alignment = GET_SEL32V(controlObject, mode); + alignment = GET_SEL32V(segMan, controlObject, mode); debugC(2, kDebugLevelGraphics, "drawing text %04x:%04x ('%s') to %d,%d, mode=%d\n", PRINT_REG(controlObject), text.c_str(), x, y, alignment); s->_gui->drawControlText(rect, controlObject, s->strSplit(text.c_str(), NULL).c_str(), fontId, alignment, style, hilite); return; case SCI_CONTROLS_TYPE_TEXTEDIT: - mode = GET_SEL32V(controlObject, mode); - maxChars = GET_SEL32V(controlObject, max); - cursorPos = GET_SEL32V(controlObject, cursor); + mode = GET_SEL32V(segMan, controlObject, mode); + maxChars = GET_SEL32V(segMan, controlObject, max); + cursorPos = GET_SEL32V(segMan, controlObject, cursor); debugC(2, kDebugLevelGraphics, "drawing edit control %04x:%04x (text %04x:%04x, '%s') to %d,%d\n", PRINT_REG(controlObject), PRINT_REG(textReference), text.c_str(), x, y); s->_gui->drawControlTextEdit(rect, controlObject, s->strSplit(text.c_str(), NULL).c_str(), fontId, mode, style, cursorPos, maxChars, hilite); return; case SCI_CONTROLS_TYPE_ICON: - viewId = GET_SEL32V(controlObject, view); + viewId = GET_SEL32V(segMan, controlObject, view); { - int l = GET_SEL32V(controlObject, loop); + int l = GET_SEL32V(segMan, controlObject, loop); loopNo = (l & 0x80) ? l - 256 : l; - int c = GET_SEL32V(controlObject, cel); + int c = GET_SEL32V(segMan, controlObject, cel); celNo = (c & 0x80) ? c - 256 : c; } debugC(2, kDebugLevelGraphics, "drawing icon control %04x:%04x to %d,%d\n", PRINT_REG(controlObject), x, y - 1); @@ -723,18 +723,18 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) { if (type == SCI_CONTROLS_TYPE_LIST_ALIAS) isAlias = true; - maxChars = GET_SEL32V(controlObject, x); // max chars per entry + maxChars = GET_SEL32V(segMan, controlObject, x); // max chars per entry // NOTE: most types of pointer dereferencing don't like odd offsets if (maxChars & 1) { warning("List control with odd maxChars %d. This is not yet implemented for all types of segments", maxChars); } - cursorOffset = GET_SEL32V(controlObject, cursor); + cursorOffset = GET_SEL32V(segMan, controlObject, cursor); if (s->_kernel->_selectorCache.topString != -1) { // Games from early SCI1 onwards use topString - upperOffset = GET_SEL32V(controlObject, topString); + upperOffset = GET_SEL32V(segMan, controlObject, topString); } else { // Earlier games use lsTop - upperOffset = GET_SEL32V(controlObject, lsTop); + upperOffset = GET_SEL32V(segMan, controlObject, lsTop); } // Count string entries in NULL terminated string list diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp index 17caae0e43..523f8ed3c6 100644 --- a/engines/sci/engine/klists.cpp +++ b/engines/sci/engine/klists.cpp @@ -389,11 +389,11 @@ reg_t kSort(EngineState *s, int argc, reg_t *argv) { reg_t dest = argv[1]; reg_t order_func = argv[2]; - int input_size = (int16)GET_SEL32V(source, size); + int input_size = (int16)GET_SEL32V(segMan, source, size); int i; - reg_t input_data = GET_SEL32(source, elements); - reg_t output_data = GET_SEL32(dest, elements); + reg_t input_data = GET_SEL32(segMan, source, elements); + reg_t output_data = GET_SEL32(segMan, dest, elements); List *list; Node *node; @@ -404,10 +404,10 @@ reg_t kSort(EngineState *s, int argc, reg_t *argv) { if (output_data.isNull()) { list = s->_segMan->allocateList(&output_data); list->first = list->last = NULL_REG; - PUT_SEL32(dest, elements, output_data); + PUT_SEL32(segMan, dest, elements, output_data); } - PUT_SEL32V(dest, size, input_size); + PUT_SEL32V(segMan, dest, size, input_size); list = s->_segMan->lookupList(input_data); node = s->_segMan->lookupNode(list->first); diff --git a/engines/sci/engine/kmenu.cpp b/engines/sci/engine/kmenu.cpp index 4c71796d6a..37c43096c1 100644 --- a/engines/sci/engine/kmenu.cpp +++ b/engines/sci/engine/kmenu.cpp @@ -114,9 +114,9 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) { reg_t event = argv[0]; /*int pause_sound = (argc > 1) ? argv[1].toUint16() : 1;*/ /* FIXME: Do this eventually */ bool claimed = false; - int type = GET_SEL32V(event, type); - int message = GET_SEL32V(event, message); - int modifiers = GET_SEL32V(event, modifiers); + int type = GET_SEL32V(segMan, event, type); + int message = GET_SEL32V(segMan, event, message); + int modifiers = GET_SEL32V(segMan, event, modifiers); int menu_nr = -1, item_nr = 0; MenuItem *item; int menu_mode = 0; /* Menu is active */ @@ -320,7 +320,7 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) { } if (claimed) { - PUT_SEL32(event, claimed, make_reg(0, 1)); + PUT_SEL32(segMan, event, claimed, make_reg(0, 1)); if (menu_nr > -1) { s->r_acc = make_reg(0, ((menu_nr + 1) << 8) | (item_nr + 1)); diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index 50a9c45f1b..62a8bc88b0 100644 --- a/engines/sci/engine/kmovement.cpp +++ b/engines/sci/engine/kmovement.cpp @@ -155,8 +155,8 @@ reg_t kSetJump(EngineState *s, int argc, reg_t *argv) { debugC(2, kDebugLevelBresen, "SetJump for object at %04x:%04x\n", PRINT_REG(object)); debugC(2, kDebugLevelBresen, "xStep: %d, yStep: %d\n", vx, vy); - PUT_SEL32V(object, xStep, vx); - PUT_SEL32V(object, yStep, vy); + PUT_SEL32V(segMan, object, xStep, vx); + PUT_SEL32V(segMan, object, yStep, vy); return s->r_acc; } @@ -165,9 +165,9 @@ reg_t kSetJump(EngineState *s, int argc, reg_t *argv) { #define _K_BRESEN_AXIS_Y 1 static void initialize_bresen(SegManager *segMan, int argc, reg_t *argv, reg_t mover, int step_factor, int deltax, int deltay) { - reg_t client = GET_SEL32(mover, client); - int stepx = (int16)GET_SEL32V(client, xStep) * step_factor; - int stepy = (int16)GET_SEL32V(client, yStep) * step_factor; + reg_t client = GET_SEL32(segMan, mover, client); + int stepx = (int16)GET_SEL32V(segMan, client, xStep) * step_factor; + int stepy = (int16)GET_SEL32V(segMan, client, yStep) * step_factor; int numsteps_x = stepx ? (abs(deltax) + stepx - 1) / stepx : 0; int numsteps_y = stepy ? (abs(deltay) + stepy - 1) / stepy : 0; int bdi, i1; @@ -188,15 +188,15 @@ static void initialize_bresen(SegManager *segMan, int argc, reg_t *argv, reg_t m /* if (abs(deltax) > abs(deltay)) {*/ // Bresenham on y if (numsteps_y < numsteps_x) { - PUT_SEL32V(mover, b_xAxis, _K_BRESEN_AXIS_Y); - PUT_SEL32V(mover, b_incr, (deltay < 0) ? -1 : 1); + PUT_SEL32V(segMan, mover, b_xAxis, _K_BRESEN_AXIS_Y); + PUT_SEL32V(segMan, mover, b_incr, (deltay < 0) ? -1 : 1); //i1 = 2 * (abs(deltay) - abs(deltay_step * numsteps)) * abs(deltax_step); //bdi = -abs(deltax); i1 = 2 * (abs(deltay) - abs(deltay_step * (numsteps - 1))) * abs(deltax_step); bdi = -abs(deltax); } else { // Bresenham on x - PUT_SEL32V(mover, b_xAxis, _K_BRESEN_AXIS_X); - PUT_SEL32V(mover, b_incr, (deltax < 0) ? -1 : 1); + PUT_SEL32V(segMan, mover, b_xAxis, _K_BRESEN_AXIS_X); + PUT_SEL32V(segMan, mover, b_incr, (deltax < 0) ? -1 : 1); //i1= 2 * (abs(deltax) - abs(deltax_step * numsteps)) * abs(deltay_step); //bdi = -abs(deltay); i1 = 2 * (abs(deltax) - abs(deltax_step * (numsteps - 1))) * abs(deltay_step); @@ -204,26 +204,26 @@ static void initialize_bresen(SegManager *segMan, int argc, reg_t *argv, reg_t m } - PUT_SEL32V(mover, dx, deltax_step); - PUT_SEL32V(mover, dy, deltay_step); + PUT_SEL32V(segMan, mover, dx, deltax_step); + PUT_SEL32V(segMan, mover, dy, deltay_step); debugC(2, kDebugLevelBresen, "Init bresen for mover %04x:%04x: d=(%d,%d)\n", PRINT_REG(mover), deltax, deltay); debugC(2, kDebugLevelBresen, " steps=%d, mv=(%d, %d), i1= %d, i2=%d\n", numsteps, deltax_step, deltay_step, i1, bdi*2); - //PUT_SEL32V(mover, b_movCnt, numsteps); // Needed for HQ1/Ogre? - PUT_SEL32V(mover, b_di, bdi); - PUT_SEL32V(mover, b_i1, i1); - PUT_SEL32V(mover, b_i2, bdi * 2); + //PUT_SEL32V(segMan, mover, b_movCnt, numsteps); // Needed for HQ1/Ogre? + PUT_SEL32V(segMan, mover, b_di, bdi); + PUT_SEL32V(segMan, mover, b_i1, i1); + PUT_SEL32V(segMan, mover, b_i2, bdi * 2); } reg_t kInitBresen(EngineState *s, int argc, reg_t *argv) { SegManager *segMan = s->_segMan; reg_t mover = argv[0]; - reg_t client = GET_SEL32(mover, client); + reg_t client = GET_SEL32(segMan, mover, client); - int deltax = (int16)GET_SEL32V(mover, x) - (int16)GET_SEL32V(client, x); - int deltay = (int16)GET_SEL32V(mover, y) - (int16)GET_SEL32V(client, y); + int deltax = (int16)GET_SEL32V(segMan, mover, x) - (int16)GET_SEL32V(segMan, client, x); + int deltay = (int16)GET_SEL32V(segMan, mover, y) - (int16)GET_SEL32V(segMan, client, y); int step_factor = (argc < 1) ? argv[1].toUint16() : 1; initialize_bresen(s->_segMan, argc, argv, mover, step_factor, deltax, deltay); @@ -237,42 +237,42 @@ reg_t kInitBresen(EngineState *s, int argc, reg_t *argv) { reg_t kDoBresen(EngineState *s, int argc, reg_t *argv) { SegManager *segMan = s->_segMan; reg_t mover = argv[0]; - reg_t client = GET_SEL32(mover, client); + reg_t client = GET_SEL32(segMan, mover, client); - int x = (int16)GET_SEL32V(client, x); - int y = (int16)GET_SEL32V(client, y); + int x = (int16)GET_SEL32V(segMan, client, x); + int y = (int16)GET_SEL32V(segMan, client, y); int oldx, oldy, destx, desty, dx, dy, bdi, bi1, bi2, movcnt, bdelta, axis; - uint16 signal = GET_SEL32V(client, signal); + uint16 signal = GET_SEL32V(segMan, client, signal); int completed = 0; - int max_movcnt = GET_SEL32V(client, moveSpeed); + int max_movcnt = GET_SEL32V(segMan, client, moveSpeed); if (getSciVersion() > SCI_VERSION_01) signal &= ~_K_VIEW_SIG_FLAG_HIT_OBSTACLE; - PUT_SEL32(client, signal, make_reg(0, signal)); // This is a NOP for SCI0 + PUT_SEL32(segMan, client, signal, make_reg(0, signal)); // This is a NOP for SCI0 oldx = x; oldy = y; - destx = (int16)GET_SEL32V(mover, x); - desty = (int16)GET_SEL32V(mover, y); - dx = (int16)GET_SEL32V(mover, dx); - dy = (int16)GET_SEL32V(mover, dy); - bdi = (int16)GET_SEL32V(mover, b_di); - bi1 = (int16)GET_SEL32V(mover, b_i1); - bi2 = (int16)GET_SEL32V(mover, b_i2); - movcnt = GET_SEL32V(mover, b_movCnt); - bdelta = (int16)GET_SEL32V(mover, b_incr); - axis = (int16)GET_SEL32V(mover, b_xAxis); + destx = (int16)GET_SEL32V(segMan, mover, x); + desty = (int16)GET_SEL32V(segMan, mover, y); + dx = (int16)GET_SEL32V(segMan, mover, dx); + dy = (int16)GET_SEL32V(segMan, mover, dy); + bdi = (int16)GET_SEL32V(segMan, mover, b_di); + bi1 = (int16)GET_SEL32V(segMan, mover, b_i1); + bi2 = (int16)GET_SEL32V(segMan, mover, b_i2); + movcnt = GET_SEL32V(segMan, mover, b_movCnt); + bdelta = (int16)GET_SEL32V(segMan, mover, b_incr); + axis = (int16)GET_SEL32V(segMan, mover, b_xAxis); //printf("movecnt %d, move speed %d\n", movcnt, max_movcnt); if (s->handleMoveCount()) { if (max_movcnt > movcnt) { ++movcnt; - PUT_SEL32V(mover, b_movCnt, movcnt); // Needed for HQ1/Ogre? + PUT_SEL32V(segMan, mover, b_movCnt, movcnt); // Needed for HQ1/Ogre? return NULL_REG; } else { movcnt = 0; - PUT_SEL32V(mover, b_movCnt, movcnt); // Needed for HQ1/Ogre? + PUT_SEL32V(segMan, mover, b_movCnt, movcnt); // Needed for HQ1/Ogre? } } @@ -285,7 +285,7 @@ reg_t kDoBresen(EngineState *s, int argc, reg_t *argv) { dy += bdelta; } - PUT_SEL32V(mover, b_di, bdi); + PUT_SEL32V(segMan, mover, b_di, bdi); x += dx; y += dy; @@ -307,8 +307,8 @@ reg_t kDoBresen(EngineState *s, int argc, reg_t *argv) { debugC(2, kDebugLevelBresen, "Finished mover %04x:%04x\n", PRINT_REG(mover)); } - PUT_SEL32V(client, x, x); - PUT_SEL32V(client, y, y); + PUT_SEL32V(segMan, client, x, x); + PUT_SEL32V(segMan, client, y, y); debugC(2, kDebugLevelBresen, "New data: (x,y)=(%d,%d), di=%d\n", x, y, bdi); @@ -320,11 +320,11 @@ reg_t kDoBresen(EngineState *s, int argc, reg_t *argv) { } if (!s->r_acc.offset) { // Contains the return value - signal = GET_SEL32V(client, signal); + signal = GET_SEL32V(segMan, client, signal); - PUT_SEL32V(client, x, oldx); - PUT_SEL32V(client, y, oldy); - PUT_SEL32V(client, signal, (signal | _K_VIEW_SIG_FLAG_HIT_OBSTACLE)); + PUT_SEL32V(segMan, client, x, oldx); + PUT_SEL32V(segMan, client, y, oldy); + PUT_SEL32V(segMan, client, signal, (signal | _K_VIEW_SIG_FLAG_HIT_OBSTACLE)); debugC(2, kDebugLevelBresen, "Finished mover %04x:%04x by collision\n", PRINT_REG(mover)); completed = 1; @@ -356,15 +356,15 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } - client = GET_SEL32(avoider, client); + client = GET_SEL32(segMan, avoider, client); if (!s->_segMan->isHeapObject(client)) { warning("DoAvoider() where client %04x:%04x is not an object", PRINT_REG(client)); return NULL_REG; } - looper = GET_SEL32(client, looper); - mover = GET_SEL32(client, mover); + looper = GET_SEL32(segMan, client, looper); + mover = GET_SEL32(segMan, client, mover); if (!s->_segMan->isHeapObject(mover)) { if (mover.segment) { @@ -373,8 +373,8 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { return s->r_acc; } - destx = GET_SEL32V(mover, x); - desty = GET_SEL32V(mover, y); + destx = GET_SEL32V(segMan, mover, x); + desty = GET_SEL32V(segMan, mover, y); debugC(2, kDebugLevelBresen, "Doing avoider %04x:%04x (dest=%d,%d)\n", PRINT_REG(avoider), destx, desty); @@ -383,7 +383,7 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } - mover = GET_SEL32(client, mover); + mover = GET_SEL32(segMan, client, mover); if (!mover.segment) // Mover has been disposed? return s->r_acc; // Return gracefully. @@ -393,18 +393,18 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } - dx = destx - GET_SEL32V(client, x); - dy = desty - GET_SEL32V(client, y); + dx = destx - GET_SEL32V(segMan, client, x); + dy = desty - GET_SEL32V(segMan, client, y); angle = get_angle(dx, dy); debugC(2, kDebugLevelBresen, "Movement (%d,%d), angle %d is %sblocked\n", dx, dy, angle, (s->r_acc.offset) ? " " : "not "); if (s->r_acc.offset) { // isBlocked() returned non-zero int rotation = (rand() & 1) ? 45 : (360 - 45); // Clockwise/counterclockwise - int oldx = GET_SEL32V(client, x); - int oldy = GET_SEL32V(client, y); - int xstep = GET_SEL32V(client, xStep); - int ystep = GET_SEL32V(client, yStep); + int oldx = GET_SEL32V(segMan, client, x); + int oldy = GET_SEL32V(segMan, client, y); + int xstep = GET_SEL32V(segMan, client, xStep); + int ystep = GET_SEL32V(segMan, client, yStep); int moves; debugC(2, kDebugLevelBresen, " avoider %04x:%04x\n", PRINT_REG(avoider)); @@ -413,8 +413,8 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { int move_x = (int)(sin(angle * PI / 180.0) * (xstep)); int move_y = (int)(-cos(angle * PI / 180.0) * (ystep)); - PUT_SEL32V(client, x, oldx + move_x); - PUT_SEL32V(client, y, oldy + move_y); + PUT_SEL32V(segMan, client, x, oldx + move_x); + PUT_SEL32V(segMan, client, y, oldy + move_y); debugC(2, kDebugLevelBresen, "Pos (%d,%d): Trying angle %d; delta=(%d,%d)\n", oldx, oldy, angle, move_x, move_y); @@ -424,12 +424,12 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } - PUT_SEL32V(client, x, oldx); - PUT_SEL32V(client, y, oldy); + PUT_SEL32V(segMan, client, x, oldx); + PUT_SEL32V(segMan, client, y, oldy); if (s->r_acc.offset) { // We can be here debugC(2, kDebugLevelBresen, "Success\n"); - PUT_SEL32V(client, heading, angle); + PUT_SEL32V(segMan, client, heading, angle); return make_reg(0, angle); } @@ -442,12 +442,12 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { warning("DoAvoider failed for avoider %04x:%04x", PRINT_REG(avoider)); } else { - int heading = GET_SEL32V(client, heading); + int heading = GET_SEL32V(segMan, client, heading); if (heading == -1) return s->r_acc; // No change - PUT_SEL32V(client, heading, angle); + PUT_SEL32V(segMan, client, heading, angle); s->r_acc = make_reg(0, angle); diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index 9bca946882..569311e099 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -278,17 +278,17 @@ static Common::Point read_point(SegManager *segMan, reg_t list, int offset) { */ static bool polygons_equal(SegManager *segMan, reg_t p1, reg_t p2) { // Check for same type - if (GET_SEL32(p1, type).toUint16() != GET_SEL32(p2, type).toUint16()) + if (GET_SEL32(segMan, p1, type).toUint16() != GET_SEL32(segMan, p2, type).toUint16()) return false; - int size = GET_SEL32(p1, size).toUint16(); + int size = GET_SEL32(segMan, p1, size).toUint16(); // Check for same number of points - if (size != GET_SEL32(p2, size).toUint16()) + if (size != GET_SEL32(segMan, p2, size).toUint16()) return false; - reg_t p1_points = GET_SEL32(p1, points); - reg_t p2_points = GET_SEL32(p2, points); + reg_t p1_points = GET_SEL32(segMan, p1, points); + reg_t p2_points = GET_SEL32(segMan, p2, points); // Check for the same points for (int i = 0; i < size; i++) { @@ -346,9 +346,9 @@ static void draw_point(EngineState *s, Common::Point p, int start) { static void draw_polygon(EngineState *s, reg_t polygon) { SegManager *segMan = s->_segMan; - reg_t points = GET_SEL32(polygon, points); - int size = GET_SEL32(polygon, size).toUint16(); - int type = GET_SEL32(polygon, type).toUint16(); + reg_t points = GET_SEL32(segMan, polygon, points); + int size = GET_SEL32(segMan, polygon, size).toUint16(); + int type = GET_SEL32(segMan, polygon, type).toUint16(); Common::Point first, prev; int i; @@ -391,9 +391,9 @@ static void draw_input(EngineState *s, reg_t poly_list, Common::Point start, Com #endif // DEBUG_AVOIDPATH static void print_polygon(SegManager *segMan, reg_t polygon) { - reg_t points = GET_SEL32(polygon, points); - int size = GET_SEL32(polygon, size).toUint16(); - int type = GET_SEL32(polygon, type).toUint16(); + reg_t points = GET_SEL32(segMan, polygon, points); + int size = GET_SEL32(segMan, polygon, size).toUint16(); + int type = GET_SEL32(segMan, polygon, type).toUint16(); int i; Common::Point point; @@ -1220,15 +1220,15 @@ static Polygon *convert_polygon(EngineState *s, reg_t polygon) { // Returns : (Polygon *) The converted polygon, or NULL on error SegManager *segMan = s->_segMan; int i; - reg_t points = GET_SEL32(polygon, points); - int size = GET_SEL32(polygon, size).toUint16(); + reg_t points = GET_SEL32(segMan, polygon, points); + int size = GET_SEL32(segMan, polygon, size).toUint16(); if (size == 0) { // If the polygon has no vertices, we skip it return NULL; } - Polygon *poly = new Polygon(GET_SEL32(polygon, type).toUint16()); + Polygon *poly = new Polygon(GET_SEL32(segMan, polygon, type).toUint16()); int skip = 0; @@ -1388,7 +1388,7 @@ static PathfindingState *convert_polygon_set(EngineState *s, reg_t poly_list, Co if (polygon) { pf_s->polygons.push_back(polygon); - count += GET_SEL32(node->value, size).toUint16(); + count += GET_SEL32(segMan, node->value, size).toUint16(); } } diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index a70cb1a2ea..b834f87b6b 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -131,9 +131,9 @@ enum AudioSyncCommands { static void script_set_priority(EngineState *s, reg_t obj, int priority) { SegManager *segMan = s->_segMan; - int song_nr = GET_SEL32V(obj, number); + int song_nr = GET_SEL32V(segMan, obj, number); Resource *song = s->resMan->findResource(ResourceId(kResourceTypeSound, song_nr), 0); - int flags = GET_SEL32V(obj, flags); + int flags = GET_SEL32V(segMan, obj, flags); if (priority == -1) { if (song->data[0] == 0xf0) @@ -145,7 +145,7 @@ static void script_set_priority(EngineState *s, reg_t obj, int priority) { } else flags |= SCI1_SOUND_FLAG_SCRIPTED_PRI; s->_sound.sfx_song_renice(FROBNICATE_HANDLE(obj), priority); - PUT_SEL32V(obj, flags, flags); + PUT_SEL32V(segMan, obj, flags, flags); } SongIterator *build_iterator(EngineState *s, int song_nr, SongIteratorType type, songit_id_t id) { @@ -183,27 +183,27 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their case SI_LOOP: debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x looped (to %d)\n", PRINT_REG(obj), cue); - /* PUT_SEL32V(obj, loops, GET_SEL32V(obj, loop) - 1);*/ - PUT_SEL32V(obj, signal, SIGNAL_OFFSET); + /* PUT_SEL32V(segMan, obj, loops, GET_SEL32V(segMan, obj, loop) - 1);*/ + PUT_SEL32V(segMan, obj, signal, SIGNAL_OFFSET); break; case SI_RELATIVE_CUE: debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x received relative cue %d\n", PRINT_REG(obj), cue); - PUT_SEL32V(obj, signal, cue + 0x7f); + PUT_SEL32V(segMan, obj, signal, cue + 0x7f); break; case SI_ABSOLUTE_CUE: debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x received absolute cue %d\n", PRINT_REG(obj), cue); - PUT_SEL32V(obj, signal, cue); + PUT_SEL32V(segMan, obj, signal, cue); break; case SI_FINISHED: debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x finished\n", PRINT_REG(obj)); - PUT_SEL32V(obj, signal, SIGNAL_OFFSET); - PUT_SEL32V(obj, state, _K_SOUND_STATUS_STOPPED); + PUT_SEL32V(segMan, obj, signal, SIGNAL_OFFSET); + PUT_SEL32V(segMan, obj, state, _K_SOUND_STATUS_STOPPED); break; default: @@ -220,7 +220,7 @@ static reg_t kDoSoundSci0(EngineState *s, int argc, reg_t *argv) { uint16 command = argv[0].toUint16(); SongHandle handle = FROBNICATE_HANDLE(obj); int number = obj.segment ? - GET_SEL32V(obj, number) : + GET_SEL32V(segMan, obj, number) : -1; /* We were not going to use it anyway */ #ifdef DEBUG_SOUND @@ -285,20 +285,20 @@ static reg_t kDoSoundSci0(EngineState *s, int argc, reg_t *argv) { switch (command) { case _K_SCI0_SOUND_INIT_HANDLE: if (obj.segment) { - debugC(2, kDebugLevelSound, "Initializing song number %d\n", GET_SEL32V(obj, number)); + debugC(2, kDebugLevelSound, "Initializing song number %d\n", GET_SEL32V(segMan, obj, number)); s->_sound.sfx_add_song(build_iterator(s, number, SCI_SONG_ITERATOR_TYPE_SCI0, handle), 0, handle, number); - PUT_SEL32V(obj, state, _K_SOUND_STATUS_INITIALIZED); - PUT_SEL32(obj, handle, obj); /* ``sound handle'': we use the object address */ + PUT_SEL32V(segMan, obj, state, _K_SOUND_STATUS_INITIALIZED); + PUT_SEL32(segMan, obj, handle, obj); /* ``sound handle'': we use the object address */ } break; case _K_SCI0_SOUND_PLAY_HANDLE: if (obj.segment) { s->_sound.sfx_song_set_status(handle, SOUND_STATUS_PLAYING); - s->_sound.sfx_song_set_loops(handle, GET_SEL32V(obj, loop)); - PUT_SEL32V(obj, state, _K_SOUND_STATUS_PLAYING); + s->_sound.sfx_song_set_loops(handle, GET_SEL32V(segMan, obj, loop)); + PUT_SEL32V(segMan, obj, state, _K_SOUND_STATUS_PLAYING); } break; @@ -309,27 +309,27 @@ static reg_t kDoSoundSci0(EngineState *s, int argc, reg_t *argv) { if (obj.segment) { s->_sound.sfx_remove_song(handle); } - PUT_SEL32V(obj, handle, 0x0000); + PUT_SEL32V(segMan, obj, handle, 0x0000); break; case _K_SCI0_SOUND_STOP_HANDLE: if (obj.segment) { s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); - PUT_SEL32V(obj, state, SOUND_STATUS_STOPPED); + PUT_SEL32V(segMan, obj, state, SOUND_STATUS_STOPPED); } break; case _K_SCI0_SOUND_SUSPEND_HANDLE: if (obj.segment) { s->_sound.sfx_song_set_status(handle, SOUND_STATUS_SUSPENDED); - PUT_SEL32V(obj, state, SOUND_STATUS_SUSPENDED); + PUT_SEL32V(segMan, obj, state, SOUND_STATUS_SUSPENDED); } break; case _K_SCI0_SOUND_RESUME_HANDLE: if (obj.segment) { s->_sound.sfx_song_set_status(handle, SOUND_STATUS_PLAYING); - PUT_SEL32V(obj, state, SOUND_STATUS_PLAYING); + PUT_SEL32V(segMan, obj, state, SOUND_STATUS_PLAYING); } break; @@ -360,8 +360,8 @@ static reg_t kDoSoundSci0(EngineState *s, int argc, reg_t *argv) { case _K_SCI0_SOUND_UPDATE_VOL_PRI: if (obj.segment) { - s->_sound.sfx_song_set_loops(handle, GET_SEL32V(obj, loop)); - script_set_priority(s, obj, GET_SEL32V(obj, pri)); + s->_sound.sfx_song_set_loops(handle, GET_SEL32V(segMan, obj, loop)); + script_set_priority(s, obj, GET_SEL32V(segMan, obj, pri)); } break; @@ -371,8 +371,8 @@ static reg_t kDoSoundSci0(EngineState *s, int argc, reg_t *argv) { ** than fading it! */ if (obj.segment) { s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); - PUT_SEL32V(obj, state, SOUND_STATUS_STOPPED); - PUT_SEL32V(obj, signal, SIGNAL_OFFSET); + PUT_SEL32V(segMan, obj, state, SOUND_STATUS_STOPPED); + PUT_SEL32V(segMan, obj, signal, SIGNAL_OFFSET); } break; @@ -400,7 +400,7 @@ static reg_t kDoSoundSci1Early(EngineState *s, int argc, reg_t *argv) { reg_t obj = (argc > 1) ? argv[1] : NULL_REG; SongHandle handle = FROBNICATE_HANDLE(obj); int number = obj.segment ? - GET_SEL32V(obj, number) : + GET_SEL32V(segMan, obj, number) : -1; /* We were not going to use it anyway */ #ifdef DEBUG_SOUND @@ -499,9 +499,9 @@ static reg_t kDoSoundSci1Early(EngineState *s, int argc, reg_t *argv) { break; } case _K_SCI01_SOUND_PLAY_HANDLE : { - int looping = GET_SEL32V(obj, loop); - //int vol = GET_SEL32V(obj, vol); - int pri = GET_SEL32V(obj, pri); + int looping = GET_SEL32V(segMan, obj, loop); + //int vol = GET_SEL32V(segMan, obj, vol); + int pri = GET_SEL32V(segMan, obj, pri); RESTORE_BEHAVIOR rb = (RESTORE_BEHAVIOR) argv[2].toUint16(); /* Too lazy to look up a default value for this */ if (obj.segment) { @@ -509,22 +509,22 @@ static reg_t kDoSoundSci1Early(EngineState *s, int argc, reg_t *argv) { s->_sound.sfx_song_set_loops(handle, looping); s->_sound.sfx_song_renice(handle, pri); s->_sound._songlib.setSongRestoreBehavior(handle, rb); - PUT_SEL32V(obj, signal, 0); + PUT_SEL32V(segMan, obj, signal, 0); } break; } case _K_SCI01_SOUND_INIT_HANDLE : { - //int looping = GET_SEL32V(obj, loop); - //int vol = GET_SEL32V(obj, vol); - //int pri = GET_SEL32V(obj, pri); + //int looping = GET_SEL32V(segMan, obj, loop); + //int vol = GET_SEL32V(segMan, obj, vol); + //int pri = GET_SEL32V(segMan, obj, pri); if (obj.segment && (s->resMan->testResource(ResourceId(kResourceTypeSound, number)))) { debugC(2, kDebugLevelSound, "Initializing song number %d\n", number); s->_sound.sfx_add_song(build_iterator(s, number, SCI_SONG_ITERATOR_TYPE_SCI1, handle), 0, handle, number); - PUT_SEL32(obj, nodePtr, obj); - PUT_SEL32(obj, handle, obj); + PUT_SEL32(segMan, obj, nodePtr, obj); + PUT_SEL32(segMan, obj, handle, obj); } break; } @@ -543,24 +543,24 @@ static reg_t kDoSoundSci1Early(EngineState *s, int argc, reg_t *argv) { int frame = 0; /* FIXME: Update the sound server state with 'vol' */ - int looping = GET_SEL32V(obj, loop); - //int vol = GET_SEL32V(obj, vol); - int pri = GET_SEL32V(obj, pri); + int looping = GET_SEL32V(segMan, obj, loop); + //int vol = GET_SEL32V(segMan, obj, vol); + int pri = GET_SEL32V(segMan, obj, pri); s->_sound.sfx_song_set_loops(handle, looping); s->_sound.sfx_song_renice(handle, pri); debugC(2, kDebugLevelSound, "[sound01-update-handle] -- CUE %04x:%04x", PRINT_REG(obj)); - PUT_SEL32V(obj, signal, signal); - PUT_SEL32V(obj, min, min); - PUT_SEL32V(obj, sec, sec); - PUT_SEL32V(obj, frame, frame); + PUT_SEL32V(segMan, obj, signal, signal); + PUT_SEL32V(segMan, obj, min, min); + PUT_SEL32V(segMan, obj, sec, sec); + PUT_SEL32V(segMan, obj, frame, frame); break; } case _K_SCI01_SOUND_STOP_HANDLE : { - PUT_SEL32V(obj, signal, SIGNAL_OFFSET); + PUT_SEL32V(segMan, obj, signal, SIGNAL_OFFSET); if (obj.segment) { s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); } @@ -581,7 +581,7 @@ static reg_t kDoSoundSci1Early(EngineState *s, int argc, reg_t *argv) { * TODO: Figure out the exact semantics */ /* FIXME: The next couple of lines actually STOP the song right away */ - PUT_SEL32V(obj, signal, SIGNAL_OFFSET); + PUT_SEL32V(segMan, obj, signal, SIGNAL_OFFSET); if (obj.segment) { s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); } @@ -605,7 +605,7 @@ static reg_t kDoSoundSci1Early(EngineState *s, int argc, reg_t *argv) { debugC(2, kDebugLevelSound, "--- [CUE] %04x:%04x Absolute Cue: %d\n", PRINT_REG(obj), signal); - PUT_SEL32V(obj, signal, signal); + PUT_SEL32V(segMan, obj, signal, signal); break; case SI_RELATIVE_CUE: @@ -616,13 +616,13 @@ static reg_t kDoSoundSci1Early(EngineState *s, int argc, reg_t *argv) { /* FIXME to match commented-out semantics * below, with proper storage of dataInc and * signal in the iterator code. */ - PUT_SEL32V(obj, dataInc, signal); - PUT_SEL32V(obj, signal, signal); + PUT_SEL32V(segMan, obj, dataInc, signal); + PUT_SEL32V(segMan, obj, signal, signal); break; case SI_FINISHED: debugC(2, kDebugLevelSound, "--- [FINISHED] %04x:%04x\n", PRINT_REG(obj)); - PUT_SEL32V(obj, signal, SIGNAL_OFFSET); + PUT_SEL32V(segMan, obj, signal, SIGNAL_OFFSET); break; case SI_LOOP: @@ -632,13 +632,13 @@ static reg_t kDoSoundSci1Early(EngineState *s, int argc, reg_t *argv) { /* switch (signal) */ /* { */ /* case 0x00: */ - /* if (dataInc!=GET_SEL32V(obj, dataInc)) */ + /* if (dataInc!=GET_SEL32V(segMan, obj, dataInc)) */ /* { */ - /* PUT_SEL32V(obj, dataInc, dataInc); */ - /* PUT_SEL32V(obj, signal, dataInc+0x7f); */ + /* PUT_SEL32V(segMan, obj, dataInc, dataInc); */ + /* PUT_SEL32V(segMan, obj, signal, dataInc+0x7f); */ /* } else */ /* { */ - /* PUT_SEL32V(obj, signal, signal); */ + /* PUT_SEL32V(segMan, obj, signal, signal); */ /* } */ /* break; */ /* case 0xFF: /\* May be unnecessary *\/ */ @@ -646,20 +646,20 @@ static reg_t kDoSoundSci1Early(EngineState *s, int argc, reg_t *argv) { /* handle, SOUND_STATUS_STOPPED); */ /* break; */ /* default : */ - /* if (dataInc!=GET_SEL32V(obj, dataInc)) */ + /* if (dataInc!=GET_SEL32V(segMan, obj, dataInc)) */ /* { */ - /* PUT_SEL32V(obj, dataInc, dataInc); */ - /* PUT_SEL32V(obj, signal, dataInc+0x7f); */ + /* PUT_SEL32V(segMan, obj, dataInc, dataInc); */ + /* PUT_SEL32V(segMan, obj, signal, dataInc+0x7f); */ /* } else */ /* { */ - /* PUT_SEL32V(obj, signal, signal); */ + /* PUT_SEL32V(segMan, obj, signal, signal); */ /* } */ /* break; */ /* } */ - PUT_SEL32V(obj, min, min); - PUT_SEL32V(obj, sec, sec); - PUT_SEL32V(obj, frame, frame); + PUT_SEL32V(segMan, obj, min, min); + PUT_SEL32V(segMan, obj, sec, sec); + PUT_SEL32V(segMan, obj, frame, frame); break; } case _K_SCI01_SOUND_MIDI_SEND : { @@ -692,7 +692,7 @@ static reg_t kDoSoundSci1Late(EngineState *s, int argc, reg_t *argv) { reg_t obj = (argc > 1) ? argv[1] : NULL_REG; SongHandle handle = FROBNICATE_HANDLE(obj); int number = obj.segment ? - GET_SEL32V(obj, number) : + GET_SEL32V(segMan, obj, number) : -1; /* We were not going to use it anyway */ #ifdef DEBUG_SOUND @@ -812,19 +812,19 @@ static reg_t kDoSoundSci1Late(EngineState *s, int argc, reg_t *argv) { return make_reg(0, 1); } case _K_SCI1_SOUND_PLAY_HANDLE : { - int looping = GET_SEL32V(obj, loop); - //int vol = GET_SEL32V(obj, vol); - int pri = GET_SEL32V(obj, pri); + int looping = GET_SEL32V(segMan, obj, loop); + //int vol = GET_SEL32V(segMan, obj, vol); + int pri = GET_SEL32V(segMan, obj, pri); int sampleLen = 0; Song *song = s->_sound._songlib.findSong(handle); - if (GET_SEL32V(obj, nodePtr) && (song && number != song->_resourceNum)) { + if (GET_SEL32V(segMan, obj, nodePtr) && (song && number != song->_resourceNum)) { s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); s->_sound.sfx_remove_song(handle); - PUT_SEL32(obj, nodePtr, NULL_REG); + PUT_SEL32(segMan, obj, nodePtr, NULL_REG); } - if (!GET_SEL32V(obj, nodePtr) && obj.segment) { + if (!GET_SEL32V(segMan, obj, nodePtr) && obj.segment) { // In SCI1.1 games, sound effects are started from here. If we can find // a relevant audio resource, play it, otherwise switch to synthesized // effects. If the resource exists, play it using map 65535 (sound @@ -842,7 +842,7 @@ static reg_t kDoSoundSci1Late(EngineState *s, int argc, reg_t *argv) { warning("Could not open song number %d", number); // Send a "stop handle" event so that the engine won't wait forever here s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); - PUT_SEL32V(obj, signal, SIGNAL_OFFSET); + PUT_SEL32V(segMan, obj, signal, SIGNAL_OFFSET); return s->r_acc; } debugC(2, kDebugLevelSound, "Initializing song number %d\n", number); @@ -850,25 +850,25 @@ static reg_t kDoSoundSci1Late(EngineState *s, int argc, reg_t *argv) { handle), 0, handle, number); } - PUT_SEL32(obj, nodePtr, obj); - PUT_SEL32(obj, handle, obj); + PUT_SEL32(segMan, obj, nodePtr, obj); + PUT_SEL32(segMan, obj, handle, obj); } if (obj.segment) { s->_sound.sfx_song_set_status(handle, SOUND_STATUS_PLAYING); s->_sound.sfx_song_set_loops(handle, looping); s->_sound.sfx_song_renice(handle, pri); - PUT_SEL32V(obj, signal, 0); + PUT_SEL32V(segMan, obj, signal, 0); } break; } case _K_SCI1_SOUND_INIT_HANDLE : { - //int looping = GET_SEL32V(obj, loop); - //int vol = GET_SEL32V(obj, vol); - //int pri = GET_SEL32V(obj, pri); + //int looping = GET_SEL32V(segMan, obj, loop); + //int vol = GET_SEL32V(segMan, obj, vol); + //int pri = GET_SEL32V(segMan, obj, pri); - if (GET_SEL32V(obj, nodePtr)) { + if (GET_SEL32V(segMan, obj, nodePtr)) { s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); s->_sound.sfx_remove_song(handle); } @@ -877,8 +877,8 @@ static reg_t kDoSoundSci1Late(EngineState *s, int argc, reg_t *argv) { debugC(2, kDebugLevelSound, "Initializing song number %d\n", number); s->_sound.sfx_add_song(build_iterator(s, number, SCI_SONG_ITERATOR_TYPE_SCI1, handle), 0, handle, number); - PUT_SEL32(obj, nodePtr, obj); - PUT_SEL32(obj, handle, obj); + PUT_SEL32(segMan, obj, nodePtr, obj); + PUT_SEL32(segMan, obj, handle, obj); } break; } @@ -890,7 +890,7 @@ static reg_t kDoSoundSci1Late(EngineState *s, int argc, reg_t *argv) { break; } case _K_SCI1_SOUND_STOP_HANDLE : { - PUT_SEL32V(obj, signal, SIGNAL_OFFSET); + PUT_SEL32V(segMan, obj, signal, SIGNAL_OFFSET); if (obj.segment) { s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); } @@ -914,13 +914,13 @@ static reg_t kDoSoundSci1Late(EngineState *s, int argc, reg_t *argv) { /* FIXME: The next couple of lines actually STOP the handle, rather ** than fading it! */ if (argv[5].toUint16()) { - PUT_SEL32V(obj, signal, SIGNAL_OFFSET); - PUT_SEL32V(obj, nodePtr, 0); - PUT_SEL32V(obj, handle, 0); + PUT_SEL32V(segMan, obj, signal, SIGNAL_OFFSET); + PUT_SEL32V(segMan, obj, nodePtr, 0); + PUT_SEL32V(segMan, obj, handle, 0); s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); } else { // FIXME: Support fade-and-continue. For now, send signal right away. - PUT_SEL32V(obj, signal, SIGNAL_OFFSET); + PUT_SEL32V(segMan, obj, signal, SIGNAL_OFFSET); } } break; @@ -944,14 +944,14 @@ static reg_t kDoSoundSci1Late(EngineState *s, int argc, reg_t *argv) { break; } case _K_SCI1_SOUND_SET_HANDLE_LOOP : { - if (!GET_SEL32(obj, nodePtr).isNull()) { + if (!GET_SEL32(segMan, obj, nodePtr).isNull()) { uint16 looping = argv[2].toUint16(); if (looping < 65535) looping = 1; s->_sound.sfx_song_set_loops(handle, looping); - PUT_SEL32V(obj, loop, looping); + PUT_SEL32V(segMan, obj, loop, looping); } break; } @@ -973,19 +973,19 @@ static reg_t kDoSoundSci1Late(EngineState *s, int argc, reg_t *argv) { debugC(2, kDebugLevelSound, "[CUE] %04x:%04x Absolute Cue: %d\n", PRINT_REG(obj), signal); - PUT_SEL32V(obj, signal, signal); + PUT_SEL32V(segMan, obj, signal, signal); break; case SI_RELATIVE_CUE: debugC(2, kDebugLevelSound, "[CUE] %04x:%04x Relative Cue: %d\n", PRINT_REG(obj), cue); - PUT_SEL32V(obj, dataInc, cue); - PUT_SEL32V(obj, signal, cue + 127); + PUT_SEL32V(segMan, obj, dataInc, cue); + PUT_SEL32V(segMan, obj, signal, cue + 127); break; case SI_FINISHED: - PUT_SEL32V(obj, signal, SIGNAL_OFFSET); + PUT_SEL32V(segMan, obj, signal, SIGNAL_OFFSET); break; case SI_LOOP: @@ -1110,12 +1110,12 @@ reg_t kDoSync(EngineState *s, int argc, reg_t *argv) { s->_sound._syncResource = s->resMan->findResource(id, 1); if (s->_sound._syncResource) { - PUT_SEL32V(argv[1], syncCue, 0); + PUT_SEL32V(segMan, argv[1], syncCue, 0); s->_sound._syncOffset = 0; } else { warning("DoSync: failed to find resource %s", id.toString().c_str()); // Notify the scripts to stop sound sync - PUT_SEL32V(argv[1], syncCue, SIGNAL_OFFSET); + PUT_SEL32V(segMan, argv[1], syncCue, SIGNAL_OFFSET); } break; } @@ -1132,8 +1132,8 @@ reg_t kDoSync(EngineState *s, int argc, reg_t *argv) { s->_sound._syncOffset += 2; } - PUT_SEL32V(argv[1], syncTime, syncTime); - PUT_SEL32V(argv[1], syncCue, syncCue); + PUT_SEL32V(segMan, argv[1], syncTime, syncTime); + PUT_SEL32V(segMan, argv[1], syncCue, syncCue); } break; } diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index b31cd4018b..36a20bbbc7 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -79,7 +79,6 @@ Common::String kernel_lookup_text(EngineState *s, reg_t address, int index) { reg_t kSaid(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->_segMan; reg_t heap_said_block = argv[0]; byte *said_block; int new_lastmatch; @@ -104,7 +103,7 @@ reg_t kSaid(EngineState *s, int argc, reg_t *argv) { s->_voc->decipherSaidBlock(said_block); #endif - if (s->parser_event.isNull() || (GET_SEL32V(s->parser_event, claimed))) { + if (s->parser_event.isNull() || (GET_SEL32V(s->_segMan, s->parser_event, claimed))) { return NULL_REG; } @@ -118,7 +117,7 @@ reg_t kSaid(EngineState *s, int argc, reg_t *argv) { s->r_acc = make_reg(0, 1); if (new_lastmatch != SAID_PARTIAL_MATCH) - PUT_SEL32V(s->parser_event, claimed, 1); + PUT_SEL32V(s->_segMan, s->parser_event, claimed, 1); } else { return NULL_REG; @@ -137,14 +136,14 @@ reg_t kSetSynonyms(EngineState *s, int argc, reg_t *argv) { s->_voc->clearSynonyms(); - list = s->_segMan->lookupList(GET_SEL32(object, elements)); + list = s->_segMan->lookupList(GET_SEL32(segMan, object, elements)); node = s->_segMan->lookupNode(list->first); while (node) { reg_t objpos = node->value; int seg; - script = GET_SEL32V(objpos, number); + script = GET_SEL32V(segMan, objpos, number); seg = s->_segMan->getScriptSegment(script); if (seg > 0) @@ -214,7 +213,7 @@ reg_t kParse(EngineState *s, int argc, reg_t *argv) { if (syntax_fail) { s->r_acc = make_reg(0, 1); - PUT_SEL32V(event, claimed, 1); + PUT_SEL32V(segMan, event, claimed, 1); invoke_selector(INV_SEL(s->game_obj, syntaxFail, kStopOnInvalidSelector), 2, s->parser_base, stringpos); /* Issue warning */ @@ -223,7 +222,7 @@ reg_t kParse(EngineState *s, int argc, reg_t *argv) { } else { s->parserIsValid = true; - PUT_SEL32V(event, claimed, 0); + PUT_SEL32V(segMan, event, claimed, 0); #ifdef DEBUG_PARSER s->_voc->dumpParseTree(); @@ -233,7 +232,7 @@ reg_t kParse(EngineState *s, int argc, reg_t *argv) { } else { s->r_acc = make_reg(0, 0); - PUT_SEL32V(event, claimed, 1); + PUT_SEL32V(segMan, event, claimed, 1); if (error) { s->_segMan->strcpy(s->parser_base, error); debugC(2, kDebugLevelParser, "Word unknown: %s\n", error); diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index e850c8b07f..dee94d6985 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -177,8 +177,7 @@ kLanguage EngineState::getLanguage() { kLanguage lang = K_LANG_ENGLISH; if (_kernel->_selectorCache.printLang != -1) { - SegManager *segMan = _segMan; - lang = (kLanguage)GET_SEL32V(this->game_obj, printLang); + lang = (kLanguage)GET_SEL32V(_segMan, this->game_obj, printLang); if ((getSciVersion() == SCI_VERSION_1_1) || (lang == K_LANG_NONE)) { // If language is set to none, we use the language from the game detector. @@ -213,7 +212,7 @@ kLanguage EngineState::getLanguage() { } // Store language in printLang selector - PUT_SEL32V(this->game_obj, printLang, lang); + PUT_SEL32V(_segMan, this->game_obj, printLang, lang); } } @@ -225,8 +224,7 @@ Common::String EngineState::strSplit(const char *str, const char *sep) { kLanguage subLang = K_LANG_NONE; if (_kernel->_selectorCache.subtitleLang != -1) { - SegManager *segMan = _segMan; - subLang = (kLanguage)GET_SEL32V(this->game_obj, subtitleLang); + subLang = (kLanguage)GET_SEL32V(_segMan, this->game_obj, subtitleLang); } Common::String retval = getLanguageString(str, lang); |