aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/game.cpp
diff options
context:
space:
mode:
authorLars Skovlund2009-03-10 14:52:02 +0000
committerLars Skovlund2009-03-10 14:52:02 +0000
commit3cddcb1660c32b902052e0e65b75e434e0f1035c (patch)
treed18127f31f61c80b239b3b3a2719341652f3ed96 /engines/sci/engine/game.cpp
parentcbfd80a5d17314790751ab59cffdf318a4b592b5 (diff)
downloadscummvm-rg350-3cddcb1660c32b902052e0e65b75e434e0f1035c.tar.gz
scummvm-rg350-3cddcb1660c32b902052e0e65b75e434e0f1035c.tar.bz2
scummvm-rg350-3cddcb1660c32b902052e0e65b75e434e0f1035c.zip
String fragments support
WIP: No regressions in this part, I hope svn-id: r39297
Diffstat (limited to 'engines/sci/engine/game.cpp')
-rw-r--r--engines/sci/engine/game.cpp27
1 files changed, 21 insertions, 6 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);