diff options
-rw-r--r-- | engines/sci/console.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kfile.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kmath.cpp | 16 | ||||
-rw-r--r-- | engines/sci/engine/kmisc.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kmovement.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/ksound.cpp | 24 | ||||
-rw-r--r-- | engines/sci/engine/vm_types.h | 6 | ||||
-rw-r--r-- | engines/sci/gfx/menubar.cpp | 6 |
9 files changed, 33 insertions, 29 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 2b3570daf5..e50139b3bc 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -2750,7 +2750,7 @@ bool Console::cmdStopSfx(int argc, const char **argv) { if (id.segment) { _vm->_gamestate->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); _vm->_gamestate->_sound.sfx_remove_song(handle); - PUT_SEL32V(id, signal, -1); + PUT_SEL32V(id, signal, SIGNAL_OFFSET); PUT_SEL32V(id, nodePtr, 0); PUT_SEL32V(id, handle, 0); } diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index 2a1d997da4..df4e3274af 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -144,7 +144,7 @@ void file_open(EngineState *s, const char *filename, int mode) { if (!inFile && !outFile) { // Failed debug(3, "file_open() failed"); - s->r_acc = make_reg(0, -1); + s->r_acc = make_reg(0, SIGNAL_OFFSET); return; } diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 363ce81910..fc72e6e3f1 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -873,7 +873,7 @@ reg_t kIsItSkip(EngineState *s, int, int argc, reg_t *argv) { if (!res) { warning("[GFX] Attempt to get cel parameters for invalid view %d", view); - return make_reg(0, -1); + return make_reg(0, SIGNAL_OFFSET); } pxm = res->loops[loop].cels[cel]; diff --git a/engines/sci/engine/kmath.cpp b/engines/sci/engine/kmath.cpp index 97f3ca4382..f2702839ca 100644 --- a/engines/sci/engine/kmath.cpp +++ b/engines/sci/engine/kmath.cpp @@ -129,8 +129,8 @@ reg_t kCosDiv(EngineState *s, int, int argc, reg_t *argv) { double cosval = cos(angle * PI / 180.0); if ((cosval < 0.0001) && (cosval > -0.0001)) { - warning("Attempted division by zero"); - return make_reg(0, 0); + warning("kCosDiv: Attempted division by zero"); + return make_reg(0, SIGNAL_OFFSET); } else return make_reg(0, (int16)(value / cosval)); } @@ -141,8 +141,8 @@ reg_t kSinDiv(EngineState *s, int, int argc, reg_t *argv) { double sinval = sin(angle * PI / 180.0); if ((sinval < 0.0001) && (sinval > -0.0001)) { - warning("Attempted division by zero"); - return make_reg(0, 0); + warning("kSinDiv: Attempted division by zero"); + return make_reg(0, SIGNAL_OFFSET); } else return make_reg(0, (int16)(value / sinval)); } @@ -153,8 +153,8 @@ reg_t kTimesTan(EngineState *s, int, int argc, reg_t *argv) { param -= 90; if ((param % 90) == 0) { - warning("Attempted tan(pi/2)"); - return make_reg(0, 0); + warning("kTimesTan: Attempted tan(pi/2)"); + return make_reg(0, SIGNAL_OFFSET); } else return make_reg(0, (int16) - (tan(param * PI / 180.0) * scale)); } @@ -164,8 +164,8 @@ reg_t kTimesCot(EngineState *s, int, int argc, reg_t *argv) { int scale = (argc > 1) ? argv[1].toSint16() : 1; if ((param % 90) == 0) { - warning("Attempted tan(pi/2)"); - return make_reg(0, 0); + warning("kTimesCot: Attempted tan(pi/2)"); + return make_reg(0, SIGNAL_OFFSET); } else return make_reg(0, (int16)(tan(param * PI / 180.0) * scale)); } diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 1ec2ffee1c..dbbb10a4d1 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -60,7 +60,7 @@ reg_t kGameIsRestarting(EngineState *s, int, int argc, reg_t *argv) { } reg_t kHaveMouse(EngineState *s, int, int argc, reg_t *argv) { - return make_reg(0, -1); + return make_reg(0, SIGNAL_OFFSET); } enum kMemoryInfoFunc { diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index a647a84cdb..ac4a2382ad 100644 --- a/engines/sci/engine/kmovement.cpp +++ b/engines/sci/engine/kmovement.cpp @@ -401,7 +401,7 @@ reg_t kDoAvoider(EngineState *s, int, int argc, reg_t *argv) { int dx, dy; int destx, desty; - s->r_acc = make_reg(0, -1); + s->r_acc = make_reg(0, SIGNAL_OFFSET); if (!s->segMan->isHeapObject(avoider)) { warning("DoAvoider() where avoider %04x:%04x is not an object", PRINT_REG(avoider)); diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index 43dfcae98b..628b8313b1 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -184,7 +184,7 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their 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, -1); + PUT_SEL32V(obj, signal, SIGNAL_OFFSET); break; case SI_RELATIVE_CUE: @@ -202,7 +202,7 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their case SI_FINISHED: debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x finished\n", PRINT_REG(obj)); - PUT_SEL32V(obj, signal, -1); + PUT_SEL32V(obj, signal, SIGNAL_OFFSET); PUT_SEL32V(obj, state, _K_SOUND_STATUS_STOPPED); break; @@ -372,7 +372,7 @@ static reg_t kDoSoundSci0(EngineState *s, int argc, reg_t *argv) { if (obj.segment) { s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); PUT_SEL32V(obj, state, SOUND_STATUS_STOPPED); - PUT_SEL32V(obj, signal, -1); + PUT_SEL32V(obj, signal, SIGNAL_OFFSET); } break; @@ -560,7 +560,7 @@ static reg_t kDoSoundSci1Early(EngineState *s, int argc, reg_t *argv) { break; } case _K_SCI01_SOUND_STOP_HANDLE : { - PUT_SEL32V(obj, signal, -1); + PUT_SEL32V(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, -1); + PUT_SEL32V(obj, signal, SIGNAL_OFFSET); if (obj.segment) { s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); } @@ -622,7 +622,7 @@ static reg_t kDoSoundSci1Early(EngineState *s, int argc, reg_t *argv) { case SI_FINISHED: debugC(2, kDebugLevelSound, "--- [FINISHED] %04x:%04x\n", PRINT_REG(obj)); - PUT_SEL32V(obj, signal, -1); + PUT_SEL32V(obj, signal, SIGNAL_OFFSET); break; case SI_LOOP: @@ -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, -1); + PUT_SEL32V(obj, signal, SIGNAL_OFFSET); return s->r_acc; } debugC(2, kDebugLevelSound, "Initializing song number %d\n", number); @@ -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, -1); + PUT_SEL32V(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, -1); + PUT_SEL32V(obj, signal, SIGNAL_OFFSET); PUT_SEL32V(obj, nodePtr, 0); PUT_SEL32V(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, -1); + PUT_SEL32V(obj, signal, SIGNAL_OFFSET); } } break; @@ -976,7 +976,7 @@ static reg_t kDoSoundSci1Late(EngineState *s, int argc, reg_t *argv) { break; case SI_FINISHED: - PUT_SEL32V(obj, signal, -1); + PUT_SEL32V(obj, signal, SIGNAL_OFFSET); break; case SI_LOOP: @@ -1106,7 +1106,7 @@ reg_t kDoSync(EngineState *s, int, int argc, reg_t *argv) { } else { warning("DoSync: failed to find resource %s", id.toString().c_str()); // Notify the scripts to stop sound sync - PUT_SEL32V(argv[1], syncCue, -1); + PUT_SEL32V(argv[1], syncCue, SIGNAL_OFFSET); } break; } diff --git a/engines/sci/engine/vm_types.h b/engines/sci/engine/vm_types.h index ba8a4d7057..62dc35aae7 100644 --- a/engines/sci/engine/vm_types.h +++ b/engines/sci/engine/vm_types.h @@ -67,9 +67,13 @@ typedef reg_t *StackPtr; typedef int Selector; #define NULL_SELECTOR -1 +// Offset sent to indicate an error, or that an operation has finished +// (depending on the case) +#define SIGNAL_OFFSET 0xffff + #define PRINT_STK(v) (unsigned) (v - s->stack_base) -static inline reg_t make_reg(SegmentId segment, int16 offset) { +static inline reg_t make_reg(SegmentId segment, uint16 offset) { reg_t r; r.offset = offset; r.segment = segment; diff --git a/engines/sci/gfx/menubar.cpp b/engines/sci/gfx/menubar.cpp index d6debea824..1c04486d4d 100644 --- a/engines/sci/gfx/menubar.cpp +++ b/engines/sci/gfx/menubar.cpp @@ -343,10 +343,10 @@ int Menubar::setAttribute(EngineState *s, int menu_nr, int item_nr, int attribut reg_t Menubar::getAttribute(int menu_nr, int item_nr, int attribute) const { if ((menu_nr < 0) || (item_nr < 0)) - return make_reg(0, -1); + return make_reg(0, SIGNAL_OFFSET); if ((menu_nr >= (int)_menus.size()) || (item_nr >= (int)_menus[menu_nr]._items.size())) - return make_reg(0, -1); + return make_reg(0, SIGNAL_OFFSET); const MenuItem &item = _menus[menu_nr]._items[item_nr]; @@ -368,7 +368,7 @@ reg_t Menubar::getAttribute(int menu_nr, int item_nr, int attribute) const { default: warning("Attempt to read invalid attribute from menu %d, item %d: 0x%04x", menu_nr, item_nr, attribute); - return make_reg(0, -1); + return make_reg(0, SIGNAL_OFFSET); } } |