[Scummvm-cvs-logs] CVS: tools descumm-common.cpp,1.2,1.3 descumm.cpp,1.34,1.35 descumm6.cpp,1.99,1.100 descumm.h,1.2,1.3

Max Horn fingolfin at users.sourceforge.net
Sat May 10 16:21:06 CEST 2003


Update of /cvsroot/scummvm/tools
In directory sc8-pr-cvs1:/tmp/cvs-serv17360

Modified Files:
	descumm-common.cpp descumm.cpp descumm6.cpp descumm.h 
Log Message:
merged more code

Index: descumm-common.cpp
===================================================================
RCS file: /cvsroot/scummvm/tools/descumm-common.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- descumm-common.cpp	10 May 2003 18:48:43 -0000	1.2
+++ descumm-common.cpp	10 May 2003 23:20:13 -0000	1.3
@@ -48,7 +48,7 @@
 byte *cur_pos, *org_pos;
 int offs_of_line;
 
-int size_of_code;
+uint size_of_code;
 
 
 ///////////////////////////////////////////////////////////////////////////
@@ -178,7 +178,7 @@
 }
 
 // Returns 0 or 1 depending if it's ok to add a block
-bool maybeAddIf(unsigned int cur, unsigned int to)
+bool maybeAddIf(uint cur, uint to)
 {
 	int i;
 	BlockStack *p;
@@ -203,9 +203,72 @@
 		i = (int16)TO_LE_16(*(int16*)(org_pos+to-2));
 	}
 	
-	p->isWhile = p->isWhile && (offs_of_line == to + i);
+	p->isWhile = p->isWhile && (offs_of_line == (int)to + i);
 	p->from = cur;
 	p->to = to;
+	return true;
+}
+
+// Returns 0 or 1 depending if it's ok to add an else
+bool maybeAddElse(uint cur, uint to)
+{
+	BlockStack *p;
+
+	if (((to | cur) >> 16) || (to <= cur))
+		return false;								/* Invalid jump */
+
+	if (!num_block_stack)
+		return false;								/* There are no previous blocks, so an else is not ok */
+
+	p = &block_stack[num_block_stack - 1];
+	if (cur != p->to)
+		return false;								/* We have no prevoius if that is exiting right at the end of this goto */
+
+	num_block_stack--;
+	if (maybeAddIf(cur, to))
+		return true;								/* We can add an else */
+	num_block_stack++;
+	return false;									/* An else is not OK here :( */
+}
+
+bool maybeAddElseIf(uint cur, uint elseto, uint to)
+{
+	uint k;
+	BlockStack *p;
+
+	if (((to | cur | elseto) >> 16) || (elseto < to) || (to <= cur))
+		return false;								/* Invalid jump */
+
+	if (!num_block_stack)
+		return false;								/* There are no previous blocks, so an ifelse is not ok */
+
+	p = &block_stack[num_block_stack - 1];
+
+	if (p->isWhile)
+		return false;
+
+	if (scriptVersion == 8)
+		k = to - 5;
+	else
+		k = to - 3;
+
+	if (k >= size_of_code)
+		return false;								/* Invalid jump */
+
+	if (org_pos[k] != g_jump_opcode)
+		return false;								/* Invalid jump */
+
+	if (scriptVersion == 8)
+		k = to + TO_LE_32(*(int32*)(org_pos + k + 1));
+	else
+		k = to + TO_LE_16(*(int16*)(org_pos + k + 1));
+
+	if (k != elseto)
+		return false;								/* Not an ifelse */
+
+	p->from = cur;
+	p->to = to;
+
 	return true;
 }
 

Index: descumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/tools/descumm.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- descumm.cpp	10 May 2003 18:29:08 -0000	1.34
+++ descumm.cpp	10 May 2003 23:20:13 -0000	1.35
@@ -315,68 +315,6 @@
 	return strchr(buf, 0);
 }
 
-
-/* Returns 0 or 1 depending if it's ok to add an else */
-int maybeAddElse(int cur, int to)
-{
-	BlockStack *p;
-	int i;
-
-	if (((to | cur) >> 16) || (to <= cur))
-		return 0;										/* Invalid jump */
-
-	if (!num_block_stack)
-		return 0;										/* There are no previous blocks, so an else is not ok */
-
-	p = &block_stack[num_block_stack - 1];
-	if (cur != p->to)
-		return 0;										/* We have no prevoius if that is exiting right at the end of this goto */
-
-	num_block_stack--;
-	i = maybeAddIf(cur, to);
-	if (i)
-		return i;										/* We can add an else */
-
-	num_block_stack++;
-
-	return 0;											/* An else is not OK here :( */
-}
-
-bool maybeAddElseIf(int cur, int elseto, int to)
-{
-	int k;
-	BlockStack *p;
-
-	if (((to | cur | elseto) >> 16) || (elseto < to) || (to <= cur))
-		return false;									/* Invalid jump */
-
-	if (!num_block_stack)
-		return false;									/* There are no previous blocks, so an ifelse is not ok */
-
-	p = &block_stack[num_block_stack - 1];
-
-	if (p->isWhile)
-		return false;
-
-	k = to - 3;
-	if (k < 0 || k >= size_of_code)
-		return false;									/* Invalid jump */
-
-	if (org_pos[k] != g_jump_opcode)
-		return false;									/* Invalid jump */
-
-	k = to + TO_LE_16(*(int16*)(org_pos + k + 1));
-
-	if (k != elseto)
-		return false;									/* Not an ifelse */
-
-	p->from = cur;
-	p->to = to;
-
-	return true;
-}
-
-
 void do_decodeparsestring_v2(char *buf, byte opcode)
 {
 	byte buffer[256];
@@ -847,7 +785,7 @@
 
 }
 
-void do_cc(char *buf)
+void do_pseudoRoom(char *buf)
 {
 	int j, i = get_byte();
 
@@ -1335,7 +1273,7 @@
 
 }
 
-void do_unconditional_jump(char *buf, byte opcode)
+void do_unconditional_jump(char *buf)
 {
 	int offset = get_signed_word();
 	int cur = get_curoffs();
@@ -1347,7 +1285,7 @@
 		pendingElse = 1;
 		pendingElseTo = to;
 		pendingElseOffs = cur - 1;
-		pendingElseOpcode = opcode;
+		pendingElseOpcode = g_jump_opcode;
 		pendingElseIndent = num_block_stack;
 		buf[0] = 0;
 	} else {
@@ -1935,8 +1873,7 @@
 		break;
 
 	case 0x18:
-		// jumpRelative
-		do_unconditional_jump(buf, opcode);
+		do_unconditional_jump(buf);
 		break;
 
 	case 0x70:
@@ -1990,7 +1927,7 @@
 		
 	case 0xCC:
 		// pseudoRoom
-		do_cc(buf);
+		do_pseudoRoom(buf);
 		break;
 	case 0x01:
 	case 0x21:
@@ -2403,7 +2340,7 @@
 		break;
 
 	case 0x18:
-		do_unconditional_jump(buf, opcode);
+		do_unconditional_jump(buf);
 		break;
 
 	case 0x1D:
@@ -2649,7 +2586,7 @@
 		break;
 
 	case 0xCC:
-		do_cc(buf);
+		do_pseudoRoom(buf);
 		break;
 
 	case 0x33:

Index: descumm6.cpp
===================================================================
RCS file: /cvsroot/scummvm/tools/descumm6.cpp,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -d -r1.99 -r1.100
--- descumm6.cpp	10 May 2003 22:21:53 -0000	1.99
+++ descumm6.cpp	10 May 2003 23:20:13 -0000	1.100
@@ -1077,72 +1077,6 @@
 	}
 }
 
-/* Returns 0 or 1 depending if it's ok to add an else */
-bool maybeAddElse(unsigned int cur, unsigned int to)
-{
-	BlockStack *p;
-	bool i;
-
-	if (((to | cur) >> 16) || (to <= cur))
-		return false;								/* Invalid jump */
-
-	if (!num_block_stack)
-		return false;								/* There are no previous blocks, so an else is not ok */
-
-	p = &block_stack[num_block_stack - 1];
-	if (cur != p->to)
-		return false;								/* We have no prevoius if that is exiting right at the end of this goto */
-
-	num_block_stack--;
-	i = maybeAddIf(cur, to);
-	if (i)
-		return i;										/* We can add an else */
-	num_block_stack++;
-	return false;									/* An else is not OK here :( */
-}
-
-bool maybeAddElseIf(unsigned int cur, unsigned int elseto, unsigned int to)
-{
-	unsigned int k;
-	BlockStack *p;
-
-	if (((to | cur | elseto) >> 16) || (elseto < to) || (to <= cur))
-		return false;								/* Invalid jump */
-
-	if (!num_block_stack)
-		return false;								/* There are no previous blocks, so an ifelse is not ok */
-
-	p = &block_stack[num_block_stack - 1];
-
-	if (p->isWhile)
-		return false;
-
-	if (scriptVersion == 8)
-		k = to - 5;
-	else
-		k = to - 3;
-
-	if (k < 0 || k >= size_of_code)
-		return false;								/* Invalid jump */
-
-	if (org_pos[k] != g_jump_opcode)
-		return false;								/* Invalid jump */
-
-	if (scriptVersion == 8)
-		k = to + TO_LE_32(*(int32*)(org_pos + k + 1));
-	else
-		k = to + TO_LE_16(*(int16*)(org_pos + k + 1));
-
-	if (k != elseto)
-		return false;								/* Not an ifelse */
-
-	p->from = cur;
-	p->to = to;
-
-	return true;
-}
-
-
 void jump()
 {
 	int offset = get_signed_word();

Index: descumm.h
===================================================================
RCS file: /cvsroot/scummvm/tools/descumm.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- descumm.h	10 May 2003 18:29:08 -0000	1.2
+++ descumm.h	10 May 2003 23:20:13 -0000	1.3
@@ -125,7 +125,7 @@
 //
 // Total size of the currently loaded script
 //
-extern int size_of_code;
+extern uint size_of_code;
 
 //
 // Common
@@ -141,7 +141,9 @@
 extern uint get_word();
 extern int get_signed_word();
 
-extern bool maybeAddIf(unsigned int cur, unsigned int to);
+extern bool maybeAddIf(uint cur, uint to);
+extern bool maybeAddElse(uint cur, uint to);
+extern bool maybeAddElseIf(uint cur, uint elseto, uint to);
 extern void writePendingElse();
 
 #endif





More information about the Scummvm-git-logs mailing list