Skip to content

Commit

Permalink
SCI: Add more support for >16-bit SCI3 offsets
Browse files Browse the repository at this point in the history
Basically just grepped for getOffset calls being assigned to
uint16s and expanded those to uint32 when they looked trivial.

While some of these changes seem superfluous, at least for the
US/English SCI3 games where potentially impacted game scripts are
not large enough to have a problem with 16-bit offsets (e.g. when
feature detecting the sound type), at least some of these changes
are necessary for correct operation of the find_callk debugger
command in SCI3 games. There should not be a reason why any of
these variables need to be kept as uint16, in any case.
  • Loading branch information
csnover committed May 21, 2017
1 parent 14a521a commit 66efb75
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions engines/sci/console.cpp
Expand Up @@ -1104,8 +1104,8 @@ bool Console::cmdVerifyScripts(int argc, const char **argv) {
debugPrintf("Error: script and heap %d together are larger than 64KB (%u bytes)\n",
itr->getNumber(), script->size() + heap->size());
} else { // SCI3
if (script && script->size() > 65535)
debugPrintf("Error: script %d is larger than 64KB (%u bytes)\n",
if (script && script->size() > 0x3FFFF)
debugPrintf("Error: script %d is larger than 256KB (%u bytes)\n",
itr->getNumber(), script->size());
}
}
Expand Down Expand Up @@ -1922,7 +1922,7 @@ bool Console::cmdSavedBits(int argc, const char **argv) {
Common::Array<reg_t> entries = hunks->listAllDeallocatable(id);

for (uint i = 0; i < entries.size(); ++i) {
uint16 offset = entries[i].getOffset();
uint32 offset = entries[i].getOffset();
const Hunk& h = hunks->at(offset);
if (strcmp(h.type, "SaveBits()") == 0) {
byte* memoryPtr = (byte *)h.mem;
Expand Down Expand Up @@ -3556,7 +3556,7 @@ void Console::printKernelCallsFound(int kernelFuncNum, bool showFoundScripts) {
// Now dissassemble each method of the script object
for (uint16 i = 0; i < obj->getMethodCount(); i++) {
reg_t fptr = obj->getFunction(i);
uint16 offset = fptr.getOffset();
uint32 offset = fptr.getOffset();
int16 opparams[4];
byte extOpcode;
byte opcode;
Expand Down
10 changes: 5 additions & 5 deletions engines/sci/engine/features.cpp
Expand Up @@ -77,7 +77,7 @@ bool GameFeatures::autoDetectSoundType() {
if (!addr.getSegment())
return false;

uint16 offset = addr.getOffset();
uint32 offset = addr.getOffset();
Script *script = _segMan->getScript(addr.getSegment());
uint16 intParam = 0xFFFF;
bool foundTarget = false;
Expand Down Expand Up @@ -224,7 +224,7 @@ bool GameFeatures::autoDetectLofsType(Common::String gameSuperClassName, int met
if (!addr.getSegment())
return false;

uint16 offset = addr.getOffset();
uint32 offset = addr.getOffset();
Script *script = _segMan->getScript(addr.getSegment());

while (true) {
Expand Down Expand Up @@ -323,7 +323,7 @@ bool GameFeatures::autoDetectGfxFunctionsType(int methodNum) {
if (!addr.getSegment())
return false;

uint16 offset = addr.getOffset();
uint32 offset = addr.getOffset();
Script *script = _segMan->getScript(addr.getSegment());

while (true) {
Expand Down Expand Up @@ -485,7 +485,7 @@ bool GameFeatures::autoDetectSci21KernelType() {
if (!addr.getSegment())
return false;

uint16 offset = addr.getOffset();
uint32 offset = addr.getOffset();
Script *script = _segMan->getScript(addr.getSegment());

while (true) {
Expand Down Expand Up @@ -620,7 +620,7 @@ bool GameFeatures::autoDetectMoveCountType() {
if (!addr.getSegment())
return false;

uint16 offset = addr.getOffset();
uint32 offset = addr.getOffset();
Script *script = _segMan->getScript(addr.getSegment());
bool foundTarget = false;

Expand Down
4 changes: 2 additions & 2 deletions engines/sci/engine/kscripts.cpp
Expand Up @@ -160,7 +160,7 @@ reg_t kClone(EngineState *s, int argc, reg_t *argv) {

debugC(kDebugLevelMemory, "Attempting to clone from %04x:%04x", PRINT_REG(parentAddr));

uint16 infoSelector = parentObj->getInfoSelector().getOffset();
uint16 infoSelector = parentObj->getInfoSelector().toUint16();
cloneObj = s->_segMan->allocateClone(&cloneAddr);

if (!cloneObj) {
Expand Down Expand Up @@ -211,7 +211,7 @@ reg_t kDisposeClone(EngineState *s, int argc, reg_t *argv) {
// At least kq4early relies on this behavior. The scripts clone "Sound", then set bit 1 manually
// and call kDisposeClone later. In that case we may not free it, otherwise we will run into issues
// later, because kIsObject would then return false and Sound object wouldn't get checked.
uint16 infoSelector = object->getInfoSelector().getOffset();
uint16 infoSelector = object->getInfoSelector().toUint16();
if ((infoSelector & 3) == kInfoFlagClone)
object->markAsFreed();

Expand Down

0 comments on commit 66efb75

Please sign in to comment.