aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/features.h2
-rw-r--r--engines/sci/engine/kernel.h2
-rw-r--r--engines/sci/engine/kernel_tables.h6
-rw-r--r--engines/sci/engine/kevent.cpp2
-rw-r--r--engines/sci/engine/kfile.cpp6
-rw-r--r--engines/sci/engine/kgraphics.cpp12
-rw-r--r--engines/sci/engine/kmisc.cpp6
-rw-r--r--engines/sci/engine/kmovement.cpp4
-rw-r--r--engines/sci/engine/kpathing.cpp6
-rw-r--r--engines/sci/engine/kscripts.cpp2
-rw-r--r--engines/sci/engine/kstring.cpp12
-rw-r--r--engines/sci/engine/kvideo.cpp6
-rw-r--r--engines/sci/engine/object.cpp10
-rw-r--r--engines/sci/engine/object.h4
-rw-r--r--engines/sci/engine/savegame.h2
-rw-r--r--engines/sci/engine/script.cpp2
-rw-r--r--engines/sci/engine/script_patches.cpp10
-rw-r--r--engines/sci/engine/scriptdebug.cpp22
-rw-r--r--engines/sci/engine/segment.cpp2
-rw-r--r--engines/sci/engine/selector.cpp2
-rw-r--r--engines/sci/engine/selector.h2
-rw-r--r--engines/sci/engine/state.cpp4
-rw-r--r--engines/sci/engine/static_selectors.cpp8
-rw-r--r--engines/sci/engine/vm.cpp38
-rw-r--r--engines/sci/engine/vm_types.cpp14
-rw-r--r--engines/sci/engine/workarounds.cpp4
26 files changed, 97 insertions, 93 deletions
diff --git a/engines/sci/engine/features.h b/engines/sci/engine/features.h
index 07ba626d15..4592c5be9c 100644
--- a/engines/sci/engine/features.h
+++ b/engines/sci/engine/features.h
@@ -75,7 +75,7 @@ public:
* @return Message function type, SCI_VERSION_1_LATE / SCI_VERSION_1_1
*/
SciVersion detectMessageFunctionType();
-
+
#ifdef ENABLE_SCI32
/**
* Autodetects the kernel functions used in SCI2.1
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index 68b1601580..ff3c67c84b 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -272,7 +272,7 @@ private:
// Kernel-related lists
Common::StringArray _selectorNames;
Common::StringArray _kernelNames;
-
+
const Common::String _invalid;
};
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index 31ef64d109..0c5d4e680d 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -558,16 +558,16 @@ static SciKernelMapEntry s_kernelMap[] = {
// SetWindowsOption is used to set Windows specific options, like for example the title bar visibility of
// the game window in Phantasmagoria 2. We ignore these settings completely.
{ MAP_EMPTY(SetWindowsOption), SIG_EVERYWHERE, "ii", NULL, NULL },
-
+
// Used by the Windows version of Phantasmagoria 1 to get the video speed setting. This is called after
- // kGetConfig and overrides the setting obtained by it. It is a dummy function in the DOS Version. We can
+ // kGetConfig and overrides the setting obtained by it. It is a dummy function in the DOS Version. We can
// just use GetConfig and mark this one as empty, like the DOS version does.
{ MAP_EMPTY(GetSierraProfileInt), SIG_EVERYWHERE, "(.*)", NULL, NULL },
// Unused / debug SCI2.1 unused functions, always mapped to kDummy
// The debug functions are called from the inbuilt debugger or polygon
- // editor in SCI2.1 games. Related objects are: PEditor, EditablePolygon,
+ // editor in SCI2.1 games. Related objects are: PEditor, EditablePolygon,
// aeDisplayClass and scalerCode
{ MAP_DUMMY(FindSelector), SIG_EVERYWHERE, "(.*)", NULL, NULL },
{ MAP_DUMMY(FindClass), SIG_EVERYWHERE, "(.*)", NULL, NULL },
diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp
index 2cd6b198de..df3b3efd57 100644
--- a/engines/sci/engine/kevent.cpp
+++ b/engines/sci/engine/kevent.cpp
@@ -194,7 +194,7 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
// Wait a bit here, so that the CPU isn't maxed out when the game
// is waiting for user input (e.g. when showing text boxes) - bug
// #3037874. Make sure that we're not delaying while the game is
- // benchmarking, as that will affect the final benchmarked result -
+ // benchmarking, as that will affect the final benchmarked result -
// check bugs #3058865 and #3127824
if (s->_gameIsBenchmarking) {
// Game is benchmarking, don't add a delay
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index e1e52215d2..1bd6754ca5 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -208,7 +208,7 @@ reg_t kFClose(EngineState *s, int argc, reg_t *argv) {
reg_t kFPuts(EngineState *s, int argc, reg_t *argv) {
int handle = argv[0].toUint16();
Common::String data = s->_segMan->getString(argv[1]);
-
+
FileHandle *f = getFileFromHandle(s, handle);
if (f)
f->_out->write(data.c_str(), data.size());
@@ -812,7 +812,7 @@ reg_t kFileIOReadRaw(EngineState *s, int argc, reg_t *argv) {
int bytesRead = 0;
char *buf = new char[size];
debugC(kDebugLevelFile, "kFileIO(readRaw): %d, %d", handle, size);
-
+
FileHandle *f = getFileFromHandle(s, handle);
if (f) {
bytesRead = f->_in->read(buf, size);
@@ -910,7 +910,7 @@ reg_t kFileIOSeek(EngineState *s, int argc, reg_t *argv) {
int offset = argv[1].toUint16();
int whence = argv[2].toUint16();
debugC(kDebugLevelFile, "kFileIO(seek): %d, %d, %d", handle, offset, whence);
-
+
FileHandle *f = getFileFromHandle(s, handle);
if (f)
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index 6c96266922..36de767464 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -151,7 +151,7 @@ static reg_t kSetCursorSci11(EngineState *s, int argc, reg_t *argv) {
case 2:
pos.y = argv[1].toSint16();
pos.x = argv[0].toSint16();
-
+
g_sci->_gfxCursor->kernelSetPos(pos);
break;
case 4: {
@@ -192,7 +192,7 @@ static reg_t kSetCursorSci11(EngineState *s, int argc, reg_t *argv) {
break;
case 10:
// Freddy pharkas, when using the whiskey glass to read the prescription (bug #3034973)
- g_sci->_gfxCursor->kernelSetZoomZone(argv[0].toUint16(),
+ g_sci->_gfxCursor->kernelSetZoomZone(argv[0].toUint16(),
Common::Rect(argv[1].toUint16(), argv[2].toUint16(), argv[3].toUint16(), argv[4].toUint16()),
argv[5].toUint16(), argv[6].toUint16(), argv[7].toUint16(),
argv[8].toUint16(), argv[9].toUint16());
@@ -428,7 +428,7 @@ reg_t kCanBeHere(EngineState *s, int argc, reg_t *argv) {
reg_t kCantBeHere(EngineState *s, int argc, reg_t *argv) {
reg_t curObject = argv[0];
reg_t listReference = (argc > 1) ? argv[1] : NULL_REG;
-
+
reg_t canBeHere = g_sci->_gfxCompare->kernelCanBeHere(curObject, listReference);
return canBeHere;
}
@@ -1279,7 +1279,7 @@ reg_t kCantBeHere32(EngineState *s, int argc, reg_t *argv) {
// TODO
// reg_t curObject = argv[0];
// reg_t listReference = (argc > 1) ? argv[1] : NULL_REG;
-
+
return NULL_REG;
}
@@ -1642,8 +1642,8 @@ reg_t kScrollWindow(EngineState *s, int argc, reg_t *argv) {
reg_t kSetFontRes(EngineState *s, int argc, reg_t *argv) {
// TODO: This defines the resolution that the fonts are supposed to be displayed
// in. Currently, this is only used for showing high-res fonts in GK1 Mac, but
- // should be extended to handle other font resolutions such as those
-
+ // should be extended to handle other font resolutions such as those
+
int xResolution = argv[0].toUint16();
//int yResolution = argv[1].toUint16();
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp
index daed248db1..e6837242e4 100644
--- a/engines/sci/engine/kmisc.cpp
+++ b/engines/sci/engine/kmisc.cpp
@@ -75,11 +75,11 @@ reg_t kGameIsRestarting(EngineState *s, int argc, reg_t *argv) {
}
break;
case GID_SQ4:
- // In SQ4 (floppy and CD) the sequel police appear way too quickly in
+ // In SQ4 (floppy and CD) the sequel police appear way too quickly in
// the Skate-o-rama rooms, resulting in all sorts of timer issues, like
// #3109139 (which occurs because a police officer instantly teleports
// just before Roger exits and shoots him). We throttle these scenes a
- // bit more, in order to prevent timer bugs related to the sequel police
+ // bit more, in order to prevent timer bugs related to the sequel police
if (s->currentRoomNumber() == 405 || s->currentRoomNumber() == 406 ||
s->currentRoomNumber() == 410 || s->currentRoomNumber() == 411) {
s->_throttleTrigger = true;
@@ -186,7 +186,7 @@ reg_t kSetDebug(EngineState *s, int argc, reg_t *argv) {
if (g_sci->getGameId() != GID_GK1) {
debug("Debug mode activated");
-
+
g_sci->getDebugger()->attach();
}
diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp
index 31715f19d3..14f7db47a0 100644
--- a/engines/sci/engine/kmovement.cpp
+++ b/engines/sci/engine/kmovement.cpp
@@ -239,7 +239,7 @@ reg_t kInitBresen(EngineState *s, int argc, reg_t *argv) {
client_step--;
if (!client_step)
- error("kInitBresen failed");
+ error("kInitBresen failed");
client_xStep--;
}
@@ -440,7 +440,7 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) {
invokeSelector(s, clientLooper, SELECTOR(doit), argc, argv, 2, params);
}
s->r_acc = SIGNAL_REG;
-
+
} else {
// is blocked
if (avoiderHeading == -1)
diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp
index 8904a48978..375aeaa06b 100644
--- a/engines/sci/engine/kpathing.cpp
+++ b/engines/sci/engine/kpathing.cpp
@@ -1110,7 +1110,7 @@ static Polygon *convert_polygon(EngineState *s, reg_t polygon) {
// Make sure that we have enough points
if (pointList.maxSize < size * POLY_POINT_SIZE) {
warning("convert_polygon: Not enough memory allocated for polygon points. "
- "Expected %d, got %d. Skipping polygon",
+ "Expected %d, got %d. Skipping polygon",
size * POLY_POINT_SIZE, pointList.maxSize);
return NULL;
}
@@ -1202,7 +1202,7 @@ static PathfindingState *convert_polygon_set(EngineState *s, reg_t poly_list, Co
change_polygons_opt_0(pf_s);
Common::Point *new_start = fixup_start_point(pf_s, start);
-
+
if (!new_start) {
warning("AvoidPath: Couldn't fixup start position for pathfinding");
delete pf_s;
@@ -1210,7 +1210,7 @@ static PathfindingState *convert_polygon_set(EngineState *s, reg_t poly_list, Co
}
Common::Point *new_end = fixup_end_point(pf_s, end);
-
+
if (!new_end) {
warning("AvoidPath: Couldn't fixup end position for pathfinding");
delete new_start;
diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp
index d83254b2c4..93c1fffe3c 100644
--- a/engines/sci/engine/kscripts.cpp
+++ b/engines/sci/engine/kscripts.cpp
@@ -163,7 +163,7 @@ reg_t kClone(EngineState *s, int argc, reg_t *argv) {
// extend the internal storage size.
if (infoSelector & kInfoFlagClone)
parentObj = s->_segMan->getObject(parentAddr);
-
+
*cloneObj = *parentObj;
// Mark as clone
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index c3c10bd2a2..9f10691767 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -238,14 +238,14 @@ reg_t kFormat(EngineState *s, int argc, reg_t *argv) {
/* int writelength; -- unused atm */
- if (xfer && (isdigit(xfer) || xfer == '-' || xfer == '=')) {
+ if (xfer && (isdigit(static_cast<unsigned char>(xfer)) || xfer == '-' || xfer == '=')) {
char *destp;
if (xfer == '0')
fillchar = '0';
else if (xfer == '=')
align = ALIGN_CENTER;
- else if (isdigit(xfer) || (xfer == '-'))
+ else if (isdigit(static_cast<unsigned char>(xfer)) || (xfer == '-'))
source--; // Go to start of length argument
str_leng = strtol(source, &destp, 10);
@@ -427,7 +427,7 @@ reg_t kGetFarText(EngineState *s, int argc, reg_t *argv) {
}
seeker = (char *)textres->data;
-
+
// The second parameter (counter) determines the number of the string
// inside the text resource.
while (counter--) {
@@ -715,7 +715,7 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) {
// triggers an assert when doing string2[i + index2].
for (uint16 i = 0; i < count; i++)
string1->setValue(i + index1, string2[i + index2]);
-
+
return strAddress;
}
case 7: { // Cmp
@@ -781,14 +781,14 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) {
return NULL_REG;
case 15: { // upper
Common::String string = s->_segMan->getString(argv[1]);
-
+
string.toUppercase();
s->_segMan->strcpy(argv[1], string.c_str());
return NULL_REG;
}
case 16: { // lower
Common::String string = s->_segMan->getString(argv[1]);
-
+
string.toLowercase();
s->_segMan->strcpy(argv[1], string.c_str());
return NULL_REG;
diff --git a/engines/sci/engine/kvideo.cpp b/engines/sci/engine/kvideo.cpp
index 9a60f39c85..6d810d516c 100644
--- a/engines/sci/engine/kvideo.cpp
+++ b/engines/sci/engine/kvideo.cpp
@@ -65,7 +65,7 @@ void playVideo(Video::VideoDecoder *videoDecoder, VideoState videoState) {
scaleBuffer = new byte[width * height * bytesPerPixel];
}
- uint16 x, y;
+ uint16 x, y;
// Sanity check...
if (videoState.x > 0 && videoState.y > 0 && isVMD) {
@@ -94,7 +94,7 @@ void playVideo(Video::VideoDecoder *videoDecoder, VideoState videoState) {
if (frame) {
if (scaleBuffer) {
- // TODO: Probably should do aspect ratio correction in e.g. GK1 Windows
+ // TODO: Probably should do aspect ratio correction in e.g. GK1 Windows
g_sci->_gfxScreen->scale2x((byte *)frame->pixels, scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel);
g_system->copyRectToScreen(scaleBuffer, pitch, x, y, width, height);
} else {
@@ -130,7 +130,7 @@ reg_t kShowMovie(EngineState *s, int argc, reg_t *argv) {
uint16 screenWidth = g_system->getWidth();
uint16 screenHeight = g_system->getHeight();
-
+
Video::VideoDecoder *videoDecoder = 0;
if (argv[0].segment != 0) {
diff --git a/engines/sci/engine/object.cpp b/engines/sci/engine/object.cpp
index f09f18298a..a1854a2723 100644
--- a/engines/sci/engine/object.cpp
+++ b/engines/sci/engine/object.cpp
@@ -259,13 +259,13 @@ void Object::initSelectorsSci3(const byte *buf) {
// two selectors are always reserved (because their storage
// space is used by the typeMask).
// We don't know beforehand how many methods and properties
- // there are, so we count them first.
+ // there are, so we count them first.
for (int groupNr = 0; groupNr < groups; ++groupNr) {
byte groupLocation = groupInfo[groupNr];
const byte *seeker = selectorBase + groupLocation * 32 * 2;
if (groupLocation != 0) {
- // This object actually has selectors belonging to this group
+ // This object actually has selectors belonging to this group
int typeMask = READ_SCI11ENDIAN_UINT32(seeker);
for (int bit = 2; bit < 32; ++bit) {
@@ -277,7 +277,7 @@ void Object::initSelectorsSci3(const byte *buf) {
} else {
// Undefined selector
}
-
+
}
}
}
@@ -296,7 +296,7 @@ void Object::initSelectorsSci3(const byte *buf) {
const byte *seeker = selectorBase + groupLocation * 32 * 2;
if (groupLocation != 0) {
- // This object actually has selectors belonging to this group
+ // This object actually has selectors belonging to this group
int typeMask = READ_SCI11ENDIAN_UINT32(seeker);
int groupBaseId = groupNr * 32;
@@ -323,7 +323,7 @@ void Object::initSelectorsSci3(const byte *buf) {
} else {
// Undefined selector
}
-
+
}
}
}
diff --git a/engines/sci/engine/object.h b/engines/sci/engine/object.h
index 80c8e9e83d..0ca16b48a2 100644
--- a/engines/sci/engine/object.h
+++ b/engines/sci/engine/object.h
@@ -79,7 +79,7 @@ public:
}
reg_t getSpeciesSelector() const {
- if (getSciVersion() <= SCI_VERSION_2_1)
+ if (getSciVersion() <= SCI_VERSION_2_1)
return _variables[_offset];
else // SCI3
return _speciesSelectorSci3;
@@ -93,7 +93,7 @@ public:
}
reg_t getSuperClassSelector() const {
- if (getSciVersion() <= SCI_VERSION_2_1)
+ if (getSciVersion() <= SCI_VERSION_2_1)
return _variables[_offset + 1];
else // SCI3
return _superClassPosSci3;
diff --git a/engines/sci/engine/savegame.h b/engines/sci/engine/savegame.h
index fbd77eb076..1d899b0d37 100644
--- a/engines/sci/engine/savegame.h
+++ b/engines/sci/engine/savegame.h
@@ -51,7 +51,7 @@ struct EngineState;
* 19 - exportsAreWide
* 18 - SCI32 arrays/strings
* 17 - sound
- *
+ *
*/
enum {
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index a38aa06bc4..01e1afe5ea 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -160,7 +160,7 @@ void Script::load(ResourceManager *resMan) {
_numExports = 0;
_synonyms = 0;
_numSynonyms = 0;
-
+
if (getSciVersion() <= SCI_VERSION_1_LATE) {
_exportTable = (const uint16 *)findBlockSCI0(SCI_OBJ_EXPORTS);
if (_exportTable) {
diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp
index 2d3d8f6155..a714980a35 100644
--- a/engines/sci/engine/script_patches.cpp
+++ b/engines/sci/engine/script_patches.cpp
@@ -209,7 +209,7 @@ const byte ecoquest2SignatureEcorderTutorial[] = {
const uint16 ecoquest2PatchEcorderTutorial[] = {
0x31, 0x23, // bnt [next state] (save 1 byte)
- // The parameter count below should be 7, but we're out of bytes
+ // The parameter count below should be 7, but we're out of bytes
// to patch! A workaround has been added because of this
0x78, // push1 (parameter count)
//0x39, 0x07, // pushi 07 (parameter count)
@@ -221,7 +221,7 @@ const uint16 ecoquest2PatchEcorderTutorial[] = {
0x78, // push1 (visual screen)
0x39, 0x17, // pushi 17 (color)
0x43, 0x6c, 0x0e, // call kGraph
- // The parameter count below should be 5, but we're out of bytes
+ // The parameter count below should be 5, but we're out of bytes
// to patch! A workaround has been added because of this
0x78, // push1 (parameter count)
//0x39, 0x05, // pushi 05 (parameter count)
@@ -697,7 +697,7 @@ const SciScriptSignature laurabow2Signatures[] = {
// ===========================================================================
// Mother Goose SCI1/SCI1.1
-// MG::replay somewhat calculates the savedgame-id used when saving again
+// MG::replay somewhat calculates the savedgame-id used when saving again
// this doesn't work right and we remove the code completely.
// We set the savedgame-id directly right after restoring in kRestoreGame.
const byte mothergoose256SignatureReplay[] = {
@@ -1034,7 +1034,7 @@ const uint16 sq1vgaPatchEgoShowsCard[] = {
// script, description, magic DWORD, adjust
const SciScriptSignature sq1vgaSignatures[] = {
- { 58, "Sarien armory droid zapping ego first time", 1, PATCH_MAGICDWORD( 0x72, 0x88, 0x15, 0x36 ), -70,
+ { 58, "Sarien armory droid zapping ego first time", 1, PATCH_MAGICDWORD( 0x72, 0x88, 0x15, 0x36 ), -70,
sq1vgaSignatureEgoShowsCard, sq1vgaPatchEgoShowsCard },
SCI_SIGNATUREENTRY_TERMINATOR};
@@ -1087,7 +1087,7 @@ void Script::applyPatch(const uint16 *patch, byte *scriptData, const uint32 scri
}
patch++;
patchWord = *patch;
- }
+ }
}
// will return -1 if no match was found, otherwise an offset to the start of the signature match
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index 16098ab275..3a18fbc68f 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -72,7 +72,7 @@ reg_t disassemble(EngineState *s, reg_t pos, bool printBWTag, bool printBytecode
const byte *scr;
int scr_size;
reg_t retval = make_reg(pos.segment, pos.offset + 1);
- uint16 param_value = 0xffff; // Suppress GCC warning by setting default value, chose value as invalid to getKernelName etc.
+ uint16 param_value = 0xffff; // Suppress GCC warning by setting default value, chose value as invalid to getKernelName etc.
int i = 0;
Kernel *kernel = g_sci->getKernel();
@@ -174,13 +174,15 @@ reg_t disassemble(EngineState *s, reg_t pos, bool printBWTag, bool printBytecode
break;
case Script_SRelative:
- if (opsize)
- param_value = scr[retval.offset++];
+ if (opsize) {
+ int8 offset = (int8)scr[retval.offset++];
+ debugN(" %02x [%04x]", 0xff & offset, 0xffff & (retval.offset + offset));
+ }
else {
- param_value = READ_SCI11ENDIAN_UINT16(&scr[retval.offset]);
+ int16 offset = (int16)READ_SCI11ENDIAN_UINT16(&scr[retval.offset]);
retval.offset += 2;
+ debugN(" %04x [%04x]", 0xffff & offset, 0xffff & (retval.offset + offset));
}
- debugN(opsize ? " %02x [%04x]" : " %04x [%04x]", param_value, (0xffff) & (retval.offset + param_value));
break;
case Script_End:
@@ -615,8 +617,8 @@ void debugSelectorCall(reg_t send_obj, Selector selector, int argc, StackPtr arg
Console *con = g_sci->getSciDebugger();
#ifdef VM_DEBUG_SEND
- debugN("Send to %04x:%04x (%s), selector %04x (%s):", PRINT_REG(send_obj),
- s->_segMan->getObjectName(send_obj), selector,
+ debugN("Send to %04x:%04x (%s), selector %04x (%s):", PRINT_REG(send_obj),
+ s->_segMan->getObjectName(send_obj), selector,
g_sci->getKernel()->getSelectorName(selector).c_str());
#endif // VM_DEBUG_SEND
@@ -642,18 +644,18 @@ void debugSelectorCall(reg_t send_obj, Selector selector, int argc, StackPtr arg
reg_t selectorValue = *varp.getPointer(segMan);
if (!argc && (activeBreakpointTypes & BREAK_SELECTORREAD)) {
if (g_sci->checkSelectorBreakpoint(BREAK_SELECTORREAD, send_obj, selector))
- con->DebugPrintf("Read from selector (%s:%s): %04x:%04x\n",
+ con->DebugPrintf("Read from selector (%s:%s): %04x:%04x\n",
objectName, selectorName,
PRINT_REG(selectorValue));
} else if (argc && (activeBreakpointTypes & BREAK_SELECTORWRITE)) {
if (g_sci->checkSelectorBreakpoint(BREAK_SELECTORWRITE, send_obj, selector))
- con->DebugPrintf("Write to selector (%s:%s): change %04x:%04x to %04x:%04x\n",
+ con->DebugPrintf("Write to selector (%s:%s): change %04x:%04x to %04x:%04x\n",
objectName, selectorName,
PRINT_REG(selectorValue), PRINT_REG(argp[1]));
}
if (argc > 1)
- debug(kDebugLevelScripts, "Write to selector (%s:%s): change %04x:%04x to %04x:%04x, argc == %d\n",
+ debug(kDebugLevelScripts, "Write to selector (%s:%s): change %04x:%04x to %04x:%04x, argc == %d\n",
objectName, selectorName,
PRINT_REG(selectorValue), PRINT_REG(argp[1]), argc);
}
diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp
index 5d8a81a7f1..3f11d6ff49 100644
--- a/engines/sci/engine/segment.cpp
+++ b/engines/sci/engine/segment.cpp
@@ -255,7 +255,7 @@ SegmentRef ArrayTable::dereference(reg_t pointer) {
return ret;
}
-void ArrayTable::freeAtAddress(SegManager *segMan, reg_t sub_addr) {
+void ArrayTable::freeAtAddress(SegManager *segMan, reg_t sub_addr) {
_table[sub_addr.offset].destroy();
freeEntry(sub_addr.offset);
}
diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp
index 2edbea9676..c2f857f319 100644
--- a/engines/sci/engine/selector.cpp
+++ b/engines/sci/engine/selector.cpp
@@ -212,7 +212,7 @@ void writeSelector(SegManager *segMan, reg_t object, Selector selectorId, reg_t
*address.getPointer(segMan) = value;
}
-void invokeSelector(EngineState *s, reg_t object, int selectorId,
+void invokeSelector(EngineState *s, reg_t object, int selectorId,
int k_argc, StackPtr k_argp, int argc, const reg_t *argv) {
int i;
int framesize = 2 + 1 * argc;
diff --git a/engines/sci/engine/selector.h b/engines/sci/engine/selector.h
index f13c13e00c..085dd6e832 100644
--- a/engines/sci/engine/selector.h
+++ b/engines/sci/engine/selector.h
@@ -185,7 +185,7 @@ void writeSelector(SegManager *segMan, reg_t object, Selector selectorId, reg_t
/**
* Invokes a selector from an object.
*/
-void invokeSelector(EngineState *s, reg_t object, int selectorId,
+void invokeSelector(EngineState *s, reg_t object, int selectorId,
int k_argc, StackPtr k_argp, int argc = 0, const reg_t *argv = 0);
} // End of namespace Sci
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index 3328f80de1..4ea9f72054 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -144,7 +144,7 @@ void EngineState::wait(int16 ticks) {
void EngineState::initGlobals() {
Script *script_000 = _segMan->getScript(1);
-
+
if (!script_000->_localsBlock)
error("Script 0 has no locals block");
@@ -331,7 +331,7 @@ void SciEngine::checkVocabularySwitch() {
uint16 parserLanguage = 1;
if (SELECTOR(parseLang) != -1)
parserLanguage = readSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(parseLang));
-
+
if (parserLanguage != _vocabularyLanguage) {
delete _vocabulary;
_vocabulary = new Vocabulary(_resMan, parserLanguage > 1 ? true : false);
diff --git a/engines/sci/engine/static_selectors.cpp b/engines/sci/engine/static_selectors.cpp
index 6526eff2db..cca4c47be8 100644
--- a/engines/sci/engine/static_selectors.cpp
+++ b/engines/sci/engine/static_selectors.cpp
@@ -96,7 +96,7 @@ static const char * const sci2Selectors[] = {
"center", "all", "show", "textLeft", "textTop", // 115 - 119
"textRight", "textBottom", "borderColor", "titleFore", "titleBack", // 120 - 124
"titleFont", "dimmed", "frameOut", "lastKey", "magnifier", // 125 - 129
- "magPower", "mirrored", "pitch", "roll", "yaw", // 130 - 134
+ "magPower", "mirrored", "pitch", "roll", "yaw", // 130 - 134
"left", "right", "top", "bottom", "numLines" // 135 - 139
};
#endif
@@ -265,8 +265,8 @@ void Kernel::findSpecificSelectors(Common::StringArray &selectorNames) {
if (targetClass) {
if (classReferences[i].selectorType == kSelectorMethod) {
if (targetClass->getMethodCount() < selectorOffset + 1)
- error("The %s class has less than %d methods (%d)",
- classReferences[i].className, selectorOffset + 1,
+ error("The %s class has less than %d methods (%d)",
+ classReferences[i].className, selectorOffset + 1,
targetClass->getMethodCount());
targetSelectorPos = targetClass->getFuncSelector(selectorOffset);
@@ -275,7 +275,7 @@ void Kernel::findSpecificSelectors(Common::StringArray &selectorNames) {
selectorOffset += (getSciVersion() <= SCI_VERSION_1_LATE) ? 3 : 8;
if (targetClass->getVarCount() < selectorOffset + 1)
- error("The %s class has less than %d variables (%d)",
+ error("The %s class has less than %d variables (%d)",
classReferences[i].className, selectorOffset + 1,
targetClass->getVarCount());
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 499574957e..274b0bbbc9 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -42,7 +42,7 @@ const reg_t NULL_REG = {0, 0};
const reg_t SIGNAL_REG = {0, SIGNAL_OFFSET};
const reg_t TRUE_REG = {0, 1};
//#define VM_DEBUG_SEND
-// Enable the define below to have the VM abort on cases where a conditional
+// Enable the define below to have the VM abort on cases where a conditional
// statement is followed by an unconditional jump (which will most likely lead
// to an infinite loop). Aids in detecting script bugs such as #3040722.
//#define ABORT_ON_INFINITE_LOOP
@@ -130,16 +130,16 @@ static reg_t read_var(EngineState *s, int type, int index) {
if (solution.type == WORKAROUND_NONE) {
#ifdef RELEASE_BUILD
// If we are running an official ScummVM release -> fake 0 in unknown cases
- warning("Uninitialized read for temp %d from method %s::%s (script %d, room %d, localCall %x)",
- index, originReply.objectName.c_str(), originReply.methodName.c_str(), originReply.scriptNr,
- g_sci->getEngineState()->currentRoomNumber(), originReply.localCallOffset);
+ warning("Uninitialized read for temp %d from method %s::%s (room %d, script %d, localCall %x)",
+ index, originReply.objectName.c_str(), originReply.methodName.c_str(), s->currentRoomNumber(),
+ originReply.scriptNr, originReply.localCallOffset);
s->variables[type][index] = NULL_REG;
break;
#else
- error("Uninitialized read for temp %d from method %s::%s (script %d, room %d, localCall %x)",
- index, originReply.objectName.c_str(), originReply.methodName.c_str(), originReply.scriptNr,
- g_sci->getEngineState()->currentRoomNumber(), originReply.localCallOffset);
+ error("Uninitialized read for temp %d from method %s::%s (room %d, script %d, localCall %x)",
+ index, originReply.objectName.c_str(), originReply.methodName.c_str(), s->currentRoomNumber(),
+ originReply.scriptNr, originReply.localCallOffset);
#endif
}
assert(solution.type == WORKAROUND_FAKE);
@@ -366,9 +366,9 @@ static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) {
switch (solution.type) {
case WORKAROUND_NONE:
kernel->signatureDebug(kernelCall.signature, argc, argv);
- error("[VM] k%s[%x]: signature mismatch via method %s::%s (script %d, room %d, localCall 0x%x)",
- kernelCall.name, kernelCallNr, originReply.objectName.c_str(), originReply.methodName.c_str(),
- originReply.scriptNr, s->currentRoomNumber(), originReply.localCallOffset);
+ error("[VM] k%s[%x]: signature mismatch via method %s::%s (room %d, script %d, localCall 0x%x)",
+ kernelCall.name, kernelCallNr, originReply.objectName.c_str(), originReply.methodName.c_str(),
+ s->currentRoomNumber(), originReply.scriptNr, originReply.localCallOffset);
break;
case WORKAROUND_IGNORE: // don't do kernel call, leave acc alone
return;
@@ -418,13 +418,13 @@ static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) {
int callNameLen = strlen(kernelCall.name);
if (strncmp(kernelCall.name, kernelSubCall.name, callNameLen) == 0) {
const char *subCallName = kernelSubCall.name + callNameLen;
- error("[VM] k%s(%s): signature mismatch via method %s::%s (script %d, room %d, localCall %x)",
- kernelCall.name, subCallName, originReply.objectName.c_str(), originReply.methodName.c_str(),
- originReply.scriptNr, s->currentRoomNumber(), originReply.localCallOffset);
+ error("[VM] k%s(%s): signature mismatch via method %s::%s (room %d, script %d, localCall %x)",
+ kernelCall.name, subCallName, originReply.objectName.c_str(), originReply.methodName.c_str(),
+ s->currentRoomNumber(), originReply.scriptNr, originReply.localCallOffset);
}
- error("[VM] k%s: signature mismatch via method %s::%s (script %d, room %d, localCall %x)",
- kernelSubCall.name, originReply.objectName.c_str(), originReply.methodName.c_str(),
- originReply.scriptNr, s->currentRoomNumber(), originReply.localCallOffset);
+ error("[VM] k%s: signature mismatch via method %s::%s (room %d, script %d, localCall %x)",
+ kernelSubCall.name, originReply.objectName.c_str(), originReply.methodName.c_str(),
+ s->currentRoomNumber(), originReply.scriptNr, originReply.localCallOffset);
break;
}
case WORKAROUND_IGNORE: // don't do kernel call, leave acc alone
@@ -462,7 +462,7 @@ int readPMachineInstruction(const byte *src, byte &extOpcode, int16 opparams[4])
extOpcode = src[offset++]; // Get "extended" opcode (lower bit has special meaning)
const byte opcode = extOpcode >> 1; // get the actual opcode
- memset(opparams, 0, sizeof(opparams));
+ memset(opparams, 0, 4*sizeof(int16));
for (int i = 0; g_opcode_formats[opcode][i]; ++i) {
//debugN("Opcode: 0x%x, Opnumber: 0x%x, temp: %d\n", opcode, opcode, temp);
@@ -828,10 +828,10 @@ void run_vm(EngineState *s) {
uint16 localCallOffset = s->xs->addr.pc.offset + opparams[0];
- ExecStack xstack(s->xs->objp, s->xs->objp, s->xs->sp,
+ ExecStack xstack(s->xs->objp, s->xs->objp, s->xs->sp,
(call_base->requireUint16()) + s->r_rest, call_base,
s->xs->local_segment, make_reg(s->xs->addr.pc.segment, localCallOffset),
- NULL_SELECTOR, -1, localCallOffset, s->_executionStack.size() - 1,
+ NULL_SELECTOR, -1, localCallOffset, s->_executionStack.size() - 1,
EXEC_STACK_TYPE_CALL);
s->_executionStack.push_back(xstack);
diff --git a/engines/sci/engine/vm_types.cpp b/engines/sci/engine/vm_types.cpp
index 71a28a9761..b95fd58129 100644
--- a/engines/sci/engine/vm_types.cpp
+++ b/engines/sci/engine/vm_types.cpp
@@ -32,9 +32,9 @@ reg_t reg_t::lookForWorkaround(const reg_t right) const {
SciTrackOriginReply originReply;
SciWorkaroundSolution solution = trackOriginAndFindWorkaround(0, arithmeticWorkarounds, &originReply);
if (solution.type == WORKAROUND_NONE)
- error("Invalid arithmetic operation (params: %04x:%04x and %04x:%04x) from method %s::%s (script %d, room %d, localCall %x)",
- PRINT_REG(*this), PRINT_REG(right), originReply.objectName.c_str(),
- originReply.methodName.c_str(), originReply.scriptNr, g_sci->getEngineState()->currentRoomNumber(),
+ error("Invalid arithmetic operation (params: %04x:%04x and %04x:%04x) from method %s::%s (room %d, script %d, localCall %x)",
+ PRINT_REG(*this), PRINT_REG(right), originReply.objectName.c_str(),
+ originReply.methodName.c_str(), g_sci->getEngineState()->currentRoomNumber(), originReply.scriptNr,
originReply.localCallOffset);
assert(solution.type == WORKAROUND_FAKE);
return make_reg(0, solution.value);
@@ -56,7 +56,7 @@ reg_t reg_t::operator+(const reg_t right) const {
return make_reg(segment, offset + right.toSint16());
default:
return lookForWorkaround(right);
- }
+ }
} else if (isNumber() && right.isPointer()) {
// Adding a pointer to a number, flip the order
return right + *this;
@@ -94,9 +94,9 @@ reg_t reg_t::operator/(const reg_t right) const {
reg_t reg_t::operator%(const reg_t right) const {
if (isNumber() && right.isNumber() && !right.isNull()) {
- // Support for negative numbers was added in Iceman, and perhaps in
+ // Support for negative numbers was added in Iceman, and perhaps in
// SCI0 0.000.685 and later. Theoretically, this wasn't really used
- // in SCI0, so the result is probably unpredictable. Such a case
+ // in SCI0, so the result is probably unpredictable. Such a case
// would indicate either a script bug, or a modulo on an unsigned
// integer larger than 32767. In any case, such a case should be
// investigated, instead of being silently accepted.
@@ -178,7 +178,7 @@ int reg_t::cmp(const reg_t right, bool treatAsUnsigned) const {
if (treatAsUnsigned || !isNumber())
return toUint16() - right.toUint16();
else
- return toSint16() - right.toSint16();
+ return toSint16() - right.toSint16();
} else if (pointerComparisonWithInteger(right)) {
return 1;
} else if (right.pointerComparisonWithInteger(*this)) {
diff --git a/engines/sci/engine/workarounds.cpp b/engines/sci/engine/workarounds.cpp
index 8bf90ff53d..e61da20f97 100644
--- a/engines/sci/engine/workarounds.cpp
+++ b/engines/sci/engine/workarounds.cpp
@@ -34,6 +34,7 @@ namespace Sci {
const SciWorkaroundEntry arithmeticWorkarounds[] = {
{ GID_CAMELOT, 92, 92, 0, "endingCartoon2", "changeState", 0x20d, 0, { WORKAROUND_FAKE, 0 } }, // op_lai: during the ending, sub gets called with no parameters, uses parameter 1 which is theGrail in this case - bug #3044734
{ GID_ECOQUEST2, 100, 0, 0, "Rain", "points", 0xcc6, 0, { WORKAROUND_FAKE, 0 } }, // op_or: when giving the papers to the customs officer, gets called against a pointer instead of a number - bug #3034464
+ { GID_ECOQUEST2, 100, 0, 0, "Rain", "points", 0xce0, 0, { WORKAROUND_FAKE, 0 } }, // Same as above, for the Spanish version - bug #3313962
{ GID_FANMADE, 516, 983, 0, "Wander", "setTarget", -1, 0, { WORKAROUND_FAKE, 0 } }, // op_mul: The Legend of the Lost Jewel Demo (fan made): called with object as second parameter when attacked by insects - bug #3038913
{ GID_ICEMAN, 199, 977, 0, "Grooper", "doit", -1, 0, { WORKAROUND_FAKE, 0 } }, // op_add: While dancing with the girl
{ GID_MOTHERGOOSE256, -1, 999, 0, "Event", "new", -1, 0, { WORKAROUND_FAKE, 0 } }, // op_and: constantly during the game (SCI1 version)
@@ -76,6 +77,7 @@ const SciWorkaroundEntry uninitializedReadWorkarounds[] = {
{ GID_HOYLE4, 700, 700, 1, "BridgeHand", "calcQTS", -1, 3, { WORKAROUND_FAKE, 0 } }, // sometimes when placing a bid in bridge
{ GID_HOYLE4, 300, 300, 0, "", "export 2", 0x1d4d, 0, { WORKAROUND_FAKE, 0 } }, // after passing around cards in hearts
{ GID_HOYLE4, 400, 400, 1, "GinHand", "calcRuns", -1, 4, { WORKAROUND_FAKE, 0 } }, // sometimes while playing Gin Rummy (e.g. when knocking and placing a card) - bug #3292334
+ { GID_HOYLE4, 500, 17, 1, "Character", "say", -1, 504, { WORKAROUND_FAKE, 0 } }, // sometimes while playing Cribbage (e.g. when the opponent says "Last Card") - bug #3292327
{ GID_ISLANDBRAIN, 100, 937, 0, "IconBar", "dispatchEvent", -1, 58, { WORKAROUND_FAKE, 0 } }, // when using ENTER at the startup menu - bug #3045225
{ GID_ISLANDBRAIN, 140, 140, 0, "piece", "init", -1, 3, { WORKAROUND_FAKE, 1 } }, // first puzzle right at the start, some initialization variable. bnt is done on it, and it should be non-0
{ GID_ISLANDBRAIN, 200, 268, 0, "anElement", "select", -1, 0, { WORKAROUND_FAKE, 0 } }, // elements puzzle, gets used before super TextIcon
@@ -446,7 +448,7 @@ SciWorkaroundSolution trackOriginAndFindWorkaround(int index, const SciWorkaroun
do {
workaround = workaroundList;
while (workaround->methodName) {
- bool objectNameMatches = (workaround->objectName == NULL) ||
+ bool objectNameMatches = (workaround->objectName == NULL) ||
(workaround->objectName == g_sci->getSciLanguageString(searchObjectName, K_LANG_ENGLISH));
// Special case: in the fanmade Russian translation of SQ4, all