diff options
author | Filippos Karapetis | 2009-05-15 09:04:21 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-05-15 09:04:21 +0000 |
commit | 565cfa074d25fbfc2458a65fe8fc300d78a2afa8 (patch) | |
tree | aba4ba158ef3bd890652710a9d238e95d0915e7e /engines/sci/engine | |
parent | adaa0472c5e64d0ff6cae12368ffdfa61b24d2f7 (diff) | |
download | scummvm-rg350-565cfa074d25fbfc2458a65fe8fc300d78a2afa8.tar.gz scummvm-rg350-565cfa074d25fbfc2458a65fe8fc300d78a2afa8.tar.bz2 scummvm-rg350-565cfa074d25fbfc2458a65fe8fc300d78a2afa8.zip |
Simplified SCI versions to be SCI version generations, and fixed some game entries in the process. Also, added a sanity check for invalid game entries
svn-id: r40596
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/game.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/kevent.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/kmovement.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/ksound.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 5 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 16 | ||||
-rw-r--r-- | engines/sci/engine/vm.h | 22 |
10 files changed, 39 insertions, 40 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index aaa9b38a78..720bf04176 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -97,7 +97,7 @@ int _reset_graphics_input(EngineState *s) { } else { resource = s->resmgr->findResource(kResourceTypePalette, 999, 1); if (resource) { - if (s->version < SCI_VERSION(1, 001, 000)) + if (s->version < SCI_VERSION_1_1) s->gfx_state->gfxResMan->setStaticPalette(gfxr_read_pal1(999, resource->data, resource->size)); else s->gfx_state->gfxResMan->setStaticPalette(gfxr_read_pal11(999, resource->data, resource->size)); @@ -388,12 +388,12 @@ int script_init_engine(EngineState *s, sci_version_t version) { s->kernel_opt_flags = 0; s->version = version; - if (s->version >= SCI_VERSION(1, 001, 000)) + if (s->version >= SCI_VERSION_1_1) result = create_class_table_sci11(s); else result = create_class_table_sci0(s); - s->seg_manager = new SegManager(s->version >= SCI_VERSION(1, 001, 000)); + s->seg_manager = new SegManager(s->version >= SCI_VERSION_1_1); s->gc_countdown = GC_INTERVAL - 1; if (result) { @@ -444,7 +444,7 @@ int script_init_engine(EngineState *s, sci_version_t version) { s->bp_list = NULL; // No breakpoints defined s->have_bp = 0; - if (s->flags & GF_SCI1_LOFSABSOLUTE && s->version < SCI_VERSION(1, 001, 000)) + if (s->flags & GF_SCI1_LOFSABSOLUTE && s->version < SCI_VERSION_1_1) s->seg_manager->setExportWidth(1); else s->seg_manager->setExportWidth(0); diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp index 6df40206f0..2c3eea4ac9 100644 --- a/engines/sci/engine/kevent.cpp +++ b/engines/sci/engine/kevent.cpp @@ -40,7 +40,7 @@ reg_t kGetEvent(EngineState *s, int funct_nr, int argc, reg_t *argv) { reg_t obj = argv[1]; sci_event_t e; int oldx, oldy; - int modifier_mask = SCI_VERSION_MAJOR(s->version) == 0 ? SCI_EVM_ALL : SCI_EVM_NO_FOOLOCK; + int modifier_mask = s->version <= SCI_VERSION_0 ? SCI_EVM_ALL : SCI_EVM_NO_FOOLOCK; if (s->kernel_opt_flags & KERNEL_OPT_FLAG_GOT_2NDEVENT) { // Penalty time- too many requests to this function without diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index c589e0659e..e32db3e1cb 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -309,7 +309,7 @@ reg_t kSetCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) { } case 2 : case 4 : - if (s->version >= SCI_VERSION(1, 1, 0) || (s->flags & GF_SCI1_NEWSETCURSOR)) { + if (s->version >= SCI_VERSION_1_1 || (s->flags & GF_SCI1_NEWSETCURSOR)) { GFX_ASSERT(gfxop_set_pointer_position(s->gfx_state, Common::Point(UKPV(0), UKPV(1)))); } else { if (SKPV_OR_ALT(1, 1)) { @@ -1132,7 +1132,7 @@ void _k_base_setter(EngineState *s, reg_t object) { // does not exist (earliest one was KQ4 SCI, version 0.000.274). This code is left here // for reference only #if 0 - if (s->version <= SCI_VERSION(0,000,256)) + if (s->version <= SCI_VERSION_0) --absrect.top; // Compensate for early SCI OB1 'bug' #endif @@ -1343,7 +1343,7 @@ static void _k_disable_delete_for_now(EngineState *s, reg_t obj) { * that game - bringing the save/load dialog on a par with SCI0. */ if (type == K_CONTROL_BUTTON && text && (s->_gameName == "sq4") && - s->version < SCI_VERSION(1, 001, 000) && !strcmp(text, " Delete ")) { + s->version < SCI_VERSION_1_1 && !strcmp(text, " Delete ")) { PUT_SEL32V(obj, state, (state | kControlStateDisabled) & ~kControlStateEnabled); } } diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index 7acb9c2e67..a2e244d265 100644 --- a/engines/sci/engine/kmovement.cpp +++ b/engines/sci/engine/kmovement.cpp @@ -272,7 +272,7 @@ static void bresenham_autodetect(EngineState *s) { } buf = s->seg_manager->getScript(fptr.segment, SEG_ID)->buf + fptr.offset; - handle_movecnt = (SCI_VERSION_MAJOR(s->version) == 0 || checksum_bytes(buf, 8) == 0x216) ? INCREMENT_MOVECNT : IGNORE_MOVECNT; + handle_movecnt = (s->version <= SCI_VERSION_0 || checksum_bytes(buf, 8) == 0x216) ? INCREMENT_MOVECNT : IGNORE_MOVECNT; sciprintf("b-moveCnt action based on checksum: %s\n", handle_movecnt == IGNORE_MOVECNT ? "ignore" : "increment"); } else { warning("bresenham_autodetect failed"); @@ -291,7 +291,7 @@ reg_t kDoBresen(EngineState *s, int funct_nr, int argc, reg_t *argv) { int completed = 0; int max_movcnt = GET_SEL32V(client, moveSpeed); - if (SCI_VERSION_MAJOR(s->version) > 0) + if (s->version > SCI_VERSION_0) signal &= ~_K_VIEW_SIG_FLAG_HIT_OBSTACLE; if (handle_movecnt == UNINITIALIZED) @@ -378,7 +378,7 @@ reg_t kDoBresen(EngineState *s, int funct_nr, int argc, reg_t *argv) { completed = 1; } - if (SCI_VERSION_MAJOR(s->version) > 0) + if (s->version > SCI_VERSION_0) if (completed) invoke_selector(INV_SEL(mover, moveDone, 0), 0); diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index a59432d4cf..9f279ff7d3 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -137,7 +137,7 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their song_handle_t handle; int cue; - if (s->version >= SCI_VERSION(1,000,000)) + if (s->version >= SCI_VERSION_01) return; /* SCI01 and later explicitly poll for everything */ @@ -983,9 +983,9 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) { } reg_t kDoSound(EngineState *s, int funct_nr, int argc, reg_t *argv) { - if (s->version >= SCI_VERSION(1,001,000) || s->flags & GF_SCI1_NEWDOSOUND) + if (s->version >= SCI_VERSION_1_1 || s->flags & GF_SCI1_NEWDOSOUND) return kDoSound_SCI1(s, funct_nr, argc, argv); - else if (s->version >= SCI_VERSION(1,000,000)) + else if (s->version >= SCI_VERSION_01) return kDoSound_SCI01(s, funct_nr, argc, argv); else return kDoSound_SCI0(s, funct_nr, argc, argv); diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index a4f3606519..51c3059329 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -561,7 +561,7 @@ static void load_script(EngineState *s, SegmentId seg) { assert(scr->buf); script = s->resmgr->findResource(kResourceTypeScript, scr->nr, 0); - if (s->version >= SCI_VERSION(1,001,000)) + if (s->version >= SCI_VERSION_1_1) heap = s->resmgr->findResource(kResourceTypeHeap, scr->nr, 0); memcpy(scr->buf, script->data, script->size); diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index 5727062bbc..e54efdc5d8 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -1184,7 +1184,7 @@ int prop_ofs_to_id(EngineState *s, int prop_ofs, reg_t objp) { selectors = obj->_variables.size(); - if (s->version < SCI_VERSION(1, 001, 000)) + if (s->version < SCI_VERSION_1_1) selectoroffset = ((byte *)(obj->base_obj)) + SCRIPT_SELECTOR_OFFSET + selectors * 2; else { if (!(obj->_variables[SCRIPT_INFO_SELECTOR].offset & SCRIPT_INFO_CLASS)) { @@ -2768,8 +2768,7 @@ int c_sci_version(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) { return 1; } - sciprintf("Emulating SCI version %d.%03d.%03d\n", SCI_VERSION_MAJOR(s->version), SCI_VERSION_MINOR(s->version), - SCI_VERSION_PATCHLEVEL(s->version)); + sciprintf("Emulating SCI version %s\n", versionNames[s->version]); return 0; } diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index c88023166c..848c3a044d 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -143,14 +143,14 @@ void SegManager::setScriptSize(Script &scr, EngineState *s, int script_nr) { scr.script_size = script->size; scr.heap_size = 0; // Set later - if (!script || (s->version >= SCI_VERSION(1, 001, 000) && !heap)) { + if (!script || (s->version >= SCI_VERSION_1_1 && !heap)) { sciprintf("%s: failed to load %s\n", __FUNCTION__, !script ? "script" : "heap"); return; } if (s->flags & GF_SCI0_OLD) { scr.buf_size = script->size + READ_LE_UINT16(script->data) * 2; //locals_size = READ_LE_UINT16(script->data) * 2; - } else if (s->version < SCI_VERSION(1, 001, 000)) { + } else if (s->version < SCI_VERSION_1_1) { scr.buf_size = script->size; } else { scr.buf_size = script->size + heap->size; @@ -198,7 +198,7 @@ int SegManager::initialiseScript(Script &scr, EngineState *s, int script_nr) { scr.obj_indices = new IntMapper(); - if (s->version >= SCI_VERSION(1, 001, 000)) + if (s->version >= SCI_VERSION_1_1) scr.heap_start = scr.buf + scr.script_size; else scr.heap_start = scr.buf; diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index ed5ebba44c..43022dc3f5 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -1238,7 +1238,7 @@ void run_vm(EngineState *s, int restoring) { case 0x39: // lofsa s->r_acc.segment = xs->addr.pc.segment; - if (s->version >= SCI_VERSION(1, 001, 000)) { + if (s->version >= SCI_VERSION_1_1) { s->r_acc.offset = opparams[0] + local_script->script_size; } else { if (s->flags & GF_SCI1_LOFSABSOLUTE) @@ -1475,7 +1475,7 @@ static int _obj_locate_varselector(EngineState *s, Object *obj, Selector slc) { // Determines if obj explicitly defines slc as a varselector // Returns -1 if not found - if (s->version < SCI_VERSION(1, 001, 000)) { + if (s->version < SCI_VERSION_1_1) { int varnum = obj->variable_names_nr; int selector_name_offset = varnum * 2 + SCRIPT_SELECTOR_OFFSET; int i; @@ -1528,7 +1528,7 @@ static SelectorType _lookup_selector_function(EngineState *s, int seg_id, Object if (index >= 0) { if (fptr) { - if (s->version < SCI_VERSION(1, 001, 000)) + if (s->version < SCI_VERSION_1_1) *fptr = make_reg(obj->pos.segment, READ_LE_UINT16((byte *)(obj->base_method + index + obj->methods_nr + 1))); else *fptr = make_reg(obj->pos.segment, READ_LE_UINT16((byte *)(obj->base_method + index * 2 + 2))); @@ -1651,13 +1651,13 @@ int script_instantiate_common(EngineState *s, int script_nr, Resource **script, *was_new = 1; *script = s->resmgr->findResource(kResourceTypeScript, script_nr, 0); - if (s->version >= SCI_VERSION(1, 001, 000)) + if (s->version >= SCI_VERSION_1_1) *heap = s->resmgr->findResource(kResourceTypeHeap, script_nr, 0); - if (!*script || (s->version >= SCI_VERSION(1, 001, 000) && !heap)) { + if (!*script || (s->version >= SCI_VERSION_1_1 && !heap)) { sciprintf("Script 0x%x requested but not found\n", script_nr); //script_debug_flag = script_error_flag = 1; - if (s->version >= SCI_VERSION(1, 001, 000)) { + if (s->version >= SCI_VERSION_1_1) { if (*heap) sciprintf("Inconsistency: heap resource WAS found\n"); else if (*script) @@ -1894,7 +1894,7 @@ int script_instantiate_sci11(EngineState *s, int script_nr) { } int script_instantiate(EngineState *s, int script_nr) { - if (s->version >= SCI_VERSION(1, 001, 000)) + if (s->version >= SCI_VERSION_1_1) return script_instantiate_sci11(s, script_nr); else return script_instantiate_sci0(s, script_nr); @@ -1963,7 +1963,7 @@ void script_uninstantiate(EngineState *s, int script_nr) { if (s->_classtable[i].reg.segment == reg.segment) s->_classtable[i].reg = NULL_REG; - if (s->version < SCI_VERSION(1, 001, 000)) + if (s->version < SCI_VERSION_1_1) script_uninstantiate_sci0(s, script_nr, reg.segment); else sciprintf("FIXME: Add proper script uninstantiation for SCI 1.1\n"); diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h index 61e34690a6..fc3744f551 100644 --- a/engines/sci/engine/vm.h +++ b/engines/sci/engine/vm.h @@ -174,12 +174,12 @@ public: #define SCRIPT_FUNCTAREAPTR_MAGIC 8 -8 /** Offset of the name pointer */ -#define SCRIPT_NAME_OFFSET (s->version < SCI_VERSION(1,001,000) ? 14 -8 : 16) -#define SCRIPT_NAME_SELECTOR (s->version < SCI_VERSION(1,001,000) ? 3 : 8) +#define SCRIPT_NAME_OFFSET (s->version < SCI_VERSION_1_1 ? 14 -8 : 16) +#define SCRIPT_NAME_SELECTOR (s->version < SCI_VERSION_1_1 ? 3 : 8) /** Object-relative offset of the -info- selector */ -#define SCRIPT_INFO_OFFSET (s->version < SCI_VERSION(1,001,000) ? 12 -8 : 14) -#define SCRIPT_INFO_SELECTOR (s->version < SCI_VERSION(1,001,000) ? 2 : 7) +#define SCRIPT_INFO_OFFSET (s->version < SCI_VERSION_1_1 ? 12 -8 : 14) +#define SCRIPT_INFO_SELECTOR (s->version < SCI_VERSION_1_1 ? 2 : 7) /** Flag fo the -info- selector */ #define SCRIPT_INFO_CLONE 0x0001 @@ -191,18 +191,18 @@ public: /** Magical object identifier */ #define SCRIPT_OBJECT_MAGIC_NUMBER 0x1234 /** Offset of this identifier */ -#define SCRIPT_OBJECT_MAGIC_OFFSET (s->version < SCI_VERSION(1,001,000) ? -8 : 0) +#define SCRIPT_OBJECT_MAGIC_OFFSET (s->version < SCI_VERSION_1_1 ? -8 : 0) /** Script-relative offset of the species ID */ #define SCRIPT_SPECIES_OFFSET 8 -8 -#define SCRIPT_SUPERCLASS_OFFSET (s->version < SCI_VERSION(1,001,000) ? 10 -8 : 12) +#define SCRIPT_SUPERCLASS_OFFSET (s->version < SCI_VERSION_1_1 ? 10 -8 : 12) /*---------------------------------*/ /* Script selector index variables */ /*---------------------------------*/ -#define SCRIPT_SPECIES_SELECTOR (s->version < SCI_VERSION(1,001,000) ? 0 : 5) -#define SCRIPT_SUPERCLASS_SELECTOR (s->version < SCI_VERSION(1,001,000) ? 1 : 6) +#define SCRIPT_SPECIES_SELECTOR (s->version < SCI_VERSION_1_1 ? 0 : 5) +#define SCRIPT_SUPERCLASS_SELECTOR (s->version < SCI_VERSION_1_1 ? 1 : 6) #define SCRIPT_CLASSSCRIPT_SELECTOR 4 /** Magic adjustment value for lofsa and lofss */ @@ -279,16 +279,16 @@ struct CodeBlock { }; #define VM_OBJECT_GET_VARSELECTOR(obj, i) \ - (s->version < SCI_VERSION(1,001,000) ? \ + (s->version < SCI_VERSION_1_1 ? \ READ_LE_UINT16(obj->base_obj + obj->_variables.size() * 2 + i*2) : \ *(obj->base_vars + i)) #define VM_OBJECT_READ_PROPERTY(obj, i) (obj->_variables[i]) #define VM_OBJECT_GET_FUNCSELECTOR(obj, i) \ - (s->version < SCI_VERSION(1,001,000) ? \ + (s->version < SCI_VERSION_1_1 ? \ READ_LE_UINT16((byte *) (obj->base_method + i)) : \ READ_LE_UINT16((byte *) (obj->base_method + i*2 + 1))) #define VM_OBJECT_READ_FUNCTION(obj, i) \ - (s->version < SCI_VERSION(1,001,000) ? \ + (s->version < SCI_VERSION_1_1 ? \ make_reg(obj->pos.segment, \ READ_LE_UINT16((byte *) (obj->base_method \ + obj->methods_nr + 1 \ |