[Scummvm-git-logs] scummvm master -> d247c83515ab2e26d8978511792378a2d14548f7

sev- sev at scummvm.org
Sun Oct 24 08:45:36 UTC 2021


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
50704ce517 GROOVIE: Further work on Triangle puzzle
d247c83515 GROOVIE: Implemented 2 more subs for Triangle puzzle


Commit: 50704ce5179d9f75fc415c1cede8b5139b0e6254
    https://github.com/scummvm/scummvm/commit/50704ce5179d9f75fc415c1cede8b5139b0e6254
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-10-24T09:24:40+03:00

Commit Message:
GROOVIE: Further work on Triangle puzzle

Changed paths:
    engines/groovie/logic/triangle.cpp
    engines/groovie/logic/triangle.h


diff --git a/engines/groovie/logic/triangle.cpp b/engines/groovie/logic/triangle.cpp
index 7f086ab08a..2a57d06fa5 100644
--- a/engines/groovie/logic/triangle.cpp
+++ b/engines/groovie/logic/triangle.cpp
@@ -32,7 +32,7 @@ extern const int8 triangleLookup3[12];
 extern const int8 triangleLogicTable[924];
 }
 
-TriangleGame::TriangleGame() {
+TriangleGame::TriangleGame() : _random("TriangleGame") {
 	init();
 }
 
@@ -106,12 +106,79 @@ int8 TriangleGame::sub02() {
 }
 
 int8 TriangleGame::sub03(int8 player) {
-	return 0;
+	int8 pickedMoves[4];
+	int8 tempTriangle1[68];
+	int8 tempTriangle2[68];
+	int8 a6a[132];
+	int8 tempTriangle3[68];
+	int8 tempMoves[132];
+	int8 pos;
+
+	if (_triangleCellCount >= 2) {
+		sub05(_triangleCells, tempMoves, tempTriangle3);
+		sub07(tempMoves, _triangleCells, tempTriangle3, tempTriangle2, tempTriangle1, a6a);
+
+		// Find move until valid one
+		(pos = sub09(player, tempTriangle2, tempTriangle1, a6a, _triangleCells)) != 66 ||
+		(pos = sub10(player, tempTriangle1, _triangleCells)) != 66 ||
+		(pos = sub12(player, a6a, _triangleCells, tempTriangle1)) != 66 ||
+		(pos = sub09(3 - player, tempTriangle2, tempTriangle1, a6a, _triangleCells));
+
+		if (pos == 66) {
+			pos = _random.getRandomNumber(65);
+
+			int8 oldPos = pos;
+			while (_triangleCells[pos]) {
+				if (++pos > 65)
+					pos = 0;
+				if (oldPos == pos) {
+					pos = 66;
+					break;
+				}
+			}
+		}
+	} else {
+		int8 max = 0;
+		if (!_triangleCells[24]) {
+			pickedMoves[0] = 24;
+			max = 1;
+		}
+
+		if (!_triangleCells[31])
+			pickedMoves[max++] = 31;
+		if (!_triangleCells[32])
+			pickedMoves[max++] = 32;
+		if (max)
+			pos = pickedMoves[_random.getRandomNumber(max - 1)];
+		else
+			pos = tempMoves[0]; // This is uninitalized in this branch
+	}
+
+	if (pos != 66)
+		setCell(pos, player);
+
+	return pos;
 }
 
 void TriangleGame::sub05(int8 *triangleCells, int8 *a2, int8 *a3) {
 }
 
+void TriangleGame::sub07(int8 *a1, int8 *triangleCells, int8 *a3, int8 *a4, int8 *a5, int8 *a6) {
+}
+
+int8 TriangleGame::sub09(int8 key, int8 *a2, int8 *a3, int8 *a4, int8 *triangleCells) {
+	return 0;
+}
+
+int8 TriangleGame::sub10(int8 key, int8 *a2, int8 *triangleCells) {
+	return 0;
+}
+
+int8 TriangleGame::sub12(int8 a1, int8 *a2, int8 *triangleCells, int8 *a4) {
+	return 0;
+}
+
+
 void TriangleGame::setCell(int8 cellnum, int8 val) {
 	if (cellnum >= 0 && cellnum < 66) {
 		++_triangleCellCount;
diff --git a/engines/groovie/logic/triangle.h b/engines/groovie/logic/triangle.h
index 0dd5d8a82e..c33fb89889 100644
--- a/engines/groovie/logic/triangle.h
+++ b/engines/groovie/logic/triangle.h
@@ -38,11 +38,17 @@ private:
 	int8 sub02();
 	int8 sub03(int8 player);
 	void sub05(int8 *triangleCells, int8 *a2, int8 *a3);
+	void sub07(int8 *a1, int8 *triangleCells, int8 *a3, int8 *a4, int8 *a5, int8 *a6);
+	int8 sub09(int8 key, int8 *a2, int8 *a3, int8 *a4, int8 *triangleCells);
+	int8 sub10(int8 key, int8 *a2, int8 *triangleCells);
+	int8 sub12(int8 a1, int8 *a2, int8 *triangleCells, int8 *a4);
 	void setCell(int8 cellnum, int8 val);
 
 private:
 	int _triangleCellCount;
 	int8 _triangleCells[66];
+
+	Common::RandomSource _random;
 };
 
 } // End of Groovie namespace


Commit: d247c83515ab2e26d8978511792378a2d14548f7
    https://github.com/scummvm/scummvm/commit/d247c83515ab2e26d8978511792378a2d14548f7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-10-24T11:44:43+03:00

Commit Message:
GROOVIE: Implemented 2 more subs for Triangle puzzle

Changed paths:
    engines/groovie/logic/triangle.cpp
    engines/groovie/logic/triangle.h


diff --git a/engines/groovie/logic/triangle.cpp b/engines/groovie/logic/triangle.cpp
index 2a57d06fa5..c0ebfee257 100644
--- a/engines/groovie/logic/triangle.cpp
+++ b/engines/groovie/logic/triangle.cpp
@@ -166,19 +166,52 @@ void TriangleGame::sub05(int8 *triangleCells, int8 *a2, int8 *a3) {
 void TriangleGame::sub07(int8 *a1, int8 *triangleCells, int8 *a3, int8 *a4, int8 *a5, int8 *a6) {
 }
 
-int8 TriangleGame::sub09(int8 key, int8 *a2, int8 *a3, int8 *a4, int8 *triangleCells) {
+int8 TriangleGame::sub09(int8 player, int8 *a2, int8 *a3, int8 *a4, int8 *triangleCells) {
 	return 0;
 }
 
-int8 TriangleGame::sub10(int8 key, int8 *a2, int8 *triangleCells) {
-	return 0;
+int8 TriangleGame::sub10(int8 player, int8 *a2, int8 *triangleCells) {
+	int8 *destPtr; // ecx
+	byte mask; // [esp+Fh] [ebp-51h]
+	int counter; // [esp+10h] [ebp-50h]
+	int8 dest[76]; // [esp+14h] [ebp-4Ch] BYREF
+
+	mask = 0;
+	counter = 0;
+
+	if (player == 1)
+		mask = 16;
+	else if (player == 2)
+		mask = 32;
+
+	for (int i = 0; i < 66; ++i) {
+		if (!triangleCells[i] && (mask & (byte)a2[i]) != 0) {
+			copyLogicRow(i, player, dest);
+
+			destPtr = dest;
+
+			while (*destPtr != 66) {
+				if ((a2[*destPtr] & 0xE) == 0xE) {
+					counter++;
+					dest[counter + 8] = i;
+					break;
+				}
+
+				destPtr++;
+			}
+		}
+	}
+
+	if (counter)
+		return dest[_random.getRandomNumber(counter - 1) + 8];
+
+	return 66;
 }
 
-int8 TriangleGame::sub12(int8 a1, int8 *a2, int8 *triangleCells, int8 *a4) {
+int8 TriangleGame::sub12(int8 player, int8 *a2, int8 *triangleCells, int8 *a4) {
 	return 0;
 }
 
-
 void TriangleGame::setCell(int8 cellnum, int8 val) {
 	if (cellnum >= 0 && cellnum < 66) {
 		++_triangleCellCount;
@@ -186,6 +219,18 @@ void TriangleGame::setCell(int8 cellnum, int8 val) {
 	}
 }
 
+void TriangleGame::copyLogicRow(int row, int8 key, int8 *dest) {
+	int pos = 0;
+
+	for (int i = 0; i < 6; i++) {
+		int8 val = triangleLogicTable[14 * row + i];
+		if (val != -1 && _triangleCells[val] == key)
+			dest[pos++] = val;
+	}
+
+	dest[pos] = 66;
+}
+
 namespace {
 
 const int8 triangleLookup1[12] = {
diff --git a/engines/groovie/logic/triangle.h b/engines/groovie/logic/triangle.h
index c33fb89889..6c64a0e26e 100644
--- a/engines/groovie/logic/triangle.h
+++ b/engines/groovie/logic/triangle.h
@@ -43,6 +43,7 @@ private:
 	int8 sub10(int8 key, int8 *a2, int8 *triangleCells);
 	int8 sub12(int8 a1, int8 *a2, int8 *triangleCells, int8 *a4);
 	void setCell(int8 cellnum, int8 val);
+	void copyLogicRow(int row, int8 key, int8 *dest);
 
 private:
 	int _triangleCellCount;




More information about the Scummvm-git-logs mailing list