diff options
-rw-r--r-- | engines/sci/engine/game.cpp | 27 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cfsml | 21 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cpp | 83 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 16 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 18 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.h | 8 | ||||
-rw-r--r-- | engines/sci/engine/state.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/state.h | 2 | ||||
-rw-r--r-- | engines/sci/engine/vm.h | 5 | ||||
-rw-r--r-- | engines/sci/module.mk | 1 |
10 files changed, 130 insertions, 53 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index c84637b2bc..7fd940fd68 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -471,12 +471,16 @@ int script_init_engine(EngineState *s, sci_version_t version) { s->script_000 = &(s->seg_manager->heap[s->script_000_segment]->data.script); s->sys_strings = s->seg_manager->allocateSysStrings(&s->sys_strings_segment); + s->string_frag_segment = s->seg_manager->allocateStringFrags(); + // Allocate static buffer for savegame and CWD directories SystemString *str = &s->sys_strings->strings[SYS_STRING_SAVEDIR]; str->name = strdup("savedir"); str->max_size = MAX_SAVE_DIR_SIZE; - str->value = (char*)sci_malloc(MAX_SAVE_DIR_SIZE + 1); - str->value[0] = 0; // Set to empty string + str->value = (reg_t*)sci_malloc(sizeof(reg_t)*MAX_SAVE_DIR_SIZE); + str->value->segment = s->string_frag_segment; // Set to empty string + str->value->offset = 0; + s->save_dir_copy = make_reg(s->sys_strings_segment, SYS_STRING_SAVEDIR); s->save_dir_edit_offset = 0; @@ -519,8 +523,18 @@ int script_init_engine(EngineState *s, sci_version_t version) { void script_set_gamestate_save_dir(EngineState *s, const char *path) { SystemString *str = &s->sys_strings->strings[SYS_STRING_SAVEDIR]; - strncpy(str->value, path, str->max_size); - str->value[str->max_size] = 0; // Make sure to terminate + + strncpy((char *)str->value, path, str->max_size); + str->value[str->max_size].segment = s->string_frag_segment; // Make sure to terminate + str->value[str->max_size].offset &= 0xff00; // Make sure to terminate +} + +void internal_stringfrag_strncpy(EngineState *s, reg_t *dest, reg_t *src, int len); + +void script_set_gamestate_save_dir(EngineState *s, reg_t path) { + SystemString *str = &s->sys_strings->strings[SYS_STRING_SAVEDIR]; + reg_t *srcbuf = kernel_dereference_reg_pointer(s, path, 1); + internal_stringfrag_strncpy(s, str->value, srcbuf, MAX_SAVE_DIR_SIZE); } void script_free_vm_memory(EngineState *s) { @@ -606,8 +620,9 @@ int game_init(EngineState *s) { SystemString *str = &s->sys_strings->strings[SYS_STRING_PARSER_BASE]; str->name = strdup("parser-base"); str->max_size = MAX_PARSER_BASE; - str->value = (char*)sci_malloc(MAX_PARSER_BASE + 1); - str->value[0] = 0; // Set to empty string + str->value = (reg_t*)sci_malloc(MAX_PARSER_BASE + 1); + str->value[0].segment = s->string_frag_segment; // Set to empty string + str->value[0].offset = 0; // Set to empty string s->parser_base = make_reg(s->sys_strings_segment, SYS_STRING_PARSER_BASE); diff --git a/engines/sci/engine/savegame.cfsml b/engines/sci/engine/savegame.cfsml index 0be2ab1dd4..2b36303057 100644 --- a/engines/sci/engine/savegame.cfsml +++ b/engines/sci/engine/savegame.cfsml @@ -601,7 +601,9 @@ static struct { {MEM_OBJ_LISTS,"LISTS"}, {MEM_OBJ_NODES,"NODES"}, {MEM_OBJ_HUNK,"HUNK"}, - {MEM_OBJ_DYNMEM,"DYNMEM"}}; + {MEM_OBJ_DYNMEM,"DYNMEM"}, + {MEM_OBJ_STRING_FRAG,"STRING_FRAGS"}, +}; int mem_obj_string_to_enum(const char *str) { int i; @@ -635,6 +637,8 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { break; case MEM_OBJ_HUNK: break; + case MEM_OBJ_STRING_FRAG: + break; case MEM_OBJ_LISTS: %CFSMLWRITE ListTable &foo->data.lists INTO fh; break; @@ -683,6 +687,8 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l case MEM_OBJ_HUNK: init_Hunk_table(&foo->data.hunks); break; + case MEM_OBJ_STRING_FRAG: + break; case MEM_OBJ_DYNMEM: %CFSMLREAD DynMem &foo->data.dynmem FROM fh ERRVAR *hiteof LINECOUNTER *line; break; @@ -1039,6 +1045,8 @@ static void reconstruct_sounds(EngineState *s) { } } +void internal_stringfrag_strncpy(EngineState *s, reg_t *dest, reg_t *src, int len); + EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { int read_eof = 0; EngineState *retval; @@ -1126,17 +1134,18 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { // First, pad memory for (int i = 0; i < SYS_STRINGS_MAX; i++) { str = &retval->sys_strings->strings[i]; - char *data = str->value; + char *data = (char *) str->value; if (data) { - str->value = (char *)sci_malloc(str->max_size + 1); - strcpy(str->value, data); + str->value = (reg_t *)sci_malloc(str->max_size + 1); + strcpy((char *)str->value, data); free(data); } } str = &retval->sys_strings->strings[SYS_STRING_SAVEDIR]; - strncpy(str->value, s->sys_strings->strings[SYS_STRING_SAVEDIR].value, str->max_size); - str->value[str->max_size] = 0; // Make sure to terminate + internal_stringfrag_strncpy(s, str->value, s->sys_strings->strings[SYS_STRING_SAVEDIR].value, str->max_size); + str->value[str->max_size].segment = s->string_frag_segment; // Make sure to terminate + str->value[str->max_size].offset &= 0xff00; // Make sure to terminate // Time state: retval->last_wait_time = g_system->getMillis(); diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 8831f43707..259e76ed24 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -4288,7 +4288,9 @@ static struct { {MEM_OBJ_LISTS,"LISTS"}, {MEM_OBJ_NODES,"NODES"}, {MEM_OBJ_HUNK,"HUNK"}, - {MEM_OBJ_DYNMEM,"DYNMEM"}}; + {MEM_OBJ_DYNMEM,"DYNMEM"}, + {MEM_OBJ_STRING_FRAG,"STRING_FRAGS"}, +}; int mem_obj_string_to_enum(const char *str) { int i; @@ -4308,7 +4310,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_int(fh, &foo->segmgr_id); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 620 "engines/sci/engine/savegame.cfsml" +#line 622 "engines/sci/engine/savegame.cfsml" switch (foo->type) { case MEM_OBJ_SCRIPT: #line 822 "engines/sci/engine/savegame.cfsml" @@ -4316,7 +4318,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_Script(fh, &foo->data.script); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 623 "engines/sci/engine/savegame.cfsml" +#line 625 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_CLONES: #line 822 "engines/sci/engine/savegame.cfsml" @@ -4324,7 +4326,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_CloneTable(fh, &foo->data.clones); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 626 "engines/sci/engine/savegame.cfsml" +#line 628 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_LOCALS: #line 822 "engines/sci/engine/savegame.cfsml" @@ -4332,7 +4334,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_LocalVariables(fh, &foo->data.locals); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 629 "engines/sci/engine/savegame.cfsml" +#line 631 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_SYS_STRINGS: #line 822 "engines/sci/engine/savegame.cfsml" @@ -4340,7 +4342,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_SystemStrings(fh, &foo->data.sys_strings); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 632 "engines/sci/engine/savegame.cfsml" +#line 634 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_STACK: #line 822 "engines/sci/engine/savegame.cfsml" @@ -4348,17 +4350,19 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_int(fh, &foo->data.stack.nr); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 635 "engines/sci/engine/savegame.cfsml" +#line 637 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_HUNK: break; + case MEM_OBJ_STRING_FRAG: + break; case MEM_OBJ_LISTS: #line 822 "engines/sci/engine/savegame.cfsml" // Auto-generated CFSML data writer code _cfsml_write_ListTable(fh, &foo->data.lists); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 640 "engines/sci/engine/savegame.cfsml" +#line 644 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_NODES: #line 822 "engines/sci/engine/savegame.cfsml" @@ -4366,7 +4370,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_NodeTable(fh, &foo->data.nodes); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 643 "engines/sci/engine/savegame.cfsml" +#line 647 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_DYNMEM: #line 822 "engines/sci/engine/savegame.cfsml" @@ -4374,7 +4378,7 @@ void write_MemObject(Common::WriteStream *fh, MemObject const *foo) { _cfsml_write_DynMem(fh, &foo->data.dynmem); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 646 "engines/sci/engine/savegame.cfsml" +#line 650 "engines/sci/engine/savegame.cfsml" break; default: break; @@ -4414,7 +4418,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 660 "engines/sci/engine/savegame.cfsml" +#line 664 "engines/sci/engine/savegame.cfsml" switch (foo->type) { case MEM_OBJ_SCRIPT: // Auto-generated CFSML data reader code @@ -4443,7 +4447,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 663 "engines/sci/engine/savegame.cfsml" +#line 667 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_CLONES: // Auto-generated CFSML data reader code @@ -4472,7 +4476,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 666 "engines/sci/engine/savegame.cfsml" +#line 670 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_LOCALS: // Auto-generated CFSML data reader code @@ -4501,7 +4505,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 669 "engines/sci/engine/savegame.cfsml" +#line 673 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_SYS_STRINGS: // Auto-generated CFSML data reader code @@ -4530,7 +4534,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 672 "engines/sci/engine/savegame.cfsml" +#line 676 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_LISTS: // Auto-generated CFSML data reader code @@ -4559,7 +4563,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 675 "engines/sci/engine/savegame.cfsml" +#line 679 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_NODES: // Auto-generated CFSML data reader code @@ -4588,7 +4592,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 678 "engines/sci/engine/savegame.cfsml" +#line 682 "engines/sci/engine/savegame.cfsml" break; case MEM_OBJ_STACK: // Auto-generated CFSML data reader code @@ -4617,12 +4621,14 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 681 "engines/sci/engine/savegame.cfsml" +#line 685 "engines/sci/engine/savegame.cfsml" foo->data.stack.entries = (reg_t *)sci_calloc(foo->data.stack.nr, sizeof(reg_t)); break; case MEM_OBJ_HUNK: init_Hunk_table(&foo->data.hunks); break; + case MEM_OBJ_STRING_FRAG: + break; case MEM_OBJ_DYNMEM: // Auto-generated CFSML data reader code #line 766 "engines/sci/engine/savegame.cfsml" @@ -4650,7 +4656,7 @@ int read_MemObject(Common::SeekableReadStream *fh, MemObject *foo, const char *l } } // End of auto-generated CFSML data reader code -#line 688 "engines/sci/engine/savegame.cfsml" +#line 694 "engines/sci/engine/savegame.cfsml" break; default: break; @@ -4666,7 +4672,7 @@ void write_MemObjPtr(Common::WriteStream *fh, const MemObject * const *foo) { write_MemObject(fh, (*foo)); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 699 "engines/sci/engine/savegame.cfsml" +#line 705 "engines/sci/engine/savegame.cfsml" } else { // Nothing to write WSprintf(fh, "\\null\\"); } @@ -4701,7 +4707,7 @@ int read_MemObjPtr(Common::SeekableReadStream *fh, MemObject **foo, const char * } } // End of auto-generated CFSML data reader code -#line 710 "engines/sci/engine/savegame.cfsml" +#line 716 "engines/sci/engine/savegame.cfsml" return *hiteof; } return 0; @@ -4715,7 +4721,7 @@ void write_CommonString(Common::WriteStream *fh, Common::String const *string) _cfsml_write_string(fh, (&t)); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 719 "engines/sci/engine/savegame.cfsml" +#line 725 "engines/sci/engine/savegame.cfsml" } int read_CommonString(Common::SeekableReadStream *fh, Common::String *string, const char *lastval, int *line, int *hiteof) @@ -4750,7 +4756,7 @@ int read_CommonString(Common::SeekableReadStream *fh, Common::String *string, co } } // End of auto-generated CFSML data reader code -#line 726 "engines/sci/engine/savegame.cfsml" +#line 732 "engines/sci/engine/savegame.cfsml" if (*hiteof) return *hiteof; *string = t; free(t); @@ -4763,13 +4769,13 @@ void write_SegManagerPtr(Common::WriteStream *fh, const SegManager * const *foo) _cfsml_write_bool(fh, &((*foo)->isSci1_1)); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 734 "engines/sci/engine/savegame.cfsml" +#line 740 "engines/sci/engine/savegame.cfsml" #line 822 "engines/sci/engine/savegame.cfsml" // Auto-generated CFSML data writer code _cfsml_write_SegManager(fh, *foo); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 735 "engines/sci/engine/savegame.cfsml" +#line 741 "engines/sci/engine/savegame.cfsml" } int read_SegManagerPtr(Common::SeekableReadStream *fh, SegManager **foo, const char *lastval, int *line, int *hiteof) { @@ -4800,7 +4806,7 @@ int read_SegManagerPtr(Common::SeekableReadStream *fh, SegManager **foo, const c } } // End of auto-generated CFSML data reader code -#line 742 "engines/sci/engine/savegame.cfsml" +#line 748 "engines/sci/engine/savegame.cfsml" *foo = new SegManager(sci11); token = _cfsml_get_identifier(fh, line, hiteof, &assignment); // Auto-generated CFSML data reader code @@ -4827,7 +4833,7 @@ int read_SegManagerPtr(Common::SeekableReadStream *fh, SegManager **foo, const c } } // End of auto-generated CFSML data reader code -#line 745 "engines/sci/engine/savegame.cfsml" +#line 751 "engines/sci/engine/savegame.cfsml" return 0; } @@ -4877,13 +4883,13 @@ int gamestate_save(EngineState *s, Common::WriteStream *fh, const char* savename _cfsml_write_SavegameMetadata(fh, (&meta)); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 790 "engines/sci/engine/savegame.cfsml" +#line 796 "engines/sci/engine/savegame.cfsml" #line 822 "engines/sci/engine/savegame.cfsml" // Auto-generated CFSML data writer code _cfsml_write_EngineState(fh, s); WSprintf(fh, "\n"); // End of auto-generated CFSML data writer code -#line 791 "engines/sci/engine/savegame.cfsml" +#line 797 "engines/sci/engine/savegame.cfsml" _gamestate_unfrob(s); @@ -5135,6 +5141,8 @@ static void reconstruct_sounds(EngineState *s) { } } +void internal_stringfrag_strncpy(EngineState *s, reg_t *dest, reg_t *src, int len); + EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { int read_eof = 0; EngineState *retval; @@ -5189,7 +5197,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { } } // End of auto-generated CFSML data reader code -#line 1065 "engines/sci/engine/savegame.cfsml" +#line 1073 "engines/sci/engine/savegame.cfsml" if (read_eof) return false; @@ -5245,7 +5253,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { } } // End of auto-generated CFSML data reader code -#line 1089 "engines/sci/engine/savegame.cfsml" +#line 1097 "engines/sci/engine/savegame.cfsml" sfx_exit(&s->sound); _gamestate_unfrob(retval); @@ -5286,17 +5294,18 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { // First, pad memory for (int i = 0; i < SYS_STRINGS_MAX; i++) { str = &retval->sys_strings->strings[i]; - char *data = str->value; + char *data = (char *) str->value; if (data) { - str->value = (char *)sci_malloc(str->max_size + 1); - strcpy(str->value, data); + str->value = (reg_t *)sci_malloc(str->max_size + 1); + strcpy((char *)str->value, data); free(data); } } str = &retval->sys_strings->strings[SYS_STRING_SAVEDIR]; - strncpy(str->value, s->sys_strings->strings[SYS_STRING_SAVEDIR].value, str->max_size); - str->value[str->max_size] = 0; // Make sure to terminate + internal_stringfrag_strncpy(s, str->value, s->sys_strings->strings[SYS_STRING_SAVEDIR].value, str->max_size); + str->value[str->max_size].segment = s->string_frag_segment; // Make sure to terminate + str->value[str->max_size].offset &= 0xff00; // Make sure to terminate // Time state: retval->last_wait_time = g_system->getMillis(); @@ -5382,7 +5391,7 @@ bool get_savegame_metadata(Common::SeekableReadStream* stream, SavegameMetadata* } } // End of auto-generated CFSML data reader code -#line 1194 "engines/sci/engine/savegame.cfsml" +#line 1203 "engines/sci/engine/savegame.cfsml" if (read_eof) return false; diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index 0aefa2b331..7a104c8df0 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -87,7 +87,8 @@ char inputbuf[256] = ""; const char *_debug_get_input_default() { char newinpbuf[256]; - + char *newline; + printf("> "); fgets(newinpbuf, 254, stdin); @@ -327,6 +328,10 @@ int c_segtable(EngineState *s) { sciprintf("M dynmem: %d bytes", mobj->data.dynmem.size); break; + case MEM_OBJ_STRING_FRAG: + sciprintf("F string fragments"); + break; + default: sciprintf("I Invalid (type = %x)", mobj->type); break; @@ -424,10 +429,12 @@ static void _c_single_seg_info(EngineState *s, MemObject *mobj) { SystemStrings *strings = &(mobj->data.sys_strings); int i; - sciprintf("system string table\n"); + sciprintf("system string table - viewing currently disabled\n"); +#if 0 for (i = 0; i < SYS_STRINGS_MAX; i++) if (strings->strings[i].name) sciprintf(" %s[%d]=\"%s\"\n", strings->strings[i].name, strings->strings[i].max_size, strings->strings[i].value); +#endif } break; @@ -483,6 +490,11 @@ static void _c_single_seg_info(EngineState *s, MemObject *mobj) { } break; + case MEM_OBJ_STRING_FRAG: { + sciprintf("string frags\n"); + break; + } + default : sciprintf("Invalid type %d\n", mobj->type); break; diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index ca682ef578..ad9bfd27cd 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -1215,6 +1215,14 @@ SystemStrings *SegManager::allocateSysStrings(SegmentId *segid) { return retval; } +SegmentId SegManager::allocateStringFrags() { + SegmentId segid; + + allocNonscriptSegment(MEM_OBJ_STRING_FRAG, &segid); + + return segid; +} + #if 0 // Unreferenced - removed SegmentId SegManager::sm_allocate_reserved_segment(char *src_name) { @@ -1660,6 +1668,13 @@ public: SegInterface(segmgr, mobj, segId, MEM_OBJ_SYS_STRINGS) {} }; +//-------------------- string frags -------------------- +class SegInterfaceStringFrag : public SegInterface { +public: + SegInterfaceStringFrag(SegManager *segmgr, MemObject *mobj, SegmentId segId) : + SegInterface(segmgr, mobj, segId, MEM_OBJ_STRING_FRAG) {} +}; + //-------------------- lists -------------------- class SegInterfaceLists : public SegInterface { @@ -1806,6 +1821,9 @@ SegInterface *SegManager::getSegInterface(SegmentId segid) { case MEM_OBJ_DYNMEM: retval = new SegInterfaceDynMem(this, mobj, segid); break; + case MEM_OBJ_STRING_FRAG: + retval = new SegInterfaceStringFrag(this, mobj, segid); + break; case MEM_OBJ_RESERVED: retval = new SegInterfaceReserved(this, mobj, segid); break; diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h index 1a4f9c53c6..12d2ec72be 100644 --- a/engines/sci/engine/seg_manager.h +++ b/engines/sci/engine/seg_manager.h @@ -304,6 +304,14 @@ public: SystemStrings *allocateSysStrings(SegmentId *segid); + // 5. System Strings + + // Allocates a string fragments segment + // Returns : (SegmentId): Segment ID to use for string fragments + // See also stringfrag.h + SegmentId allocateStringFrags(); + + // 6, 7. Lists and Nodes // Allocate a fresh list diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index 0c7cbd8411..383a0c4264 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -137,6 +137,8 @@ EngineState::EngineState() : _dirseeker(this) { script_000_segment = 0; script_000 = 0; + string_frag_segment = 0; + parser_lastmatch_word = 0; bp_list = 0; have_bp = 0; diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h index a8c1e08d24..a9471d767e 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -251,6 +251,8 @@ struct EngineState { SegmentId sys_strings_segment; SystemStrings *sys_strings; + SegmentId string_frag_segment; + /* Parser data: */ word_t **parser_words; int parser_words_nr; diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h index 8b45f5770b..164f17c757 100644 --- a/engines/sci/engine/vm.h +++ b/engines/sci/engine/vm.h @@ -48,7 +48,7 @@ enum { struct SystemString { char *name; int max_size; - char *value; + reg_t *value; }; struct SystemStrings { @@ -284,7 +284,8 @@ enum memObjType { MEM_OBJ_NODES = 7, MEM_OBJ_HUNK = 8, MEM_OBJ_DYNMEM = 9, - MEM_OBJ_RESERVED = 10, + MEM_OBJ_STRING_FRAG = 10, + MEM_OBJ_RESERVED = 11, MEM_OBJ_MAX = MEM_OBJ_RESERVED // For sanity checking }; diff --git a/engines/sci/module.mk b/engines/sci/module.mk index a2a88c5763..20d4b10e47 100644 --- a/engines/sci/module.mk +++ b/engines/sci/module.mk @@ -32,6 +32,7 @@ MODULE_OBJS = \ engine/scriptconsole.o \ engine/scriptdebug.o \ engine/seg_manager.o \ + engine/stringfrag.o \ engine/state.o \ engine/vm.o \ gfx/font.o \ |