[Scummvm-cvs-logs] SF.net SVN: scummvm:[44359] scummvm/trunk/engines/sci
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Fri Sep 25 18:15:58 CEST 2009
Revision: 44359
http://scummvm.svn.sourceforge.net/scummvm/?rev=44359&view=rev
Author: thebluegr
Date: 2009-09-25 16:15:57 +0000 (Fri, 25 Sep 2009)
Log Message:
-----------
Create a define for the special "signal" offset used throughout the engine, and fixed the arbitrary 0 values from commit #44294, set when some math functions do invalid calculations
Modified Paths:
--------------
scummvm/trunk/engines/sci/console.cpp
scummvm/trunk/engines/sci/engine/kfile.cpp
scummvm/trunk/engines/sci/engine/kgraphics.cpp
scummvm/trunk/engines/sci/engine/kmath.cpp
scummvm/trunk/engines/sci/engine/kmisc.cpp
scummvm/trunk/engines/sci/engine/kmovement.cpp
scummvm/trunk/engines/sci/engine/ksound.cpp
scummvm/trunk/engines/sci/engine/vm_types.h
scummvm/trunk/engines/sci/gfx/menubar.cpp
Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp 2009-09-25 13:02:11 UTC (rev 44358)
+++ scummvm/trunk/engines/sci/console.cpp 2009-09-25 16:15:57 UTC (rev 44359)
@@ -2750,7 +2750,7 @@
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);
}
Modified: scummvm/trunk/engines/sci/engine/kfile.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kfile.cpp 2009-09-25 13:02:11 UTC (rev 44358)
+++ scummvm/trunk/engines/sci/engine/kfile.cpp 2009-09-25 16:15:57 UTC (rev 44359)
@@ -144,7 +144,7 @@
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;
}
Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp 2009-09-25 13:02:11 UTC (rev 44358)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp 2009-09-25 16:15:57 UTC (rev 44359)
@@ -873,7 +873,7 @@
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];
Modified: scummvm/trunk/engines/sci/engine/kmath.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmath.cpp 2009-09-25 13:02:11 UTC (rev 44358)
+++ scummvm/trunk/engines/sci/engine/kmath.cpp 2009-09-25 16:15:57 UTC (rev 44359)
@@ -129,8 +129,8 @@
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 @@
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 @@
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 @@
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));
}
Modified: scummvm/trunk/engines/sci/engine/kmisc.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmisc.cpp 2009-09-25 13:02:11 UTC (rev 44358)
+++ scummvm/trunk/engines/sci/engine/kmisc.cpp 2009-09-25 16:15:57 UTC (rev 44359)
@@ -60,7 +60,7 @@
}
reg_t kHaveMouse(EngineState *s, int, int argc, reg_t *argv) {
- return make_reg(0, -1);
+ return make_reg(0, SIGNAL_OFFSET);
}
enum kMemoryInfoFunc {
Modified: scummvm/trunk/engines/sci/engine/kmovement.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmovement.cpp 2009-09-25 13:02:11 UTC (rev 44358)
+++ scummvm/trunk/engines/sci/engine/kmovement.cpp 2009-09-25 16:15:57 UTC (rev 44359)
@@ -401,7 +401,7 @@
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));
Modified: scummvm/trunk/engines/sci/engine/ksound.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/ksound.cpp 2009-09-25 13:02:11 UTC (rev 44358)
+++ scummvm/trunk/engines/sci/engine/ksound.cpp 2009-09-25 16:15:57 UTC (rev 44359)
@@ -184,7 +184,7 @@
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 @@
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 @@
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 @@
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 @@
* 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 @@
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 @@
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 @@
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 @@
/* 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 @@
break;
case SI_FINISHED:
- PUT_SEL32V(obj, signal, -1);
+ PUT_SEL32V(obj, signal, SIGNAL_OFFSET);
break;
case SI_LOOP:
@@ -1106,7 +1106,7 @@
} 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;
}
Modified: scummvm/trunk/engines/sci/engine/vm_types.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm_types.h 2009-09-25 13:02:11 UTC (rev 44358)
+++ scummvm/trunk/engines/sci/engine/vm_types.h 2009-09-25 16:15:57 UTC (rev 44359)
@@ -67,9 +67,13 @@
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;
Modified: scummvm/trunk/engines/sci/gfx/menubar.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/menubar.cpp 2009-09-25 13:02:11 UTC (rev 44358)
+++ scummvm/trunk/engines/sci/gfx/menubar.cpp 2009-09-25 16:15:57 UTC (rev 44359)
@@ -343,10 +343,10 @@
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 @@
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);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list