diff options
author | Max Horn | 2009-10-04 18:38:18 +0000 |
---|---|---|
committer | Max Horn | 2009-10-04 18:38:18 +0000 |
commit | 6ad5840181557a42be4812984fb38d3f47c3e66a (patch) | |
tree | ba4ab9536c38b67d1dbb53707c76e733558cb196 /engines/sci/engine | |
parent | 0da9ad5ff59e910c91becf1ba62ee5e864d25c32 (diff) | |
download | scummvm-rg350-6ad5840181557a42be4812984fb38d3f47c3e66a.tar.gz scummvm-rg350-6ad5840181557a42be4812984fb38d3f47c3e66a.tar.bz2 scummvm-rg350-6ad5840181557a42be4812984fb38d3f47c3e66a.zip |
SCI: Rename EngineState::segMan to _segMan
svn-id: r44629
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/game.cpp | 32 | ||||
-rw-r--r-- | engines/sci/engine/gc.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/kevent.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/kfile.cpp | 74 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 60 | ||||
-rw-r--r-- | engines/sci/engine/klists.cpp | 18 | ||||
-rw-r--r-- | engines/sci/engine/kmenu.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/kmisc.cpp | 12 | ||||
-rw-r--r-- | engines/sci/engine/kmovement.cpp | 24 | ||||
-rw-r--r-- | engines/sci/engine/kpathing.cpp | 16 | ||||
-rw-r--r-- | engines/sci/engine/kscripts.cpp | 30 | ||||
-rw-r--r-- | engines/sci/engine/ksound.cpp | 14 | ||||
-rw-r--r-- | engines/sci/engine/kstring.cpp | 68 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cpp | 24 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 10 | ||||
-rw-r--r-- | engines/sci/engine/selector.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/state.cpp | 21 | ||||
-rw-r--r-- | engines/sci/engine/state.h | 6 | ||||
-rw-r--r-- | engines/sci/engine/stringfrag.cpp | 30 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 36 |
20 files changed, 251 insertions, 248 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 23806f1db0..00230f0f3c 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -318,20 +318,20 @@ int game_init_sound(EngineState *s, int sound_flags) { // Architectural stuff: Init/Unintialize engine int script_init_engine(EngineState *s) { - s->segMan = new SegManager(s->resMan); + s->_segMan = new SegManager(s->resMan); s->gc_countdown = GC_INTERVAL - 1; - SegmentId script_000_segment = s->segMan->getScriptSegment(0, SCRIPT_GET_LOCK); + SegmentId script_000_segment = s->_segMan->getScriptSegment(0, SCRIPT_GET_LOCK); if (script_000_segment <= 0) { debug(2, "Failed to instantiate script.000"); return 1; } - s->script_000 = s->segMan->getScript(script_000_segment); + s->script_000 = s->_segMan->getScript(script_000_segment); - s->sys_strings = s->segMan->allocateSysStrings(&s->sys_strings_segment); - s->string_frag_segment = s->segMan->allocateStringFrags(); + s->sys_strings = s->_segMan->allocateSysStrings(&s->sys_strings_segment); + s->string_frag_segment = s->_segMan->allocateStringFrags(); // Allocate static buffer for savegame and CWD directories SystemString *str = &s->sys_strings->_strings[SYS_STRING_SAVEDIR]; @@ -352,9 +352,9 @@ int script_init_engine(EngineState *s) { s->have_bp = 0; if (s->detectLofsType() == SCI_VERSION_1_MIDDLE) - s->segMan->setExportAreWide(true); + s->_segMan->setExportAreWide(true); else - s->segMan->setExportAreWide(false); + s->_segMan->setExportAreWide(false); debug(2, "Engine initialized"); @@ -366,8 +366,8 @@ int script_init_engine(EngineState *s) { void script_free_vm_memory(EngineState *s) { debug(2, "Freeing VM memory"); - if (s->segMan) - s->segMan->_classtable.clear(); + if (s->_segMan) + s->_segMan->_classtable.clear(); // Close all opened file handles s->_fileHandles.clear(); @@ -404,11 +404,11 @@ int game_init(EngineState *s) { // FIXME Use new VM instantiation code all over the place DataStack *stack; - stack = s->segMan->allocateStack(VM_STACK_SIZE, &s->stack_segment); + stack = s->_segMan->allocateStack(VM_STACK_SIZE, &s->stack_segment); s->stack_base = stack->_entries; s->stack_top = stack->_entries + stack->_capacity; - if (!script_instantiate(s->resMan, s->segMan, 0)) { + if (!script_instantiate(s->resMan, s->_segMan, 0)) { warning("game_init(): Could not instantiate script 0"); return 1; } @@ -437,9 +437,9 @@ int game_init(EngineState *s) { // script_dissect(0, s->_selectorNames); // The first entry in the export table of script 0 points to the game object - s->game_obj = s->segMan->lookupScriptExport(0, 0); + s->game_obj = s->_segMan->lookupScriptExport(0, 0); uint32 gameFlags = 0; // unused - s->_gameName = convertSierraGameId(s->segMan->getObjectName(s->game_obj), &gameFlags); + s->_gameName = convertSierraGameId(s->_segMan->getObjectName(s->game_obj), &gameFlags); debug(2, " \"%s\" at %04x:%04x", s->_gameName.c_str(), PRINT_REG(s->game_obj)); @@ -463,9 +463,9 @@ int game_exit(EngineState *s) { game_init_sound(s, SFX_STATE_FLAG_NOSOUND); } - s->segMan->_classtable.clear(); - delete s->segMan; - s->segMan = 0; + s->_segMan->_classtable.clear(); + delete s->_segMan; + s->_segMan = 0; debug(2, "Freeing miscellaneous data..."); diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp index 2a2b3ad19d..160842ebe4 100644 --- a/engines/sci/engine/gc.cpp +++ b/engines/sci/engine/gc.cpp @@ -71,7 +71,7 @@ void add_outgoing_refs(void *refcon, reg_t addr) { } reg_t_hash_map *find_all_used_references(EngineState *s) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; reg_t_hash_map *normal_map = NULL; WorklistManager wm; uint i; @@ -102,7 +102,7 @@ reg_t_hash_map *find_all_used_references(EngineState *s) { wm.push(es.objp); wm.push(es.sendp); if (es.type == EXEC_STACK_TYPE_VARSELECTOR) - wm.push(*(es.getVarPointer(s->segMan))); + wm.push(*(es.getVarPointer(s->_segMan))); } } @@ -174,7 +174,7 @@ void free_unless_used(void *refcon, reg_t addr) { void run_gc(EngineState *s) { uint seg_nr; deallocator_t deallocator; - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; #ifdef DEBUG_GC debugC(2, kDebugLevelGC, "[GC] Running...\n"); diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp index 728dad0df7..b8454ac70f 100644 --- a/engines/sci/engine/kevent.cpp +++ b/engines/sci/engine/kevent.cpp @@ -41,7 +41,7 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) { sci_event_t e; int oldx, oldy; int modifier_mask = getSciVersion() <= SCI_VERSION_01 ? SCI_EVM_ALL : SCI_EVM_NO_FOOLOCK; - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; // If there's a simkey pending, and the game wants a keyboard event, use the // simkey instead of a normal event @@ -153,7 +153,7 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) { reg_t kMapKeyToDir(EngineState *s, int argc, reg_t *argv) { reg_t obj = argv[0]; - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; if (GET_SEL32V(obj, type) == SCI_EVT_KEYBOARD) { // Keyboard int mover = -1; @@ -203,7 +203,7 @@ reg_t kMapKeyToDir(EngineState *s, int argc, reg_t *argv) { reg_t kGlobalToLocal(EngineState *s, int argc, reg_t *argv) { reg_t obj = argc ? argv[0] : NULL_REG; // Can this really happen? Lars - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; if (obj.segment) { int16 x = GET_SEL32V(obj, x); @@ -221,7 +221,7 @@ reg_t kGlobalToLocal(EngineState *s, int argc, reg_t *argv) { reg_t kLocalToGlobal(EngineState *s, int argc, reg_t *argv) { reg_t obj = argc ? argv[0] : NULL_REG; // Can this really happen? Lars - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; if (obj.segment) { int16 x = GET_SEL32V(obj, x); diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index 1c68428de5..a1b17d58a2 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -201,7 +201,7 @@ void file_open(EngineState *s, const char *filename, int mode) { } reg_t kFOpen(EngineState *s, int argc, reg_t *argv) { - Common::String name = s->segMan->getString(argv[0]); + Common::String name = s->_segMan->getString(argv[0]); int mode = argv[1].toUint16(); debug(3, "kFOpen(%s,0x%x)", name.c_str(), mode); @@ -254,7 +254,7 @@ void fwrite_wrapper(EngineState *s, int handle, const char *data, int length) { reg_t kFPuts(EngineState *s, int argc, reg_t *argv) { int handle = argv[0].toUint16(); - Common::String data = s->segMan->getString(argv[1]); + Common::String data = s->_segMan->getString(argv[1]); fwrite_wrapper(s, handle, data.c_str(), data.size()); return s->r_acc; @@ -317,7 +317,7 @@ reg_t kFGets(EngineState *s, int argc, reg_t *argv) { debug(3, "kFGets(%d,%d)", handle, maxsize); fgets_wrapper(s, buf, maxsize, handle); - s->segMan->memcpy(argv[0], (const byte*)buf, maxsize); + s->_segMan->memcpy(argv[0], (const byte*)buf, maxsize); return argv[0]; } @@ -328,7 +328,7 @@ reg_t kGetCWD(EngineState *s, int argc, reg_t *argv) { // We do not let the scripts see the file system, instead pretending // we are always in the same directory. // TODO/FIXME: Is "/" a good value? Maybe "" or "." or "C:\" are better? - s->segMan->strcpy(argv[0], "/"); + s->_segMan->strcpy(argv[0], "/"); debug(3, "kGetCWD() -> %s", "/"); @@ -358,20 +358,20 @@ reg_t kDeviceInfo(EngineState *s, int argc, reg_t *argv) { switch (mode) { case K_DEVICE_INFO_GET_DEVICE: { - Common::String input_str = s->segMan->getString(argv[1]); + Common::String input_str = s->_segMan->getString(argv[1]); - s->segMan->strcpy(argv[2], "/"); + s->_segMan->strcpy(argv[2], "/"); debug(3, "K_DEVICE_INFO_GET_DEVICE(%s) -> %s", input_str.c_str(), "/"); break; } case K_DEVICE_INFO_GET_CURRENT_DEVICE: - s->segMan->strcpy(argv[1], "/"); + s->_segMan->strcpy(argv[1], "/"); debug(3, "K_DEVICE_INFO_GET_CURRENT_DEVICE() -> %s", "/"); break; case K_DEVICE_INFO_PATHS_EQUAL: { - Common::String path1_s = s->segMan->getString(argv[1]); - Common::String path2_s = s->segMan->getString(argv[2]); + Common::String path1_s = s->_segMan->getString(argv[1]); + Common::String path2_s = s->_segMan->getString(argv[2]); debug(3, "K_DEVICE_INFO_PATHS_EQUAL(%s,%s)", path1_s.c_str(), path2_s.c_str()); return make_reg(0, Common::matchString(path2_s.c_str(), path1_s.c_str(), false, true)); @@ -379,7 +379,7 @@ reg_t kDeviceInfo(EngineState *s, int argc, reg_t *argv) { break; case K_DEVICE_INFO_IS_FLOPPY: { - Common::String input_str = s->segMan->getString(argv[1]); + Common::String input_str = s->_segMan->getString(argv[1]); debug(3, "K_DEVICE_INFO_IS_FLOPPY(%s)", input_str.c_str()); return NULL_REG; /* Never */ } @@ -388,16 +388,16 @@ reg_t kDeviceInfo(EngineState *s, int argc, reg_t *argv) { ** for more information on our workaround for this. */ case K_DEVICE_INFO_GET_SAVECAT_NAME: { - Common::String game_prefix = s->segMan->getString(argv[2]); - s->segMan->strcpy(argv[1], "__throwaway"); + Common::String game_prefix = s->_segMan->getString(argv[2]); + s->_segMan->strcpy(argv[1], "__throwaway"); debug(3, "K_DEVICE_INFO_GET_SAVECAT_NAME(%s) -> %s", game_prefix.c_str(), "__throwaway"); } break; case K_DEVICE_INFO_GET_SAVEFILE_NAME: { - Common::String game_prefix = s->segMan->getString(argv[2]); + Common::String game_prefix = s->_segMan->getString(argv[2]); int savegame_id = argv[3].toUint16(); - s->segMan->strcpy(argv[1], "__throwaway"); + s->_segMan->strcpy(argv[1], "__throwaway"); debug(3, "K_DEVICE_INFO_GET_SAVEFILE_NAME(%s,%d) -> %s", game_prefix.c_str(), savegame_id, "__throwaway"); delete_savegame(s, savegame_id); } @@ -423,7 +423,7 @@ reg_t kGetSaveDir(EngineState *s, int argc, reg_t *argv) { } reg_t kCheckFreeSpace(EngineState *s, int argc, reg_t *argv) { - Common::String path = s->segMan->getString(argv[0]); + Common::String path = s->_segMan->getString(argv[0]); debug(3, "kCheckFreeSpace(%s)", path.c_str()); // We simply always pretend that there is enough space. @@ -481,7 +481,7 @@ void listSavegames(Common::Array<SavegameDesc> &saves) { } reg_t kCheckSaveGame(EngineState *s, int argc, reg_t *argv) { - Common::String game_id = s->segMan->getString(argv[0]); + Common::String game_id = s->_segMan->getString(argv[0]); int savedir_nr = argv[1].toUint16(); debug(3, "kCheckSaveGame(%s, %d)", game_id.c_str(), savedir_nr); @@ -517,9 +517,9 @@ reg_t kCheckSaveGame(EngineState *s, int argc, reg_t *argv) { } reg_t kGetSaveFiles(EngineState *s, int argc, reg_t *argv) { - Common::String game_id = s->segMan->getString(argv[0]); + Common::String game_id = s->_segMan->getString(argv[0]); reg_t nametarget = argv[1]; - reg_t *nameoffsets = s->segMan->derefRegPtr(argv[2], 0); + reg_t *nameoffsets = s->_segMan->derefRegPtr(argv[2], 0); debug(3, "kGetSaveFiles(%s)", game_id.c_str()); @@ -553,7 +553,7 @@ reg_t kGetSaveFiles(EngineState *s, int argc, reg_t *argv) { Common::String name = meta.savegame_name; if (name.size() > SCI_MAX_SAVENAME_LENGTH-1) name = Common::String(meta.savegame_name.c_str(), SCI_MAX_SAVENAME_LENGTH-1); - s->segMan->strcpy(nametarget, name.c_str()); + s->_segMan->strcpy(nametarget, name.c_str()); // Increase name offset pointer accordingly nametarget.offset += SCI_MAX_SAVENAME_LENGTH; @@ -563,19 +563,19 @@ reg_t kGetSaveFiles(EngineState *s, int argc, reg_t *argv) { } //free(gfname); - s->segMan->strcpy(nametarget, ""); // Terminate list + s->_segMan->strcpy(nametarget, ""); // Terminate list return s->r_acc; } reg_t kSaveGame(EngineState *s, int argc, reg_t *argv) { - Common::String game_id = s->segMan->getString(argv[0]); + Common::String game_id = s->_segMan->getString(argv[0]); int savedir_nr = argv[1].toUint16(); int savedir_id; // Savegame ID, derived from savedir_nr and the savegame ID list - Common::String game_description = s->segMan->getString(argv[2]); + Common::String game_description = s->_segMan->getString(argv[2]); Common::String version; if (argc > 3) - version = s->segMan->getString(argv[3]); + version = s->_segMan->getString(argv[3]); debug(3, "kSaveGame(%s,%d,%s,%s)", game_id.c_str(), savedir_nr, game_description.c_str(), version.c_str()); @@ -641,7 +641,7 @@ reg_t kSaveGame(EngineState *s, int argc, reg_t *argv) { } reg_t kRestoreGame(EngineState *s, int argc, reg_t *argv) { - Common::String game_id = s->segMan->getString(argv[0]); + Common::String game_id = s->_segMan->getString(argv[0]); int savedir_nr = argv[1].toUint16(); debug(3, "kRestoreGame(%s,%d)", game_id.c_str(), savedir_nr); @@ -680,7 +680,7 @@ reg_t kRestoreGame(EngineState *s, int argc, reg_t *argv) { } reg_t kValidPath(EngineState *s, int argc, reg_t *argv) { - Common::String path = s->segMan->getString(argv[0]); + Common::String path = s->_segMan->getString(argv[0]); // FIXME: For now, we only accept the (fake) root dir "/" as a valid path. s->r_acc = make_reg(0, path == "/"); @@ -710,7 +710,7 @@ void DirSeeker::firstFile(const char *mask, reg_t buffer) { // Verify that we are given a valid buffer if (!buffer.segment) { error("DirSeeker::firstFile('%s') invoked with invalid buffer", mask); - _vm->r_acc = NULL_REG; + _state->r_acc = NULL_REG; return; } _outbuffer = buffer; @@ -727,7 +727,7 @@ void DirSeeker::firstFile(const char *mask, reg_t buffer) { void DirSeeker::nextFile() { if (_iter == _savefiles.end()) { - _vm->r_acc = NULL_REG; + _state->r_acc = NULL_REG; return; } @@ -736,10 +736,10 @@ void DirSeeker::nextFile() { Common::String string = *_iter; if (string.size() > 12) string = Common::String(string.c_str(), 12); - _vm->segMan->strcpy(_outbuffer, string.c_str()); + _state->_segMan->strcpy(_outbuffer, string.c_str()); // Return the result and advance the list iterator :) - _vm->r_acc = _outbuffer; + _state->r_acc = _outbuffer; ++_iter; } @@ -750,7 +750,7 @@ reg_t kFileIO(EngineState *s, int argc, reg_t *argv) { switch (func_nr) { case K_FILEIO_OPEN : { - Common::String name = s->segMan->getString(argv[1]); + Common::String name = s->_segMan->getString(argv[1]); int mode = argv[2].toUint16(); if (name.empty()) { @@ -775,7 +775,7 @@ reg_t kFileIO(EngineState *s, int argc, reg_t *argv) { debug(3, "K_FILEIO_READ_RAW(%d,%d)", handle, size); fread_wrapper(s, buf, size, handle); - s->segMan->memcpy(argv[2], (const byte*)buf, size); + s->_segMan->memcpy(argv[2], (const byte*)buf, size); delete[] buf; break; } @@ -783,7 +783,7 @@ reg_t kFileIO(EngineState *s, int argc, reg_t *argv) { int handle = argv[1].toUint16(); int size = argv[3].toUint16(); char *buf = new char[size]; - s->segMan->memcpy((byte*)buf, argv[2], size); + s->_segMan->memcpy((byte*)buf, argv[2], size); debug(3, "K_FILEIO_WRITE_RAW(%d,%d)", handle, size); fwrite_wrapper(s, handle, buf, size); @@ -791,7 +791,7 @@ reg_t kFileIO(EngineState *s, int argc, reg_t *argv) { break; } case K_FILEIO_UNLINK : { - Common::String name = s->segMan->getString(argv[1]); + Common::String name = s->_segMan->getString(argv[1]); debug(3, "K_FILEIO_UNLINK(%s)", name.c_str()); Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager(); @@ -808,14 +808,14 @@ reg_t kFileIO(EngineState *s, int argc, reg_t *argv) { debug(3, "K_FILEIO_READ_STRING(%d,%d)", handle, size); fgets_wrapper(s, buf, size, handle); - s->segMan->memcpy(argv[1], (const byte*)buf, size); + s->_segMan->memcpy(argv[1], (const byte*)buf, size); delete[] buf; return argv[1]; } case K_FILEIO_WRITE_STRING : { int handle = argv[1].toUint16(); int size = argv[3].toUint16(); - Common::String str = s->segMan->getString(argv[2]); + Common::String str = s->_segMan->getString(argv[2]); debug(3, "K_FILEIO_WRITE_STRING(%d,%d)", handle, size); // CHECKME: Is the size parameter used at all? @@ -835,7 +835,7 @@ reg_t kFileIO(EngineState *s, int argc, reg_t *argv) { break; } case K_FILEIO_FIND_FIRST : { - Common::String mask = s->segMan->getString(argv[1]); + Common::String mask = s->_segMan->getString(argv[1]); reg_t buf = argv[2]; int attr = argv[3].toUint16(); // We won't use this, Win32 might, though... debug(3, "K_FILEIO_FIND_FIRST(%s,0x%x)", mask.c_str(), attr); @@ -857,7 +857,7 @@ reg_t kFileIO(EngineState *s, int argc, reg_t *argv) { break; } case K_FILEIO_FILE_EXISTS : { - Common::String name = s->segMan->getString(argv[1]); + Common::String name = s->_segMan->getString(argv[1]); // Check for regular file bool exists = Common::File::exists(name); diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 74a42bc036..64896d7d92 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -186,8 +186,8 @@ int _find_priority_band(EngineState *s, int nr) { } reg_t graph_save_box(EngineState *s, rect_t area) { - reg_t handle = kalloc(s->segMan, "graph_save_box()", sizeof(gfxw_snapshot_t *)); - gfxw_snapshot_t **ptr = (gfxw_snapshot_t **)kmem(s->segMan, handle); + reg_t handle = kalloc(s->_segMan, "graph_save_box()", sizeof(gfxw_snapshot_t *)); + gfxw_snapshot_t **ptr = (gfxw_snapshot_t **)kmem(s->_segMan, handle); // FIXME: gfxw_make_snapshot returns a pointer. Now why do we store a // pointer to real memory inside the SCI heap? @@ -208,7 +208,7 @@ void graph_restore_box(EngineState *s, reg_t handle) { return; } - ptr = (gfxw_snapshot_t **)kmem(s->segMan, handle); + ptr = (gfxw_snapshot_t **)kmem(s->_segMan, handle); if (!ptr) { warning("Attempt to restore invalid handle %04x:%04x", PRINT_REG(handle)); @@ -248,7 +248,7 @@ void graph_restore_box(EngineState *s, reg_t handle) { free(*ptr); *ptr = NULL; - kfree(s->segMan, handle); + kfree(s->_segMan, handle); } PaletteEntry get_pic_color(EngineState *s, int color) { @@ -520,15 +520,15 @@ reg_t kGraph(EngineState *s, int argc, reg_t *argv) { reg_t kTextSize(EngineState *s, int argc, reg_t *argv) { int16 textWidth, textHeight; - Common::String text = s->segMan->getString(argv[1]); - reg_t *dest = s->segMan->derefRegPtr(argv[0], 4); + Common::String text = s->_segMan->getString(argv[1]); + reg_t *dest = s->_segMan->derefRegPtr(argv[0], 4); int maxwidth = (argc > 3) ? argv[3].toUint16() : 0; int font_nr = argv[2].toUint16(); Common::String sep_str; const char *sep = NULL; if ((argc > 4) && (argv[4].segment)) { - sep_str = s->segMan->getString(argv[4]); + sep_str = s->_segMan->getString(argv[4]); sep = sep_str.c_str(); } @@ -586,7 +586,7 @@ reg_t kPriCoord(EngineState *s, int argc, reg_t *argv) { } void _k_dirloop(reg_t obj, uint16 angle, EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; int view = GET_SEL32V(obj, view); int signal = GET_SEL32V(obj, signal); int loop; @@ -641,7 +641,7 @@ reg_t kDirLoop(EngineState *s, int argc, reg_t *argv) { static Common::Rect nsrect_clip(EngineState *s, int y, Common::Rect retval, int priority); static int collides_with(EngineState *s, Common::Rect area, reg_t other_obj, int use_nsrect, int view_mask, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; int other_signal = GET_SEL32V(other_obj, signal); int other_priority = GET_SEL32V(other_obj, priority); int y = (int16)GET_SEL32V(other_obj, y); @@ -681,7 +681,7 @@ static int collides_with(EngineState *s, Common::Rect area, reg_t other_obj, int } reg_t kCanBeHere(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; reg_t obj = argv[0]; reg_t cliplist_ref = (argc > 1) ? argv[1] : NULL_REG; List *cliplist = NULL; @@ -727,7 +727,7 @@ reg_t kCanBeHere(EngineState *s, int argc, reg_t *argv) { while (widget) { if (widget->_ID && (widget->signal & _K_VIEW_SIG_FLAG_STOPUPD) && ((widget->_ID != obj.segment) || (widget->_subID != obj.offset)) - && s->segMan->isObject(make_reg(widget->_ID, widget->_subID))) + && s->_segMan->isObject(make_reg(widget->_ID, widget->_subID))) if (collides_with(s, abs_zone, make_reg(widget->_ID, widget->_subID), 1, GASEOUS_VIEW_MASK_ACTIVE, argc, argv)) return NULL_REG; @@ -753,7 +753,7 @@ reg_t kCanBeHere(EngineState *s, int argc, reg_t *argv) { reg_t other_obj = node->value; debugC(2, kDebugLevelBresen, " comparing against %04x:%04x\n", PRINT_REG(other_obj)); - if (!s->segMan->isObject(other_obj)) { + if (!s->_segMan->isObject(other_obj)) { warning("CanBeHere() cliplist contains non-object %04x:%04x", PRINT_REG(other_obj)); } else if (other_obj != obj) { // Clipping against yourself is not recommended @@ -838,7 +838,7 @@ reg_t kCelWide(EngineState *s, int argc, reg_t *argv) { } reg_t kNumLoops(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; reg_t obj = argv[0]; int view = GET_SEL32V(obj, view); int loops_nr = gfxop_lookup_view_get_loops(s->gfx_state, view); @@ -854,7 +854,7 @@ reg_t kNumLoops(EngineState *s, int argc, reg_t *argv) { } reg_t kNumCels(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; reg_t obj = argv[0]; int loop = GET_SEL32V(obj, loop); int view = GET_SEL32V(obj, view); @@ -917,7 +917,7 @@ reg_t kDrawPic(EngineState *s, int argc, reg_t *argv) { } Common::Rect set_base(EngineState *s, reg_t object) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; int x, y, original_y, z, ystep, xsize, ysize; int xbase, ybase, xend, yend; int view, loop, cel; @@ -976,10 +976,10 @@ Common::Rect set_base(EngineState *s, reg_t object) { } void _k_base_setter(EngineState *s, reg_t object) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; Common::Rect absrect = set_base(s, object); - if (lookup_selector(s->segMan, object, s->_kernel->_selectorCache.brLeft, NULL, NULL) != kSelectorVariable) + if (lookup_selector(s->_segMan, object, s->_kernel->_selectorCache.brLeft, NULL, NULL) != kSelectorVariable) return; // non-fatal // Note: there was a check here for a very old version of SCI, which supposedly needed @@ -1049,7 +1049,7 @@ static Common::Rect calculate_nsrect(EngineState *s, int x, int y, int view, int } Common::Rect get_nsrect(EngineState *s, reg_t object, byte clip) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; int x, y, z; int view, loop, cel; Common::Rect retval; @@ -1191,7 +1191,7 @@ static void disableCertainButtons(SegManager *segMan, Common::String gameName, r reg_t kDrawControl(EngineState *s, int argc, reg_t *argv) { reg_t obj = argv[0]; - disableCertainButtons(s->segMan, s->_gameName, obj); + disableCertainButtons(s->_segMan, s->_gameName, obj); _k_draw_control(s, obj, false); // FULL_REDRAW(); return NULL_REG; @@ -1228,7 +1228,7 @@ void update_cursor_limits(int *display_offset, int *cursor, int max_displayed) { } reg_t kEditControl(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; reg_t obj = argv[0]; reg_t event = argv[1]; @@ -1249,7 +1249,7 @@ reg_t kEditControl(EngineState *s, int argc, reg_t *argv) { reg_t text_pos = GET_SEL32(obj, text); int display_offset = 0; - Common::String text = s->segMan->getString(text_pos); + Common::String text = s->_segMan->getString(text_pos); int textlen; #if 0 @@ -1378,7 +1378,7 @@ reg_t kEditControl(EngineState *s, int argc, reg_t *argv) { } PUT_SEL32V(obj, cursor, cursor); // Write back cursor position - s->segMan->strcpy(text_pos, text.c_str()); // Write back string + s->_segMan->strcpy(text_pos, text.c_str()); // Write back string } if (event.segment) PUT_SEL32V(event, claimed, 1); _k_draw_control(s, obj, false); @@ -1406,7 +1406,7 @@ reg_t kEditControl(EngineState *s, int argc, reg_t *argv) { } static void _k_draw_control(EngineState *s, reg_t obj, bool inverse) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; int x = (int16)GET_SEL32V(obj, nsLeft); int y = (int16)GET_SEL32V(obj, nsTop); int xl = (int16)GET_SEL32V(obj, nsRight) - x; @@ -1420,7 +1420,7 @@ static void _k_draw_control(EngineState *s, reg_t obj, bool inverse) { reg_t text_pos = GET_SEL32(obj, text); Common::String text; if (!text_pos.isNull()) - text = s->segMan->getString(text_pos); + text = s->_segMan->getString(text_pos); int view = GET_SEL32V(obj, view); int cel = sign_extend_byte(GET_SEL32V(obj, cel)); int loop = sign_extend_byte(GET_SEL32V(obj, loop)); @@ -1494,7 +1494,7 @@ static void _k_draw_control(EngineState *s, reg_t obj, bool inverse) { reg_t seeker = text_pos; // Count string entries in NULL terminated string list - while (s->segMan->strlen(seeker) > 0) { + while (s->_segMan->strlen(seeker) > 0) { ++entries_nr; seeker.offset += entry_size; } @@ -1509,7 +1509,7 @@ static void _k_draw_control(EngineState *s, reg_t obj, bool inverse) { entries_list = (const char**)malloc(sizeof(char *) * entries_nr); strings = new Common::String[entries_nr]; for (i = 0; i < entries_nr; i++) { - strings[i] = s->segMan->getString(seeker); + strings[i] = s->_segMan->getString(seeker); entries_list[i] = strings[i].c_str(); seeker.offset += entry_size; if ((seeker.offset - text_pos.offset) == lsTop) @@ -1653,7 +1653,7 @@ reg_t kNewWindow(EngineState *s, int argc, reg_t *argv) { Common::String title; if (argv[4 + argextra].segment) { - title = s->segMan->getString(argv[4 + argextra]); + title = s->_segMan->getString(argv[4 + argextra]); title = s->strSplit(title.c_str(), NULL); } @@ -1716,7 +1716,7 @@ reg_t kDisplay(EngineState *s, int argc, reg_t *argv) { if (textp.segment) { argc--; argv++; - text = s->segMan->getString(textp); + text = s->_segMan->getString(textp); } else { argc--; argc--; argv++; argv++; text = kernel_lookup_text(s, textp, index); @@ -1727,7 +1727,7 @@ reg_t kDisplay(EngineState *s, int argc, reg_t *argv) { } static reg_t kShowMovie_Windows(EngineState *s, int argc, reg_t *argv) { - Common::String filename = s->segMan->getString(argv[1]); + Common::String filename = s->_segMan->getString(argv[1]); Graphics::AVIPlayer *player = new Graphics::AVIPlayer(g_system); @@ -1806,7 +1806,7 @@ static reg_t kShowMovie_Windows(EngineState *s, int argc, reg_t *argv) { } static reg_t kShowMovie_DOS(EngineState *s, int argc, reg_t *argv) { - Common::String filename = s->segMan->getString(argv[0]); + Common::String filename = s->_segMan->getString(argv[0]); int delay = argv[1].toUint16(); // Time between frames in ticks int frameNr = 0; SeqDecoder seq; diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp index f4bcde2b21..ea33a48f4e 100644 --- a/engines/sci/engine/klists.cpp +++ b/engines/sci/engine/klists.cpp @@ -32,7 +32,7 @@ Node *lookup_node(EngineState *s, reg_t addr) { if (!addr.offset && !addr.segment) return NULL; // Non-error null - SegmentObj *mobj = GET_SEGMENT(*s->segMan, addr.segment, SEG_TYPE_NODES); + SegmentObj *mobj = GET_SEGMENT(*s->_segMan, addr.segment, SEG_TYPE_NODES); if (!mobj) { // FIXME: This occurs right at the beginning of SQ4, when walking north from the first screen. It doesn't // seem to have any apparent ill-effects, though, so it's been changed to non-fatal, for now @@ -52,7 +52,7 @@ Node *lookup_node(EngineState *s, reg_t addr) { } List *lookup_list(EngineState *s, reg_t addr) { - SegmentObj *mobj = GET_SEGMENT(*s->segMan, addr.segment, SEG_TYPE_LISTS); + SegmentObj *mobj = GET_SEGMENT(*s->_segMan, addr.segment, SEG_TYPE_LISTS); if (!mobj) { warning("Attempt to use non-list %04x:%04x as list", PRINT_REG(addr)); @@ -135,7 +135,7 @@ int sane_listp(EngineState *s, reg_t addr) { reg_t kNewList(EngineState *s, int argc, reg_t *argv) { reg_t listbase; List *l; - l = s->segMan->allocateList(&listbase); + l = s->_segMan->allocateList(&listbase); l->first = l->last = NULL_REG; debugC(2, kDebugLevelNodes, "New listbase at %04x:%04x\n", PRINT_REG(listbase)); @@ -159,19 +159,19 @@ reg_t kDisposeList(EngineState *s, int argc, reg_t *argv) { while (!n_addr.isNull()) { // Free all nodes Node *n = lookup_node(s, n_addr); - s->segMan->free_Node(n_addr); + s->_segMan->free_Node(n_addr); n_addr = n->succ; } } - s->segMan->free_list(argv[0]); + s->_segMan->free_list(argv[0]); */ return s->r_acc; } reg_t _k_new_node(EngineState *s, reg_t value, reg_t key) { reg_t nodebase; - Node *n = s->segMan->allocateNode(&nodebase); + Node *n = s->_segMan->allocateNode(&nodebase); if (!n) { error("[Kernel] Out of memory while creating a node"); @@ -401,7 +401,7 @@ reg_t kDeleteKey(EngineState *s, int argc, reg_t *argv) { if (!n->succ.isNull()) lookup_node(s, n->succ)->pred = n->pred; - //s->segMan->free_Node(node_pos); + //s->_segMan->free_Node(node_pos); return make_reg(0, 1); // Signal success } @@ -425,7 +425,7 @@ int sort_temp_cmp(const void *p1, const void *p2) { } reg_t kSort(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; reg_t source = argv[0]; reg_t dest = argv[1]; reg_t order_func = argv[2]; @@ -443,7 +443,7 @@ reg_t kSort(EngineState *s, int argc, reg_t *argv) { return s->r_acc; if (output_data.isNull()) { - list = s->segMan->allocateList(&output_data); + list = s->_segMan->allocateList(&output_data); list->first = list->last = NULL_REG; PUT_SEL32(dest, elements, output_data); } diff --git a/engines/sci/engine/kmenu.cpp b/engines/sci/engine/kmenu.cpp index d0a33f62a6..48522be339 100644 --- a/engines/sci/engine/kmenu.cpp +++ b/engines/sci/engine/kmenu.cpp @@ -34,8 +34,8 @@ namespace Sci { reg_t kAddMenu(EngineState *s, int argc, reg_t *argv) { - Common::String name = s->segMan->getString(argv[0]); - Common::String contents = s->segMan->getString(argv[1]); + Common::String name = s->_segMan->getString(argv[0]); + Common::String contents = s->_segMan->getString(argv[1]); s->_menubar->addMenu(s->gfx_state, name, contents, s->titlebar_port->_font, argv[1]); @@ -78,7 +78,7 @@ reg_t kDrawStatus(EngineState *s, int argc, reg_t *argv) { s->status_bar_background = bgcolor; if (text.segment) { - s->_statusBarText = s->segMan->getString(text); + s->_statusBarText = s->_segMan->getString(text); } sciw_set_status_bar(s, s->titlebar_port, s->_statusBarText, fgcolor, bgcolor); @@ -123,7 +123,7 @@ static int _menu_go_down(Menubar *menubar, int menu_nr, int item_nr) { reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; reg_t event = argv[0]; /*int pause_sound = (argc > 1) ? argv[1].toUint16() : 1;*/ /* FIXME: Do this eventually */ bool claimed = false; diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index e46f707aae..c075717dd6 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -167,25 +167,25 @@ enum { reg_t kMemory(EngineState *s, int argc, reg_t *argv) { switch (argv[0].toUint16()) { case K_MEMORY_ALLOCATE_CRITICAL : - if (!s->segMan->allocDynmem(argv[1].toUint16(), "kMemory() critical", &s->r_acc)) { + if (!s->_segMan->allocDynmem(argv[1].toUint16(), "kMemory() critical", &s->r_acc)) { error("Critical heap allocation failed"); } break; case K_MEMORY_ALLOCATE_NONCRITICAL : - s->segMan->allocDynmem(argv[1].toUint16(), "kMemory() non-critical", &s->r_acc); + s->_segMan->allocDynmem(argv[1].toUint16(), "kMemory() non-critical", &s->r_acc); break; case K_MEMORY_FREE : - if (s->segMan->freeDynmem(argv[1])) { + if (s->_segMan->freeDynmem(argv[1])) { error("Attempt to kMemory::free() non-dynmem pointer %04x:%04x", PRINT_REG(argv[1])); } break; case K_MEMORY_MEMCPY : { int size = argv[3].toUint16(); - s->segMan->memcpy(argv[1], argv[2], size); + s->_segMan->memcpy(argv[1], argv[2], size); break; } case K_MEMORY_PEEK : { - SegmentRef ref = s->segMan->dereference(argv[1]); + SegmentRef ref = s->_segMan->dereference(argv[1]); if (!ref.isValid() || ref.maxSize < 2) { // This occurs in KQ5CD when interacting with certain objects @@ -199,7 +199,7 @@ reg_t kMemory(EngineState *s, int argc, reg_t *argv) { break; } case K_MEMORY_POKE : { - SegmentRef ref = s->segMan->dereference(argv[1]); + SegmentRef ref = s->_segMan->dereference(argv[1]); if (!ref.isValid() || ref.maxSize < 2) { warning("Attempt to poke invalid memory at %04x:%04x", PRINT_REG(argv[1])); diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index 43cba3eb4d..dfdb02dd22 100644 --- a/engines/sci/engine/kmovement.cpp +++ b/engines/sci/engine/kmovement.cpp @@ -67,7 +67,7 @@ Still, what we compute in the end is of course not a real velocity anymore, but used in an iterative stepping algorithm */ reg_t kSetJump(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; // Input data reg_t object = argv[0]; int dx = argv[1].toSint16(); @@ -218,7 +218,7 @@ static void initialize_bresen(SegManager *segMan, int argc, reg_t *argv, reg_t m } reg_t kInitBresen(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; reg_t mover = argv[0]; reg_t client = GET_SEL32(mover, client); @@ -226,7 +226,7 @@ reg_t kInitBresen(EngineState *s, int argc, reg_t *argv) { int deltay = (int16)GET_SEL32V(mover, y) - (int16)GET_SEL32V(client, y); int step_factor = (argc < 1) ? argv[1].toUint16() : 1; - initialize_bresen(s->segMan, argc, argv, mover, step_factor, deltax, deltay); + initialize_bresen(s->_segMan, argc, argv, mover, step_factor, deltax, deltay); return s->r_acc; } @@ -255,10 +255,10 @@ static int checksum_bytes(byte *data, int size) { } static void bresenham_autodetect(EngineState *s) { - reg_t motionClass = s->segMan->findObjectByName("Motion"); + reg_t motionClass = s->_segMan->findObjectByName("Motion"); if (!motionClass.isNull()) { - Object *obj = s->segMan->getObject(motionClass); + Object *obj = s->_segMan->getObject(motionClass); reg_t fptr; byte *buf; @@ -268,13 +268,13 @@ static void bresenham_autodetect(EngineState *s) { return; } - if (lookup_selector(s->segMan, motionClass, s->_kernel->_selectorCache.doit, NULL, &fptr) != kSelectorMethod) { + if (lookup_selector(s->_segMan, motionClass, s->_kernel->_selectorCache.doit, NULL, &fptr) != kSelectorMethod) { warning("bresenham_autodetect failed"); handle_movecnt = INCREMENT_MOVECNT; // Most games do this, so best guess return; } - buf = s->segMan->getScript(fptr.segment)->_buf + fptr.offset; + buf = s->_segMan->getScript(fptr.segment)->_buf + fptr.offset; handle_movecnt = (getSciVersion() <= SCI_VERSION_01 || checksum_bytes(buf, 8) == 0x216) ? INCREMENT_MOVECNT : IGNORE_MOVECNT; printf("b-moveCnt action based on checksum: %s\n", handle_movecnt == IGNORE_MOVECNT ? "ignore" : "increment"); } else { @@ -284,7 +284,7 @@ static void bresenham_autodetect(EngineState *s) { } reg_t kDoBresen(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; reg_t mover = argv[0]; reg_t client = GET_SEL32(mover, client); @@ -393,7 +393,7 @@ extern void _k_dirloop(reg_t obj, uint16 angle, EngineState *s, int argc, reg_t extern int get_angle(int xrel, int yrel); reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; reg_t avoider = argv[0]; reg_t client, looper, mover; int angle; @@ -402,14 +402,14 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { 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)); return NULL_REG; } client = GET_SEL32(avoider, client); - if (!s->segMan->isHeapObject(client)) { + if (!s->_segMan->isHeapObject(client)) { warning("DoAvoider() where client %04x:%04x is not an object", PRINT_REG(client)); return NULL_REG; } @@ -417,7 +417,7 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { looper = GET_SEL32(client, looper); mover = GET_SEL32(client, mover); - if (!s->segMan->isHeapObject(mover)) { + if (!s->_segMan->isHeapObject(mover)) { if (mover.segment) { warning("DoAvoider() where mover %04x:%04x is not an object", PRINT_REG(mover)); } diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index f6377f46b9..ea6e5c7610 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -344,7 +344,7 @@ static void draw_point(EngineState *s, Common::Point p, int start) { } static void draw_polygon(EngineState *s, reg_t polygon) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; reg_t points = GET_SEL32(polygon, points); int size = GET_SEL32(polygon, size).toUint16(); int type = GET_SEL32(polygon, type).toUint16(); @@ -429,7 +429,7 @@ static void print_input(EngineState *s, reg_t poly_list, Common::Point start, Co node = lookup_node(s, list->first); while (node) { - print_polygon(s->segMan, node->value); + print_polygon(s->_segMan, node->value); node = lookup_node(s, node->succ); } } @@ -1212,7 +1212,7 @@ static Polygon *convert_polygon(EngineState *s, reg_t polygon) { // Parameters: (EngineState *) s: The game state // (reg_t) polygon: The SCI polygon to convert // Returns : (Polygon *) The converted polygon - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; int i; reg_t points = GET_SEL32(polygon, points); int size = GET_SEL32(polygon, size).toUint16(); @@ -1347,7 +1347,7 @@ static PathfindingState *convert_polygon_set(EngineState *s, reg_t poly_list, Co // (int) opt: Optimization level (0, 1 or 2) // Returns : (PathfindingState *) On success a newly allocated pathfinding state, // NULL otherwise - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; Polygon *polygon; int err; int count = 0; @@ -1363,7 +1363,7 @@ static PathfindingState *convert_polygon_set(EngineState *s, reg_t poly_list, Co // Workaround for game bugs that put a polygon in the list more than once while (dup != node) { - if (polygons_equal(s->segMan, node->value, dup->value)) { + if (polygons_equal(s->_segMan, node->value, dup->value)) { warning("[avoidpath] Ignoring duplicate polygon"); break; } @@ -1574,7 +1574,7 @@ static reg_t output_path(PathfindingState *p, EngineState *s) { if (unreachable) { // If pathfinding failed we only return the path up to vertex_start - oref = s->segMan->allocDynmem(POLY_POINT_SIZE * 3, AVOIDPATH_DYNMEM_STRING, &output); + oref = s->_segMan->allocDynmem(POLY_POINT_SIZE * 3, AVOIDPATH_DYNMEM_STRING, &output); if (p->_prependPoint) POLY_SET_POINT(oref, 0, *p->_prependPoint); @@ -1594,7 +1594,7 @@ static reg_t output_path(PathfindingState *p, EngineState *s) { } // Allocate memory for path, plus 3 extra for appended point, prepended point and sentinel - oref = s->segMan->allocDynmem(POLY_POINT_SIZE * (path_len + 3), AVOIDPATH_DYNMEM_STRING, &output); + oref = s->_segMan->allocDynmem(POLY_POINT_SIZE * (path_len + 3), AVOIDPATH_DYNMEM_STRING, &output); int offset = 0; @@ -1686,7 +1686,7 @@ reg_t kAvoidPath(EngineState *s, int argc, reg_t *argv) { printf("[avoidpath] Error: pathfinding failed for following input:\n"); print_input(s, poly_list, start, end, opt); printf("[avoidpath] Returning direct path from start point to end point\n"); - oref = s->segMan->allocDynmem(POLY_POINT_SIZE * 3, + oref = s->_segMan->allocDynmem(POLY_POINT_SIZE * 3, AVOIDPATH_DYNMEM_STRING, &output); POLY_SET_POINT(oref, 0, start); diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index 7f84fa207d..e409e1a010 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -39,7 +39,7 @@ reg_t kLoad(EngineState *s, int argc, reg_t *argv) { // Request to dynamically allocate hunk memory for later use if (restype == kResourceTypeMemory) - return kalloc(s->segMan, "kLoad()", resnr); + return kalloc(s->_segMan, "kLoad()", resnr); return make_reg(0, ((restype << 11) | resnr)); // Return the resource identifier as handle } @@ -77,7 +77,7 @@ reg_t kUnLoad(EngineState *s, int argc, reg_t *argv) { reg_t resnr = argv[1]; if (restype == kResourceTypeMemory) - kfree(s->segMan, resnr); + kfree(s->_segMan, resnr); return s->r_acc; } @@ -104,7 +104,7 @@ reg_t kResCheck(EngineState *s, int argc, reg_t *argv) { reg_t kClone(EngineState *s, int argc, reg_t *argv) { reg_t parent_addr = argv[0]; - Object *parent_obj = s->segMan->getObject(parent_addr); + Object *parent_obj = s->_segMan->getObject(parent_addr); reg_t clone_addr; Clone *clone_obj; // same as Object* @@ -115,7 +115,7 @@ reg_t kClone(EngineState *s, int argc, reg_t *argv) { debugC(2, kDebugLevelMemory, "Attempting to clone from %04x:%04x\n", PRINT_REG(parent_addr)); - clone_obj = s->segMan->allocateClone(&clone_addr); + clone_obj = s->_segMan->allocateClone(&clone_addr); if (!clone_obj) { error("Cloning %04x:%04x failed-- internal error", PRINT_REG(parent_addr)); @@ -130,8 +130,8 @@ reg_t kClone(EngineState *s, int argc, reg_t *argv) { clone_obj->setSpeciesSelector(clone_obj->_pos); if (parent_obj->isClass()) clone_obj->setSuperClassSelector(parent_obj->_pos); - s->segMan->getScript(parent_obj->_pos.segment)->incrementLockers(); - s->segMan->getScript(clone_obj->_pos.segment)->incrementLockers(); + s->_segMan->getScript(parent_obj->_pos.segment)->incrementLockers(); + s->_segMan->getScript(clone_obj->_pos.segment)->incrementLockers(); return clone_addr; } @@ -140,7 +140,7 @@ extern void _k_view_list_mark_free(EngineState *s, reg_t off); reg_t kDisposeClone(EngineState *s, int argc, reg_t *argv) { reg_t victim_addr = argv[0]; - Clone *victim_obj = s->segMan->getObject(victim_addr); + Clone *victim_obj = s->_segMan->getObject(victim_addr); if (!victim_obj) { error("Attempt to dispose non-class/object at %04x:%04x", @@ -182,13 +182,13 @@ reg_t kScriptID(EngineState *s, int argc, reg_t *argv) { if (argv[0].segment) return argv[0]; - SegmentId scriptSeg = s->segMan->getScriptSegment(script, SCRIPT_GET_LOAD); + SegmentId scriptSeg = s->_segMan->getScriptSegment(script, SCRIPT_GET_LOAD); Script *scr; if (!scriptSeg) return NULL_REG; - scr = s->segMan->getScript(scriptSeg); + scr = s->_segMan->getScript(scriptSeg); if (!scr->_numExports) { // FIXME: Is this fatal? This occurs in SQ4CD @@ -201,7 +201,7 @@ reg_t kScriptID(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } - return make_reg(scriptSeg, s->segMan->validateExportFunc(index, scriptSeg)); + return make_reg(scriptSeg, s->_segMan->validateExportFunc(index, scriptSeg)); } reg_t kDisposeScript(EngineState *s, int argc, reg_t *argv) { @@ -211,14 +211,14 @@ reg_t kDisposeScript(EngineState *s, int argc, reg_t *argv) { if (argv[0].segment) return s->r_acc; - int id = s->segMan->getScriptSegment(script); - Script *scr = s->segMan->getScriptIfLoaded(id); + int id = s->_segMan->getScriptSegment(script); + Script *scr = s->_segMan->getScriptIfLoaded(id); if (scr) { if (s->_executionStack.back().addr.pc.segment != id) scr->setLockers(1); } - script_uninstantiate(s->segMan, script); + script_uninstantiate(s->_segMan, script); s->_executionStackPosChanged = true; if (argc != 2) { @@ -234,14 +234,14 @@ reg_t kIsObject(EngineState *s, int argc, reg_t *argv) { if (argv[0].offset == SIGNAL_OFFSET) // Treated specially return NULL_REG; else - return make_reg(0, s->segMan->isHeapObject(argv[0])); + return make_reg(0, s->_segMan->isHeapObject(argv[0])); } reg_t kRespondsTo(EngineState *s, int argc, reg_t *argv) { reg_t obj = argv[0]; int selector = argv[1].toUint16(); - return make_reg(0, s->segMan->isHeapObject(obj) && lookup_selector(s->segMan, obj, selector, NULL, NULL) != kSelectorNone); + return make_reg(0, s->_segMan->isHeapObject(obj) && lookup_selector(s->_segMan, obj, selector, NULL, NULL) != kSelectorNone); } } // End of namespace Sci diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index 5d73fd4fb3..feb5bd523f 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -130,7 +130,7 @@ enum AudioSyncCommands { static void script_set_priority(EngineState *s, reg_t obj, int priority) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; int song_nr = GET_SEL32V(obj, number); Resource *song = s->resMan->findResource(ResourceId(kResourceTypeSound, song_nr), 0); int flags = GET_SEL32V(obj, flags); @@ -165,7 +165,7 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their int result; SongHandle handle; int cue; - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; if (getSciVersion() > SCI_VERSION_01) return; @@ -173,7 +173,7 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their while ((result = s->_sound.sfx_poll(&handle, &cue))) { reg_t obj = DEFROBNICATE_HANDLE(handle); - if (!s->segMan->isObject(obj)) { + if (!s->_segMan->isObject(obj)) { warning("Non-object %04x:%04x received sound signal (%d/%d)", PRINT_REG(obj), result, cue); return; } @@ -215,7 +215,7 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their static reg_t kDoSoundSci0(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; reg_t obj = (argc > 1) ? argv[1] : NULL_REG; uint16 command = argv[0].toUint16(); SongHandle handle = FROBNICATE_HANDLE(obj); @@ -395,7 +395,7 @@ static reg_t kDoSoundSci0(EngineState *s, int argc, reg_t *argv) { static reg_t kDoSoundSci1Early(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; uint16 command = argv[0].toUint16(); reg_t obj = (argc > 1) ? argv[1] : NULL_REG; SongHandle handle = FROBNICATE_HANDLE(obj); @@ -687,7 +687,7 @@ static reg_t kDoSoundSci1Early(EngineState *s, int argc, reg_t *argv) { } static reg_t kDoSoundSci1Late(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; uint16 command = argv[0].toUint16(); reg_t obj = (argc > 1) ? argv[1] : NULL_REG; SongHandle handle = FROBNICATE_HANDLE(obj); @@ -1077,7 +1077,7 @@ reg_t kDoAudio(EngineState *s, int argc, reg_t *argv) { } reg_t kDoSync(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; switch (argv[0].toUint16()) { case kSciAudioSyncStart: { ResourceId id; diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index f02f5f5636..8e75675a66 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -44,7 +44,7 @@ Common::String kernel_lookup_text(EngineState *s, reg_t address, int index) { Resource *textres; if (address.segment) - return s->segMan->getString(address); + return s->_segMan->getString(address); else { int textlen; int _index = index; @@ -79,7 +79,7 @@ Common::String kernel_lookup_text(EngineState *s, reg_t address, int index) { reg_t kSaid(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; reg_t heap_said_block = argv[0]; byte *said_block; int new_lastmatch; @@ -92,7 +92,7 @@ reg_t kSaid(EngineState *s, int argc, reg_t *argv) { if (!heap_said_block.segment) return NULL_REG; - said_block = (byte *)s->segMan->derefBulkPtr(heap_said_block, 0); + said_block = (byte *)s->_segMan->derefBulkPtr(heap_said_block, 0); if (!said_block) { warning("Said on non-string, pointer %04x:%04x", PRINT_REG(heap_said_block)); @@ -128,7 +128,7 @@ reg_t kSaid(EngineState *s, int argc, reg_t *argv) { reg_t kSetSynonyms(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; reg_t object = argv[0]; List *list; Node *node; @@ -145,13 +145,13 @@ reg_t kSetSynonyms(EngineState *s, int argc, reg_t *argv) { int seg; script = GET_SEL32V(objpos, number); - seg = s->segMan->getScriptSegment(script); + seg = s->_segMan->getScriptSegment(script); if (seg > 0) - numSynonyms = s->segMan->getScript(seg)->getSynonymsNr(); + numSynonyms = s->_segMan->getScript(seg)->getSynonymsNr(); if (numSynonyms) { - byte *synonyms = s->segMan->getScript(seg)->getSynonyms(); + byte *synonyms = s->_segMan->getScript(seg)->getSynonyms(); if (synonyms) { debugC(2, kDebugLevelParser, "Setting %d synonyms for script.%d\n", @@ -185,9 +185,9 @@ reg_t kSetSynonyms(EngineState *s, int argc, reg_t *argv) { reg_t kParse(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->segMan; + SegManager *segMan = s->_segMan; reg_t stringpos = argv[0]; - Common::String string = s->segMan->getString(stringpos); + Common::String string = s->_segMan->getString(stringpos); char *error; ResultWordList words; reg_t event = argv[1]; @@ -235,7 +235,7 @@ reg_t kParse(EngineState *s, int argc, reg_t *argv) { s->r_acc = make_reg(0, 0); PUT_SEL32V(event, claimed, 1); if (error) { - s->segMan->strcpy(s->parser_base, error); + s->_segMan->strcpy(s->parser_base, error); debugC(2, kDebugLevelParser, "Word unknown: %s\n", error); /* Issue warning: */ @@ -251,23 +251,23 @@ reg_t kParse(EngineState *s, int argc, reg_t *argv) { reg_t kStrEnd(EngineState *s, int argc, reg_t *argv) { reg_t address = argv[0]; - address.offset += s->segMan->strlen(address); + address.offset += s->_segMan->strlen(address); return address; } reg_t kStrCat(EngineState *s, int argc, reg_t *argv) { - Common::String s1 = s->segMan->getString(argv[0]); - Common::String s2 = s->segMan->getString(argv[1]); + Common::String s1 = s->_segMan->getString(argv[0]); + Common::String s2 = s->_segMan->getString(argv[1]); s1 += s2; - s->segMan->strcpy(argv[0], s1.c_str()); + s->_segMan->strcpy(argv[0], s1.c_str()); return argv[0]; } reg_t kStrCmp(EngineState *s, int argc, reg_t *argv) { - Common::String s1 = s->segMan->getString(argv[0]); - Common::String s2 = s->segMan->getString(argv[1]); + Common::String s1 = s->_segMan->getString(argv[0]); + Common::String s2 = s->_segMan->getString(argv[1]); if (argc > 2) return make_reg(0, strncmp(s1.c_str(), s2.c_str(), argv[2].toUint16())); @@ -281,18 +281,18 @@ reg_t kStrCpy(EngineState *s, int argc, reg_t *argv) { int length = argv[2].toSint16(); if (length >= 0) - s->segMan->strncpy(argv[0], argv[1], length); + s->_segMan->strncpy(argv[0], argv[1], length); else - s->segMan->memcpy(argv[0], argv[1], -length); + s->_segMan->memcpy(argv[0], argv[1], -length); } else - s->segMan->strcpy(argv[0], argv[1]); + s->_segMan->strcpy(argv[0], argv[1]); return argv[0]; } reg_t kStrAt(EngineState *s, int argc, reg_t *argv) { - SegmentRef dest_r = s->segMan->dereference(argv[0]); + SegmentRef dest_r = s->_segMan->dereference(argv[0]); if (!dest_r.raw) { warning("Attempt to StrAt at invalid pointer %04x:%04x", PRINT_REG(argv[0])); return NULL_REG; @@ -332,7 +332,7 @@ reg_t kStrAt(EngineState *s, int argc, reg_t *argv) { reg_t kReadNumber(EngineState *s, int argc, reg_t *argv) { - Common::String source_str = s->segMan->getString(argv[0]); + Common::String source_str = s->_segMan->getString(argv[0]); const char *source = source_str.c_str(); while (isspace((unsigned char)*source)) @@ -569,14 +569,14 @@ reg_t kFormat(EngineState *s, int argc, reg_t *argv) { *target = 0; /* Terminate string */ - s->segMan->strcpy(dest, targetbuf); + s->_segMan->strcpy(dest, targetbuf); return dest; /* Return target addr */ } reg_t kStrLen(EngineState *s, int argc, reg_t *argv) { - return make_reg(0, s->segMan->strlen(argv[0])); + return make_reg(0, s->_segMan->strlen(argv[0])); } @@ -601,7 +601,7 @@ reg_t kGetFarText(EngineState *s, int argc, reg_t *argv) { ** resource. */ - s->segMan->strcpy(argv[2], seeker); /* Copy the string and get return value */ + s->_segMan->strcpy(argv[2], seeker); /* Copy the string and get return value */ return argv[2]; } @@ -675,15 +675,15 @@ reg_t kMessage(EngineState *s, int argc, reg_t *argv) { if (!bufferReg.isNull()) { int len = str.size() + 1; - SegmentRef buffer_r = s->segMan->dereference(bufferReg); + SegmentRef buffer_r = s->_segMan->dereference(bufferReg); if (buffer_r.maxSize < len) { warning("Message: buffer %04x:%04x invalid or too small to hold the following text of %i bytes: '%s'", PRINT_REG(bufferReg), len, str.c_str()); // Set buffer to empty string if possible if (buffer_r.maxSize > 0) - s->segMan->strcpy(bufferReg, ""); + s->_segMan->strcpy(bufferReg, ""); } else - s->segMan->strcpy(bufferReg, str.c_str()); + s->_segMan->strcpy(bufferReg, str.c_str()); s->_msgState.gotoNext(); } @@ -720,12 +720,12 @@ reg_t kMessage(EngineState *s, int argc, reg_t *argv) { case K_MESSAGE_LASTMESSAGE: { MessageTuple msg = s->_msgState.getLastTuple(); int module = s->_msgState.getLastModule(); - byte *buffer = s->segMan->derefBulkPtr(argv[1], 10); + byte *buffer = s->_segMan->derefBulkPtr(argv[1], 10); if (buffer) { // FIXME: Is this correct? I.e., do we really write into a "raw" segment // here? Or maybe we want to write 4 reg_t instead? - assert(s->segMan->dereference(argv[1]).isRaw); + assert(s->_segMan->dereference(argv[1]).isRaw); WRITE_LE_UINT16(buffer, module); WRITE_LE_UINT16(buffer + 2, msg.noun); @@ -746,28 +746,28 @@ reg_t kMessage(EngineState *s, int argc, reg_t *argv) { } reg_t kSetQuitStr(EngineState *s, int argc, reg_t *argv) { - Common::String quitStr = s->segMan->getString(argv[0]); + Common::String quitStr = s->_segMan->getString(argv[0]); debug("Setting quit string to '%s'", quitStr.c_str()); return s->r_acc; } reg_t kStrSplit(EngineState *s, int argc, reg_t *argv) { - Common::String format = s->segMan->getString(argv[1]); + Common::String format = s->_segMan->getString(argv[1]); Common::String sep_str; const char *sep = NULL; if (!argv[2].isNull()) { - sep_str = s->segMan->getString(argv[2]); + sep_str = s->_segMan->getString(argv[2]); sep = sep_str.c_str(); } Common::String str = s->strSplit(format.c_str(), sep); // Make sure target buffer is large enough - SegmentRef buf_r = s->segMan->dereference(argv[0]); + SegmentRef buf_r = s->_segMan->dereference(argv[0]); if (!buf_r.isValid() || buf_r.maxSize < (int)str.size() + 1) { warning("StrSplit: buffer %04x:%04x invalid or too small to hold the following text of %i bytes: '%s'", PRINT_REG(argv[0]), str.size() + 1, str.c_str()); return NULL_REG; } - s->segMan->strcpy(argv[0], str.c_str()); + s->_segMan->strcpy(argv[0], str.c_str()); return argv[0]; } diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index dd2daaeb75..04fc2eef46 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -296,9 +296,9 @@ void EngineState::saveLoadWithSerializer(Common::Serializer &s) { s.syncAsSint32LE(status_bar_foreground); s.syncAsSint32LE(status_bar_background); - sync_SegManagerPtr(s, resMan, segMan); + sync_SegManagerPtr(s, resMan, _segMan); - syncArray<Class>(s, segMan->_classtable); + syncArray<Class>(s, _segMan->_classtable); sync_sfx_state_t(s, _sound); } @@ -552,8 +552,8 @@ static byte *find_unique_script_block(EngineState *s, byte *buf, int type) { // FIXME: This should probably be turned into an EngineState method static void reconstruct_stack(EngineState *retval) { - SegmentId stack_seg = retval->segMan->findSegmentByType(SEG_TYPE_STACK); - DataStack *stack = (DataStack *)(retval->segMan->_heap[stack_seg]); + SegmentId stack_seg = retval->_segMan->findSegmentByType(SEG_TYPE_STACK); + DataStack *stack = (DataStack *)(retval->_segMan->_heap[stack_seg]); retval->stack_segment = stack_seg; retval->stack_base = stack->_entries; @@ -591,13 +591,13 @@ static void reconstruct_scripts(EngineState *s, SegManager *self) { // FIXME: Unify this code with script_instantiate_* load_script(s, scr); - scr->_localsBlock = (scr->_localsSegment == 0) ? NULL : (LocalVariables *)(s->segMan->_heap[scr->_localsSegment]); + scr->_localsBlock = (scr->_localsSegment == 0) ? NULL : (LocalVariables *)(s->_segMan->_heap[scr->_localsSegment]); if (getSciVersion() >= SCI_VERSION_1_1) { scr->_exportTable = 0; scr->_synonyms = 0; if (READ_LE_UINT16(scr->_buf + 6) > 0) { scr->setExportTableOffset(6); - s->segMan->scriptRelocateExportsSci11(i); + s->_segMan->scriptRelocateExportsSci11(i); } } else { scr->_exportTable = (uint16 *) find_unique_script_block(s, scr->_buf, SCI_OBJ_EXPORTS); @@ -643,7 +643,7 @@ static void reconstruct_scripts(EngineState *s, SegManager *self) { int funct_area = READ_LE_UINT16( data + SCRIPT_FUNCTAREAPTR_OFFSET ); Object *base_obj; - base_obj = s->segMan->getObject(it->_value.getSpeciesSelector()); + base_obj = s->_segMan->getObject(it->_value.getSpeciesSelector()); if (!base_obj) { warning("Object without a base class: Script %d, index %d (reg address %04x:%04x", @@ -763,13 +763,13 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { _reset_graphics_input(retval); reconstruct_stack(retval); - reconstruct_scripts(retval, retval->segMan); - retval->segMan->reconstructClones(); + reconstruct_scripts(retval, retval->_segMan); + retval->_segMan->reconstructClones(); retval->game_obj = s->game_obj; - retval->script_000 = retval->segMan->getScript(retval->segMan->getScriptSegment(0, SCRIPT_GET_DONT_LOAD)); + retval->script_000 = retval->_segMan->getScript(retval->_segMan->getScriptSegment(0, SCRIPT_GET_DONT_LOAD)); retval->gc_countdown = GC_INTERVAL - 1; - retval->sys_strings_segment = retval->segMan->findSegmentByType(SEG_TYPE_SYS_STRINGS); - retval->sys_strings = (SystemStrings *)GET_SEGMENT(*retval->segMan, retval->sys_strings_segment, SEG_TYPE_SYS_STRINGS); + retval->sys_strings_segment = retval->_segMan->findSegmentByType(SEG_TYPE_SYS_STRINGS); + retval->sys_strings = (SystemStrings *)GET_SEGMENT(*retval->_segMan, retval->sys_strings_segment, SEG_TYPE_SYS_STRINGS); // Time state: retval->last_wait_time = g_system->getMillis(); diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index 7ddec73f19..e6b5c56899 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -98,7 +98,7 @@ int propertyOffsetToId(SegManager *segMan, int prop_ofs, reg_t objp) { // Disassembles one command from the heap, returns address of next command or 0 if a ret was encountered. reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecode) { - SegmentObj *mobj = GET_SEGMENT(*s->segMan, pos.segment, SEG_TYPE_SCRIPT); + SegmentObj *mobj = GET_SEGMENT(*s->_segMan, pos.segment, SEG_TYPE_SCRIPT); Script *script_entity = NULL; byte *scr; int scr_size; @@ -256,7 +256,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod if ((opcode == op_pTos) || (opcode == op_sTop) || (opcode == op_pToa) || (opcode == op_aTop) || (opcode == op_dpToa) || (opcode == op_ipToa) || (opcode == op_dpTos) || (opcode == op_ipTos)) { int prop_ofs = scr[pos.offset + 1]; - int prop_id = propertyOffsetToId(s->segMan, prop_ofs, scriptState.xs->objp); + int prop_id = propertyOffsetToId(s->_segMan, prop_ofs, scriptState.xs->objp); printf(" (%s)", selector_name(s, prop_id)); } @@ -300,14 +300,14 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod selector = sb[- stackframe].offset; - name = s->segMan->getObjectName(called_obj_addr); + name = s->_segMan->getObjectName(called_obj_addr); if (!name) name = "<invalid>"; printf(" %s::%s[", name, (selector > kernel->getSelectorNamesSize()) ? "<invalid>" : selector_name(s, selector)); - switch (lookup_selector(s->segMan, called_obj_addr, selector, 0, &fun_ref)) { + switch (lookup_selector(s->_segMan, called_obj_addr, selector, 0, &fun_ref)) { case kSelectorMethod: printf("FUNCT"); argc += restmod; @@ -359,7 +359,7 @@ void script_debug(EngineState *s, bool bp) { #endif if (g_debugState.seeking && !bp) { // Are we looking for something special? - SegmentObj *mobj = GET_SEGMENT(*s->segMan, scriptState.xs->addr.pc.segment, SEG_TYPE_SCRIPT); + SegmentObj *mobj = GET_SEGMENT(*s->_segMan, scriptState.xs->addr.pc.segment, SEG_TYPE_SCRIPT); if (mobj) { Script *scr = (Script *)mobj; diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp index e6d40f8155..1d44691af5 100644 --- a/engines/sci/engine/selector.cpp +++ b/engines/sci/engine/selector.cpp @@ -65,7 +65,7 @@ int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvoc stackframe[0] = make_reg(0, selector_id); // The selector we want to call stackframe[1] = make_reg(0, argc); // Argument count - slc_type = lookup_selector(s->segMan, object, selector_id, NULL, &address); + slc_type = lookup_selector(s->_segMan, object, selector_id, NULL, &address); if (slc_type == kSelectorNone) { warning("Selector '%s' of object at %04x:%04x could not be invoked (%s L%d)", diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index d9671239dc..4e7d0944e1 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -103,7 +103,7 @@ EngineState::EngineState(ResourceManager *res, Kernel *kernel, Vocabulary *voc, game_obj = NULL_REG; - segMan = 0; + _segMan = 0; gc_countdown = 0; successor = 0; @@ -176,6 +176,7 @@ kLanguage EngineState::getLanguage() { kLanguage lang = K_LANG_ENGLISH; if (_kernel->_selectorCache.printLang != -1) { + SegManager *segMan = _segMan; lang = (kLanguage)GET_SEL32V(this->game_obj, printLang); if ((getSciVersion() == SCI_VERSION_1_1) || (lang == K_LANG_NONE)) { @@ -222,8 +223,10 @@ Common::String EngineState::strSplit(const char *str, const char *sep) { kLanguage lang = getLanguage(); kLanguage subLang = K_LANG_NONE; - if (_kernel->_selectorCache.subtitleLang != -1) + if (_kernel->_selectorCache.subtitleLang != -1) { + SegManager *segMan = _segMan; subLang = (kLanguage)GET_SEL32V(this->game_obj, subtitleLang); + } Common::String retval = getLanguageString(str, lang); @@ -238,13 +241,13 @@ Common::String EngineState::strSplit(const char *str, const char *sep) { int EngineState::methodChecksum(reg_t objAddress, Selector sel, int offset, uint size) const { reg_t fptr; - Object *obj = segMan->getObject(objAddress); - SelectorType selType = lookup_selector(segMan, objAddress, sel, NULL, &fptr); + Object *obj = _segMan->getObject(objAddress); + SelectorType selType = lookup_selector(_segMan, objAddress, sel, NULL, &fptr); if (!obj || (selType != kSelectorMethod)) return -1; - Script *script = segMan->getScript(fptr.segment); + Script *script = _segMan->getScript(fptr.segment); if (!script->_buf || (fptr.offset + offset < 0)) return -1; @@ -265,7 +268,7 @@ int EngineState::methodChecksum(reg_t objAddress, Selector sel, int offset, uint SciVersion EngineState::detectDoSoundType() { if (_doSoundType == SCI_VERSION_AUTODETECT) { - reg_t soundClass = segMan->findObjectByName("Sound"); + reg_t soundClass = _segMan->findObjectByName("Sound"); if (!soundClass.isNull()) { int sum = methodChecksum(soundClass, _kernel->_selectorCache.play, -6, 6); @@ -337,10 +340,10 @@ SciVersion EngineState::detectLofsType() { } Object *obj = NULL; - reg_t gameClass = segMan->findObjectByName("Game"); + reg_t gameClass = _segMan->findObjectByName("Game"); if (!gameClass.isNull()) - obj = segMan->getObject(gameClass); + obj = _segMan->getObject(gameClass); bool couldBeAbs = true; bool couldBeRel = true; @@ -350,7 +353,7 @@ SciVersion EngineState::detectLofsType() { for (int m = 0; m < obj->methods_nr; m++) { reg_t fptr = obj->getFunction(m); - Script *script = segMan->getScript(fptr.segment); + Script *script = _segMan->getScript(fptr.segment); if ((script == NULL) || (script->_buf == NULL)) continue; diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h index a8dbce53f1..4bc64b0a94 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -59,13 +59,13 @@ struct GfxList; class DirSeeker { protected: - EngineState *_vm; + EngineState *_state; reg_t _outbuffer; Common::StringList _savefiles; Common::StringList::const_iterator _iter; public: - DirSeeker(EngineState *s) : _vm(s) { + DirSeeker(EngineState *s) : _state(s) { _outbuffer = NULL_REG; _iter = _savefiles.begin(); } @@ -298,7 +298,7 @@ public: reg_t game_obj; /**< Pointer to the game object */ - SegManager *segMan; + SegManager *_segMan; int gc_countdown; /**< Number of kernel calls until next gc */ MessageState _msgState; diff --git a/engines/sci/engine/stringfrag.cpp b/engines/sci/engine/stringfrag.cpp index 94ae3d4c9d..ae17ae7763 100644 --- a/engines/sci/engine/stringfrag.cpp +++ b/engines/sci/engine/stringfrag.cpp @@ -103,7 +103,7 @@ static int internal_is_valid_stringfrag(EngineState *s, reg_t *buffer) { } int is_valid_stringfrag(EngineState *s, reg_t pos) { - reg_t *buffer = s->segMan->derefRegPtr(pos, 1); + reg_t *buffer = s->_segMan->derefRegPtr(pos, 1); return internal_is_valid_stringfrag(s, buffer); } @@ -138,7 +138,7 @@ static int internal_stringfrag_length(EngineState *s, reg_t *buffer) { } int stringfrag_length(EngineState *s, reg_t pos) { - reg_t *buffer = s->segMan->derefRegPtr(pos, 1); + reg_t *buffer = s->_segMan->derefRegPtr(pos, 1); return internal_stringfrag_length(s, buffer); } @@ -169,7 +169,7 @@ static void internal_stringfrag_to_ascii(EngineState *s, reg_t *buffer) { } void stringfrag_to_ascii(EngineState *s, reg_t pos) { - reg_t *buffer = s->segMan->derefRegPtr(pos, 1); + reg_t *buffer = s->_segMan->derefRegPtr(pos, 1); internal_stringfrag_to_ascii(s, buffer); } @@ -191,7 +191,7 @@ static void internal_ascii_to_stringfrag(EngineState *s, reg_t *buffer) { } void ascii_to_stringfrag(EngineState *s, reg_t pos) { - reg_t *buffer = s->segMan->derefRegPtr(pos, 1); + reg_t *buffer = s->_segMan->derefRegPtr(pos, 1); internal_ascii_to_stringfrag(s, buffer); } @@ -214,7 +214,7 @@ static void internal_stringfrag_append_char(EngineState *s, reg_t *buffer, unsig } void stringfrag_append_char(EngineState *s, reg_t pos, unsigned char c) { - reg_t *buffer = s->segMan->derefRegPtr(pos, 1); + reg_t *buffer = s->_segMan->derefRegPtr(pos, 1); internal_stringfrag_append_char(s, buffer, c); } @@ -311,7 +311,7 @@ static void internal_stringfrag_insert_char(EngineState *s, reg_t *buffer, int p } void stringfrag_insert_char(EngineState *s, reg_t pos, int p, unsigned char c) { - reg_t *buffer = s->segMan->derefRegPtr(pos, 1); + reg_t *buffer = s->_segMan->derefRegPtr(pos, 1); internal_stringfrag_insert_char(s, buffer, p, c); } @@ -343,7 +343,7 @@ static void internal_stringfrag_delete_char(EngineState *s, reg_t *buffer, int p } void stringfrag_delete_char(EngineState *s, reg_t pos, int p) { - reg_t *buffer = s->segMan->derefRegPtr(pos, 1); + reg_t *buffer = s->_segMan->derefRegPtr(pos, 1); internal_stringfrag_delete_char(s, buffer, p); } @@ -360,8 +360,8 @@ void internal_stringfrag_strcpy(EngineState *s, reg_t *dest, reg_t *src) { } void stringfrag_strcpy(EngineState *s, reg_t dest, reg_t src) { - reg_t *destbuf = s->segMan->derefRegPtr(dest, 1); - reg_t *srcbuf = s->segMan->derefRegPtr(src, 1); + reg_t *destbuf = s->_segMan->derefRegPtr(dest, 1); + reg_t *srcbuf = s->_segMan->derefRegPtr(src, 1); internal_stringfrag_strcpy(s, destbuf, srcbuf); } @@ -388,8 +388,8 @@ void internal_stringfrag_strncpy(EngineState *s, reg_t *dest, reg_t *src, int le } void stringfrag_strncpy(EngineState *s, reg_t dest, reg_t src, int len) { - reg_t *destbuf = s->segMan->derefRegPtr(dest, 1); - reg_t *srcbuf = s->segMan->derefRegPtr(src, 1); + reg_t *destbuf = s->_segMan->derefRegPtr(dest, 1); + reg_t *srcbuf = s->_segMan->derefRegPtr(src, 1); internal_stringfrag_strncpy(s, destbuf, srcbuf, len); } @@ -416,8 +416,8 @@ int internal_stringfrag_strcmp(EngineState *s, reg_t *s1, reg_t *s2) { } void stringfrag_strcmp(EngineState *s, reg_t s1, reg_t s2) { - reg_t *s1buf = s->segMan->derefRegPtr(s1, 1); - reg_t *s2buf = s->segMan->derefRegPtr(s2, 1); + reg_t *s1buf = s->_segMan->derefRegPtr(s1, 1); + reg_t *s2buf = s->_segMan->derefRegPtr(s2, 1); internal_stringfrag_strcmp(s, s1buf, s2buf); } @@ -449,8 +449,8 @@ int internal_stringfrag_strncmp(EngineState *s, reg_t *s1, reg_t *s2, int len) { } void stringfrag_strncmp(EngineState *s, reg_t s1, reg_t s2, int len) { - reg_t *s1buf = s->segMan->derefRegPtr(s1, 1); - reg_t *s2buf = s->segMan->derefRegPtr(s2, 1); + reg_t *s1buf = s->_segMan->derefRegPtr(s1, 1); + reg_t *s2buf = s->_segMan->derefRegPtr(s2, 1); internal_stringfrag_strncmp(s, s1buf, s2buf, len); } diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 2413998690..8f1ffff224 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -185,13 +185,13 @@ static void validate_write_var(reg_t *r, reg_t *stack_base, int type, int max, i #define GET_OP_SIGNED_FLEX() ((opcode & 1)? GET_OP_SIGNED_BYTE() : GET_OP_SIGNED_WORD()) ExecStack *execute_method(EngineState *s, uint16 script, uint16 pubfunct, StackPtr sp, reg_t calling_obj, uint16 argc, StackPtr argp) { - int seg = s->segMan->getScriptSegment(script); - Script *scr = s->segMan->getScriptIfLoaded(seg); + int seg = s->_segMan->getScriptSegment(script); + Script *scr = s->_segMan->getScriptIfLoaded(seg); if (!scr || scr->isMarkedAsDeleted()) // Script not present yet? - seg = script_instantiate(s->resMan, s->segMan, script); + seg = script_instantiate(s->resMan, s->_segMan, script); - const int temp = s->segMan->validateExportFunc(pubfunct, seg); + const int temp = s->_segMan->validateExportFunc(pubfunct, seg); if (!temp) { error("Request for invalid exported function 0x%x of script 0x%x", pubfunct, script); return NULL; @@ -225,7 +225,7 @@ static void _exec_varselectors(EngineState *s) { // Executes all varselector read/write ops on the TOS while (!s->_executionStack.empty() && s->_executionStack.back().type == EXEC_STACK_TYPE_VARSELECTOR) { ExecStack &xs = s->_executionStack.back(); - reg_t *var = xs.getVarPointer(s->segMan); + reg_t *var = xs.getVarPointer(s->_segMan); // varselector access? if (xs.argc) { // write? *var = xs.variables_argp[1]; @@ -280,7 +280,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt Breakpoint *bp; char method_name [256]; - sprintf(method_name, "%s::%s", s->segMan->getObjectName(send_obj), s->_kernel->getSelectorName(selector).c_str()); + sprintf(method_name, "%s::%s", s->_segMan->getObjectName(send_obj), s->_kernel->getSelectorName(selector).c_str()); bp = s->bp_list; while (bp) { @@ -305,7 +305,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt #endif // VM_DEBUG_SEND ObjVarRef varp; - switch (lookup_selector(s->segMan, send_obj, selector, &varp, &funcp)) { + switch (lookup_selector(s->_segMan, send_obj, selector, &varp, &funcp)) { case kSelectorNone: error("Send to invalid selector 0x%x of object at %04x:%04x", 0xffff & selector, PRINT_REG(send_obj)); @@ -329,7 +329,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt } if (print_send_action && argc > 0) { - reg_t oldReg = *varp.getPointer(s->segMan); + reg_t oldReg = *varp.getPointer(s->_segMan); reg_t newReg = argp[1]; printf("[write to selector: change %04x:%04x to %04x:%04x]\n", PRINT_REG(oldReg), PRINT_REG(newReg)); print_send_action = 0; @@ -454,7 +454,7 @@ ExecStack *add_exec_stack_entry(EngineState *s, reg_t pc, StackPtr sp, reg_t obj #endif static reg_t pointer_add(EngineState *s, reg_t base, int offset) { - SegmentObj *mobj = s->segMan->getSegmentObj(base.segment); + SegmentObj *mobj = s->_segMan->getSegmentObj(base.segment); if (!mobj) { error("[VM] Error: Attempt to add %d to invalid pointer %04x:%04x", offset, PRINT_REG(base)); @@ -504,8 +504,8 @@ void run_vm(EngineState *s, int restoring) { // Current execution data: scriptState.xs = &(s->_executionStack.back()); ExecStack *xs_new = NULL; - Object *obj = s->segMan->getObject(scriptState.xs->objp); - Script *local_script = s->segMan->getScriptIfLoaded(scriptState.xs->local_segment); + Object *obj = s->_segMan->getObject(scriptState.xs->objp); + Script *local_script = s->_segMan->getScriptIfLoaded(scriptState.xs->local_segment); int old_execution_stack_base = s->execution_stack_base; // Used to detect the stack bottom, for "physical" returns const byte *code_buf = NULL; // (Avoid spurious warning) @@ -551,7 +551,7 @@ void run_vm(EngineState *s, int restoring) { scriptState.xs = &(s->_executionStack.back()); s->_executionStackPosChanged = false; - scr = s->segMan->getScriptIfLoaded(scriptState.xs->addr.pc.segment); + scr = s->_segMan->getScriptIfLoaded(scriptState.xs->addr.pc.segment); if (!scr) { // No script? Implicit return via fake instruction buffer warning("Running on non-existant script in segment %x", scriptState.xs->addr.pc.segment); @@ -564,12 +564,12 @@ void run_vm(EngineState *s, int restoring) { scr = NULL; obj = NULL; } else { - obj = s->segMan->getObject(scriptState.xs->objp); + obj = s->_segMan->getObject(scriptState.xs->objp); code_buf = scr->_buf; #ifndef DISABLE_VALIDATIONS code_buf_size = scr->_bufSize; #endif - local_script = s->segMan->getScriptIfLoaded(scriptState.xs->local_segment); + local_script = s->_segMan->getScriptIfLoaded(scriptState.xs->local_segment); if (!local_script) { warning("Could not find local script from segment %x", scriptState.xs->local_segment); local_script = NULL; @@ -916,7 +916,7 @@ void run_vm(EngineState *s, int restoring) { argc += scriptState.restAdjust; if (kfun.signature - && !kernel_matches_signature(s->segMan, kfun.signature, argc, scriptState.xs->sp + 1)) { + && !kernel_matches_signature(s->_segMan, kfun.signature, argc, scriptState.xs->sp + 1)) { error("[VM] Invalid arguments to kernel call %x", opparams[0]); } else { reg_t *argv = scriptState.xs->sp + 1; @@ -1009,7 +1009,7 @@ void run_vm(EngineState *s, int restoring) { if (old_xs->type == EXEC_STACK_TYPE_VARSELECTOR) { // varselector access? - reg_t *var = old_xs->getVarPointer(s->segMan); + reg_t *var = old_xs->getVarPointer(s->_segMan); if (old_xs->argc) // write? *var = old_xs->variables_argp[1]; else // No, read @@ -1050,7 +1050,7 @@ void run_vm(EngineState *s, int restoring) { break; case 0x28: // class - s->r_acc = s->segMan->getClassAddress((unsigned)opparams[0], SCRIPT_GET_LOCK, + s->r_acc = s->_segMan->getClassAddress((unsigned)opparams[0], SCRIPT_GET_LOCK, scriptState.xs->addr.pc); break; @@ -1070,7 +1070,7 @@ void run_vm(EngineState *s, int restoring) { break; case 0x2b: // super - r_temp = s->segMan->getClassAddress(opparams[0], SCRIPT_GET_LOAD, scriptState.xs->addr.pc); + r_temp = s->_segMan->getClassAddress(opparams[0], SCRIPT_GET_LOAD, scriptState.xs->addr.pc); if (!r_temp.segment) error("[VM]: Invalid superclass in object"); |