Added a new special reg_t, SIGNAL_REG, for signaling when an error occurs (usually), or to signal success in some special occasions
svn-id: r44505
This commit is contained in:
parent
96a40e7712
commit
30084d72a5
8 changed files with 14 additions and 12 deletions
|
@ -148,7 +148,7 @@ void file_open(EngineState *s, const char *filename, int mode) {
|
||||||
|
|
||||||
if (!inFile && !outFile) { // Failed
|
if (!inFile && !outFile) { // Failed
|
||||||
debug(3, "file_open() failed");
|
debug(3, "file_open() failed");
|
||||||
s->r_acc = make_reg(0, SIGNAL_OFFSET);
|
s->r_acc = SIGNAL_REG;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,7 +755,7 @@ reg_t kFileIO(EngineState *s, int argc, reg_t *argv) {
|
||||||
|
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
warning("Attempted to open a file with an empty filename");
|
warning("Attempted to open a file with an empty filename");
|
||||||
return make_reg(0, SIGNAL_OFFSET);
|
return SIGNAL_REG;
|
||||||
}
|
}
|
||||||
file_open(s, name.c_str(), mode);
|
file_open(s, name.c_str(), mode);
|
||||||
debug(3, "K_FILEIO_OPEN(%s,0x%x)", name.c_str(), mode);
|
debug(3, "K_FILEIO_OPEN(%s,0x%x)", name.c_str(), mode);
|
||||||
|
|
|
@ -876,7 +876,7 @@ reg_t kIsItSkip(EngineState *s, int argc, reg_t *argv) {
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
warning("[GFX] Attempt to get cel parameters for invalid view %d", view);
|
warning("[GFX] Attempt to get cel parameters for invalid view %d", view);
|
||||||
return make_reg(0, SIGNAL_OFFSET);
|
return SIGNAL_REG;
|
||||||
}
|
}
|
||||||
|
|
||||||
pxm = res->loops[loop].cels[cel];
|
pxm = res->loops[loop].cels[cel];
|
||||||
|
|
|
@ -130,7 +130,7 @@ reg_t kCosDiv(EngineState *s, int argc, reg_t *argv) {
|
||||||
|
|
||||||
if ((cosval < 0.0001) && (cosval > -0.0001)) {
|
if ((cosval < 0.0001) && (cosval > -0.0001)) {
|
||||||
warning("kCosDiv: Attempted division by zero");
|
warning("kCosDiv: Attempted division by zero");
|
||||||
return make_reg(0, SIGNAL_OFFSET);
|
return SIGNAL_REG;
|
||||||
} else
|
} else
|
||||||
return make_reg(0, (int16)(value / cosval));
|
return make_reg(0, (int16)(value / cosval));
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ reg_t kSinDiv(EngineState *s, int argc, reg_t *argv) {
|
||||||
|
|
||||||
if ((sinval < 0.0001) && (sinval > -0.0001)) {
|
if ((sinval < 0.0001) && (sinval > -0.0001)) {
|
||||||
warning("kSinDiv: Attempted division by zero");
|
warning("kSinDiv: Attempted division by zero");
|
||||||
return make_reg(0, SIGNAL_OFFSET);
|
return SIGNAL_REG;
|
||||||
} else
|
} else
|
||||||
return make_reg(0, (int16)(value / sinval));
|
return make_reg(0, (int16)(value / sinval));
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ reg_t kTimesTan(EngineState *s, int argc, reg_t *argv) {
|
||||||
param -= 90;
|
param -= 90;
|
||||||
if ((param % 90) == 0) {
|
if ((param % 90) == 0) {
|
||||||
warning("kTimesTan: Attempted tan(pi/2)");
|
warning("kTimesTan: Attempted tan(pi/2)");
|
||||||
return make_reg(0, SIGNAL_OFFSET);
|
return SIGNAL_REG;
|
||||||
} else
|
} else
|
||||||
return make_reg(0, (int16) - (tan(param * PI / 180.0) * scale));
|
return make_reg(0, (int16) - (tan(param * PI / 180.0) * scale));
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ reg_t kTimesCot(EngineState *s, int argc, reg_t *argv) {
|
||||||
|
|
||||||
if ((param % 90) == 0) {
|
if ((param % 90) == 0) {
|
||||||
warning("kTimesCot: Attempted tan(pi/2)");
|
warning("kTimesCot: Attempted tan(pi/2)");
|
||||||
return make_reg(0, SIGNAL_OFFSET);
|
return SIGNAL_REG;
|
||||||
} else
|
} else
|
||||||
return make_reg(0, (int16)(tan(param * PI / 180.0) * scale));
|
return make_reg(0, (int16)(tan(param * PI / 180.0) * scale));
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ reg_t kGameIsRestarting(EngineState *s, int argc, reg_t *argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
reg_t kHaveMouse(EngineState *s, int argc, reg_t *argv) {
|
reg_t kHaveMouse(EngineState *s, int argc, reg_t *argv) {
|
||||||
return make_reg(0, SIGNAL_OFFSET);
|
return SIGNAL_REG;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum kMemoryInfoFunc {
|
enum kMemoryInfoFunc {
|
||||||
|
|
|
@ -401,7 +401,7 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) {
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
int destx, desty;
|
int destx, desty;
|
||||||
|
|
||||||
s->r_acc = make_reg(0, SIGNAL_OFFSET);
|
s->r_acc = SIGNAL_REG;
|
||||||
|
|
||||||
if (!s->segMan->isHeapObject(avoider)) {
|
if (!s->segMan->isHeapObject(avoider)) {
|
||||||
warning("DoAvoider() where avoider %04x:%04x is not an object", PRINT_REG(avoider));
|
warning("DoAvoider() where avoider %04x:%04x is not an object", PRINT_REG(avoider));
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
namespace Sci {
|
namespace Sci {
|
||||||
|
|
||||||
reg_t NULL_REG = {0, 0};
|
reg_t NULL_REG = {0, 0};
|
||||||
|
reg_t SIGNAL_REG = {0, SIGNAL_OFFSET};
|
||||||
|
|
||||||
//#define VM_DEBUG_SEND
|
//#define VM_DEBUG_SEND
|
||||||
#undef STRICT_SEND // Disallows variable sends with more than one parameter
|
#undef STRICT_SEND // Disallows variable sends with more than one parameter
|
||||||
|
|
|
@ -81,6 +81,7 @@ static inline reg_t make_reg(SegmentId segment, uint16 offset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
extern reg_t NULL_REG;
|
extern reg_t NULL_REG;
|
||||||
|
extern reg_t SIGNAL_REG;
|
||||||
|
|
||||||
} // End of namespace Sci
|
} // End of namespace Sci
|
||||||
|
|
||||||
|
|
|
@ -345,10 +345,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 {
|
reg_t Menubar::getAttribute(int menu_nr, int item_nr, int attribute) const {
|
||||||
if ((menu_nr < 0) || (item_nr < 0))
|
if ((menu_nr < 0) || (item_nr < 0))
|
||||||
return make_reg(0, SIGNAL_OFFSET);
|
return SIGNAL_REG;
|
||||||
|
|
||||||
if ((menu_nr >= (int)_menus.size()) || (item_nr >= (int)_menus[menu_nr]._items.size()))
|
if ((menu_nr >= (int)_menus.size()) || (item_nr >= (int)_menus[menu_nr]._items.size()))
|
||||||
return make_reg(0, SIGNAL_OFFSET);
|
return SIGNAL_REG;
|
||||||
|
|
||||||
const MenuItem &item = _menus[menu_nr]._items[item_nr];
|
const MenuItem &item = _menus[menu_nr]._items[item_nr];
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ reg_t Menubar::getAttribute(int menu_nr, int item_nr, int attribute) const {
|
||||||
|
|
||||||
default:
|
default:
|
||||||
warning("Attempt to read invalid attribute from menu %d, item %d: 0x%04x", menu_nr, item_nr, attribute);
|
warning("Attempt to read invalid attribute from menu %d, item %d: 0x%04x", menu_nr, item_nr, attribute);
|
||||||
return make_reg(0, SIGNAL_OFFSET);
|
return SIGNAL_REG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue