aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorFilippos Karapetis2016-01-15 03:25:40 +0200
committerFilippos Karapetis2016-01-15 03:25:40 +0200
commit2a4b04f3b28a924cad402f21979e143fa5cd248a (patch)
treec9b2123ccaf80ed150b10914a3c519e789b7f319 /engines/sci/engine
parenta5a531ec9f5c6f6f6d550a4f0d7034110ec1c02a (diff)
downloadscummvm-rg350-2a4b04f3b28a924cad402f21979e143fa5cd248a.tar.gz
scummvm-rg350-2a4b04f3b28a924cad402f21979e143fa5cd248a.tar.bz2
scummvm-rg350-2a4b04f3b28a924cad402f21979e143fa5cd248a.zip
SCI: Add an initial implementation of kStringTrim
Thanks to lskovlun for his help
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/kernel_tables.h5
-rw-r--r--engines/sci/engine/kstring.cpp7
2 files changed, 8 insertions, 4 deletions
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index 2d0f1c3933..7be85fc3e5 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -331,8 +331,7 @@ static const SciKernelMapSubEntry kString_subops[] = {
{ SIG_UNTIL_SCI21MID, 11, MAP_CALL(StringPrintf), "[or](.*)", NULL },
{ SIG_UNTIL_SCI21MID, 12, MAP_CALL(StringPrintfBuf), "[or](.*)", NULL },
{ SIG_UNTIL_SCI21MID, 13, MAP_CALL(StringAtoi), "[or]", NULL },
- // exact functionality of Trim is unknown atm
- { SIG_UNTIL_SCI21MID, 14, MAP_CALL(StringTrim), "[or]", NULL },
+ { SIG_UNTIL_SCI21MID, 14, MAP_CALL(StringTrim), "[or]i", NULL },
{ SIG_UNTIL_SCI21MID, 15, MAP_CALL(StringUpper), "[or]", NULL },
{ SIG_UNTIL_SCI21MID, 16, MAP_CALL(StringLower), "[or]", NULL },
// the following 2 are unknown atm (happen in Phantasmagoria)
@@ -345,7 +344,7 @@ static const SciKernelMapSubEntry kString_subops[] = {
{ SIG_SINCE_SCI21LATE, 9, MAP_CALL(StringPrintf), "[or](.*)", NULL },
{ SIG_SINCE_SCI21LATE,10, MAP_CALL(StringPrintfBuf), "[or](.*)", NULL },
{ SIG_SINCE_SCI21LATE,11, MAP_CALL(StringAtoi), "[or]", NULL },
- { SIG_SINCE_SCI21LATE,12, MAP_CALL(StringTrim), "[or]", NULL },
+ { SIG_SINCE_SCI21LATE,12, MAP_CALL(StringTrim), "[or]i", NULL },
{ SIG_SINCE_SCI21LATE,13, MAP_CALL(StringUpper), "[or]", NULL },
{ SIG_SINCE_SCI21LATE,14, MAP_CALL(StringLower), "[or]", NULL },
{ SIG_SINCE_SCI21LATE,15, MAP_CALL(StringTrn), "[or]", NULL },
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index cd0d6af936..310e38dbd1 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -860,7 +860,12 @@ reg_t kStringAtoi(EngineState *s, int argc, reg_t *argv) {
}
reg_t kStringTrim(EngineState *s, int argc, reg_t *argv) {
- warning("kStringTrim (argc = %d)", argc);
+ Common::String string = s->_segMan->getString(argv[0]);
+
+ string.trim();
+ // TODO: Second parameter (bitfield, trim from left, right, center)
+ warning("kStringTrim (%d)", argv[1].getOffset());
+ s->_segMan->strcpy(argv[0], string.c_str());
return NULL_REG;
}