[Scummvm-cvs-logs] SF.net SVN: scummvm:[40092] scummvm/trunk/engines/sci/engine

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Thu Apr 23 20:17:35 CEST 2009


Revision: 40092
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40092&view=rev
Author:   thebluegr
Date:     2009-04-23 18:17:35 +0000 (Thu, 23 Apr 2009)

Log Message:
-----------
WIP code for kGetMessage (tested with Eco Quest 1). Currently, it doesn't always work for some reason...

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/engine/kernel.h
    scummvm/trunk/engines/sci/engine/kstring.cpp
    scummvm/trunk/engines/sci/engine/message.cpp

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2009-04-23 16:17:22 UTC (rev 40091)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-04-23 18:17:35 UTC (rev 40092)
@@ -204,6 +204,7 @@
 	/*(?)*/	DEFUN("TimesCot", kTimesCot, "ii"),
 	/*(?)*/	DEFUN("TimesTan", kTimesTan, "ii"),
 	DEFUN("Message", kMessage, ".*"),
+	DEFUN("GetMessage", kGetMessage, ".*"),
 	DEFUN("DoAudio", kDoAudio, ".*"),
 
 

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2009-04-23 16:17:22 UTC (rev 40091)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2009-04-23 18:17:35 UTC (rev 40092)
@@ -450,6 +450,7 @@
 reg_t kTextSize(EngineState *s, int funct_nr, int argc, reg_t *argv);
 reg_t kIsItSkip(EngineState *s, int funct_nr, int argc, reg_t *argv);
 reg_t kMessage(EngineState *s, int funct_nr, int argc, reg_t *argv);
+reg_t kGetMessage(EngineState *s, int funct_nr, int argc, reg_t *argv);
 reg_t kDoAudio(EngineState *s, int funct_nr, int argc, reg_t *argv);
 reg_t k_Unknown(EngineState *s, int funct_nr, int argc, reg_t *argv);
 

Modified: scummvm/trunk/engines/sci/engine/kstring.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kstring.cpp	2009-04-23 16:17:22 UTC (rev 40091)
+++ scummvm/trunk/engines/sci/engine/kstring.cpp	2009-04-23 18:17:35 UTC (rev 40092)
@@ -782,4 +782,28 @@
 	return NULL_REG;
 }
 
+// FIXME: This doesn't always work, sometimes it doesn't find the requested tuple (tested with EcoQuest 1)
+reg_t kGetMessage(EngineState *s, int funct_nr, int argc, reg_t *argv) {
+	if (!state.initialized)
+		message_state_initialize(s->resmgr, &state);
+
+	char *buffer = argc == 4 ? kernel_dereference_char_pointer(s, argv[3], 0) : NULL;
+
+	MessageTuple tuple;
+	tuple.noun = UKPV(0);
+	int module = UKPV(1);
+	tuple.verb = UKPV(2);
+	tuple.cond = 0;
+	tuple.seq = 0;
+
+	if (state.loadRes(module) && state.getSpecific(&tuple)) {
+		if (buffer)
+			state.getText(buffer, 100);
+
+		return make_reg(0, *buffer);
+	} else {
+		return NULL_REG;
+	}
+}
+
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/engine/message.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/message.cpp	2009-04-23 16:17:22 UTC (rev 40091)
+++ scummvm/trunk/engines/sci/engine/message.cpp	2009-04-23 18:17:35 UTC (rev 40092)
@@ -28,17 +28,12 @@
 
 namespace Sci {
 
-#if 0
-// Unreferenced - removed
 static int get_talker_trivial(IndexRecordCursor *cursor) {
 	return -1;
 }
-#endif
 
 /* Version 2.101 and later code ahead */
 
-#if 0
-// Unreferenced - removed
 static void index_record_parse_2101(IndexRecordCursor *cursor, MessageTuple *t) {
 	int noun = *(cursor->index_record + 0);
 	int verb = *(cursor->index_record + 1);
@@ -47,24 +42,17 @@
 	t->verb = verb;
 	t->cond = t->seq = 0;
 }
-#endif
 
-#if 0
-// Unreferenced - removed
 static void index_record_get_text_2101(IndexRecordCursor *cursor, char *buffer, int buffer_size) {
 	int offset = READ_LE_UINT16(cursor->index_record + 2);
 	char *stringptr = (char *)cursor->resource_beginning + offset;
 
 	strncpy(buffer, stringptr, buffer_size);
 }
-#endif
 
-#if 0
-// Unreferenced - removed
 static int header_get_index_record_count_2101(byte *header) {
 	return READ_LE_UINT16(header + 4);
 }
-#endif
 
 // Version 3.411 and later code ahead
 
@@ -175,6 +163,16 @@
 	return 1;
 }
 
+static MessageHandler fixed_handler_old = {
+	2101,
+	index_record_parse_2101,
+	get_talker_trivial,
+	index_record_get_text_2101,
+	header_get_index_record_count_2101,
+	10,		// FIXME: is this correct?
+	11		// FIXME: is this correct?
+};
+
 static MessageHandler fixed_handler = {
 	3411,
 	index_record_parse_3411,
@@ -186,20 +184,23 @@
 };
 
 void message_state_initialize(ResourceManager *resmgr, MessageState *state) {
-	//Resource *tester = resmgr->findResource(kResourceTypeMessage, 0, 0);
-	//int version;
+	Resource *tester = resmgr->findResource(kResourceTypeMessage, 0, 0);
+	int version;
 
-	//if (tester == NULL)
-	//	return;
+	if (tester == NULL)
+		return;
 
-	//version = READ_LE_UINT16(tester->data);
+	version = READ_LE_UINT16(tester->data);
 
 	state->initialized = 1;
 	state->_module = -1;
 	state->resmgr = resmgr;
 	state->current_res = NULL;
 	state->record_count = 0;
-	state->handler = &fixed_handler;
+	if (version == 2101)
+		state->handler = &fixed_handler_old;
+	else
+		state->handler = &fixed_handler;
 }
 
 } // End of namespace Sci


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list