[Scummvm-cvs-logs] CVS: scummvm/sky logic.cpp,1.63,1.64 compact.cpp,1.10,1.11

Oliver Kiehl olki at users.sourceforge.net
Sat May 31 09:26:03 CEST 2003


Update of /cvsroot/scummvm/scummvm/sky
In directory sc8-pr-cvs1:/tmp/cvs-serv5284

Modified Files:
	logic.cpp compact.cpp 
Log Message:
cleanup, add some doxygen docs


Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/logic.cpp,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- logic.cpp	30 May 2003 16:06:42 -0000	1.63
+++ logic.cpp	31 May 2003 16:25:15 -0000	1.64
@@ -104,6 +104,11 @@
 
 void SkyLogic::nop() {}
 
+/**
+ * This function is basicly a wrapper around the real script engine. It runs
+ * the script engine until a script has finished.
+ * @see script()
+ */
 void SkyLogic::logicScript() {
 	// Process the current mega's script
 	// If the script finishes then drop back a level
@@ -113,9 +118,7 @@
 		uint16 *scriptNo = SkyCompact::getSub(_compact, mode);
 		uint16 *offset   = SkyCompact::getSub(_compact, mode + 2);
 
-		uint32 scr = script(*scriptNo, *offset);
-		*scriptNo = (uint16)(scr & 0xffff);
-		*offset   = (uint16)(scr >> 16);
+		*offset = script(*scriptNo, *offset);
 
 		if (!*offset) // script finished
 			_compact->mode -= 4;
@@ -920,15 +923,23 @@
 	memcpy(_scriptVariables + 505, forwardList5b, sizeof(forwardList5b));
 }
 
-uint32 SkyLogic::script(uint16 scriptNo, uint16 offset) {
+/**
+ * \fn uint32 SkyLogic::script(uint16 scriptNo, uint16 offset)
+ * \brief This is the actual script engine. 
+ *        It interprets script \a scriptNo starting at \a offset
+ *
+ * \param scriptNo The script to interpret.
+ * 	\li \arg Bits 0-11 - Script number
+ * 	\li \arg Bits 12-15 - Module number
+ * \param offset At which offset to start interpreting the script.
+ *
+ * @return 0 if script finished. Else offset where to continue.
+ */
+uint16 SkyLogic::script(uint16 scriptNo, uint16 offset) {
 script:
 	// process a script
 	// low level interface to interpreter
 
-	// scriptNo:
-	// Bit  0-11 - Script number
-	// Bit 12-15 - Module number
-
 	uint16 moduleNo = (uint16)((scriptNo & 0xff00) >> 12);
 	debug(3, "Doing Script %x\n", (offset << 16) | scriptNo);
 	uint16 *scriptData = _moduleList[moduleNo]; // get module address
@@ -1039,7 +1050,7 @@
 				_compact = saveCpt;
 
 				if (!ret)
-					return (((scriptData - moduleStart) << 16) | scriptNo);
+					return (scriptData - moduleStart);
 			}
 			break;
 		case 12: // more_than
@@ -1092,7 +1103,7 @@
 			}
 		case 13:
 		case 19: // script_exit
-			return scriptNo;
+			return 0;
 		case 20: // restart_script
 			goto script;
 		default:

Index: compact.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/compact.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- compact.cpp	26 May 2003 19:59:38 -0000	1.10
+++ compact.cpp	31 May 2003 16:25:15 -0000	1.11
@@ -50,6 +50,9 @@
 
 namespace SkyCompact {
 
+/**
+ * Returns the n'th mega set specified by \a megaSet from Compact \a cpt.
+ */
 MegaSet *getMegaSet(Compact *cpt, uint16 megaSet) {
 	switch (megaSet) {
 	case 0:
@@ -65,6 +68,19 @@
 	}
 }
 
+/**
+ \brief Returns the turn table for direction \a dir
+ 	from Compact \a cpt in \a megaSet.
+  
+ Functionally equivalent to:
+ \verbatim
+ clear eax
+ mov al,20
+ mul (cpt[esi]).c_dir
+ add ax,(cpt[esi]).c_mega_set
+ lea eax,(cpt[esi+eax]).c_turn_table_up
+ \endverbatim
+*/
 uint16 **getTurnTable(Compact *cpt, uint16 megaSet, uint16 dir) {
 	MegaSet *m = getMegaSet(cpt, megaSet);
 	switch (dir) {
@@ -83,6 +99,21 @@
 	}
 }
 
+/**
+ * \brief Returns the script for \a mode from Compact \a cpt.
+ *        Add 2 to \a mode to get the offset.
+ *
+ \verbatim
+ uint16 *scriptNo = SkyCompact::getSub(_compact, mode);
+ uint16 *offset   = SkyCompact::getSub(_compact, mode + 2);
+ uint32 script = (*offset << 16) | *scriptNo;
+ \endverbatim
+ * Is functionally equivalent to:
+ \verbatim
+ mov eax,c_base_sub[ebx+esi]
+ \endverbatim
+ where \a esi is the compact and ebx the mode.
+ */ 
 uint16 *getSub(Compact *cpt, uint16 mode) {
 	switch (mode) {
 	case 0:
@@ -189,6 +220,10 @@
 	MK32_A5(TurnTable, turnTableTalk),
 };
 
+/**
+ * Returns a void pointer to offset \a off in compact \a cpt
+ * as it would be on a 386.
+ */
 void *getCompactElem(Compact *cpt, uint32 off) {
 	if (off < COMPACT_SIZE)
 		return((uint8 *)cpt + compactOffsets[off]);





More information about the Scummvm-git-logs mailing list