[Scummvm-git-logs] scummvm-tools master -> 2f8d472d3fac10bfcd5233173dcc4657cedce53c

Die4Ever noreply at scummvm.org
Wed Nov 2 05:03:10 UTC 2022


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

Summary:
d98e9ebfef Groovie compiler explicit first bit argument, reassembler cleanup
2f8d472d3f update .gitignore with extract_hadesch_img


Commit: d98e9ebfef1da0684d62d2bbc1fbf793f73dcc52
    https://github.com/scummvm/scummvm-tools/commit/d98e9ebfef1da0684d62d2bbc1fbf793f73dcc52
Author: Die4Ever (die4ever2005 at gmail.com)
Date: 2022-11-02T00:58:56-04:00

Commit Message:
Groovie compiler explicit first bit argument, reassembler cleanup

Changed paths:
    decompiler/groovie/disassembler.cpp
    decompiler/groovie/disassembler.h
    decompiler/groovie/engine.cpp
    decompiler/groovie/opcodes.h
    decompiler/reassembler.cpp
    decompiler/reassembler.h


diff --git a/decompiler/groovie/disassembler.cpp b/decompiler/groovie/disassembler.cpp
index 5d86f978..d429dd41 100644
--- a/decompiler/groovie/disassembler.cpp
+++ b/decompiler/groovie/disassembler.cpp
@@ -212,6 +212,9 @@ ValuePtr GroovieDisassembler::readParameter(char type) {
 	case 'C': // Indexed value
 		retval = readParameterIndexed(false, true, true);
 		break;
+	case 'B': // First Bit
+		retval = new IntValue(_firstBit, false);
+		break;
 	default:
 		std::cout << "  UNKNOWN param type: " << type << std::endl;
 	}
@@ -386,6 +389,7 @@ void GroovieDisassembler::doAssembly(const std::string &label, std::string &inst
 
 size_t GroovieDisassembler::writeParams(std::vector<byte> &bytes, const char *typeString, const std::vector<std::string> &args, std::string &jumpToLabel) {
 	size_t jumpAddrStart = 0;
+	assert(args.size() >= strlen(typeString));
 	for(int i=0; typeString[i]; i++) {
 		writeParameter(typeString[i], bytes, args[i], jumpAddrStart, jumpToLabel);
 	}
@@ -455,19 +459,16 @@ void GroovieDisassembler::writeParameter(char type, std::vector<byte> &bytes, co
 	case 'C': // Indexed value
 		writeParameterIndexed(false, true, true, bytes, arg);
 		break;
+	case 'B': // First Bit
+		i = std::stoi(arg);
+		_firstBit = bool(i);
+		break;
 	default:
 		std::cout << "writeParameter UNKNOWN param type: " << type << "\n";
 		throw std::runtime_error(std::string() + "writeParameter UNKNOWN param type: " + type);
 	}
 }
 
-void GroovieDisassembler::splitArrayString(const std::string &arg, std::string &first, std::string &second) {
-	size_t e = getEndArgument(arg, 2);
-	first = arg.substr(2, e - 2);
-	second = arg.substr(e + 2);
-	second.pop_back();
-}
-
 void GroovieDisassembler::writeParameterVideoName(std::vector<byte> &bytes, const std::string &arg) {
 	size_t s = 0, e = 0;
 	while(e < arg.length()) {
diff --git a/decompiler/groovie/disassembler.h b/decompiler/groovie/disassembler.h
index 2c71ab7c..2e260648 100644
--- a/decompiler/groovie/disassembler.h
+++ b/decompiler/groovie/disassembler.h
@@ -50,7 +50,6 @@ protected:
 	void writeParameterVideoName(std::vector<byte> &bytes, const std::string &arg);
 	void writeParameterIndexed(bool allow7C, bool limitVal, bool limitVar, std::vector<byte> &bytes, const std::string &arg);
 	void writeParameterArray(std::vector<byte> &bytes, const std::string &arg);
-	void splitArrayString(const std::string &arg, std::string &first, std::string &second);
 
 	ValuePtr readParameterIndexed(bool allow7C, bool limitVal, bool limitVar);
 	ValuePtr readParameterArray();
diff --git a/decompiler/groovie/engine.cpp b/decompiler/groovie/engine.cpp
index e6a6caea..01b4a7ea 100644
--- a/decompiler/groovie/engine.cpp
+++ b/decompiler/groovie/engine.cpp
@@ -81,7 +81,7 @@ const std::vector<GroovieOpcode> GroovieEngine::opcodesT7G = {
 	{0x19, kKernelCallInst, "Sleep",                 "2"},
 	{0x1A, kCondJumpInst,   "JmpStrCmp-NE",          "3A@"},
 	{0x1B, kKernelCallInst, "XOR-Obfuscate",         "3A"},
-	{0x1C, kKernelCallInst, "VDX-Transition",        "2"},
+	{0x1C, kKernelCallInst, "VDX-Transition",        "B2"},
 	{0x1D, kKernelCallInst, "Swap",                  "22"},
 	{0x1E, kKernelCallInst, "Nop8",                  "1"},
 	{0x1F, kUnaryOpPreInst, "Inc",                   "3"},
@@ -92,7 +92,7 @@ const std::vector<GroovieOpcode> GroovieEngine::opcodesT7G = {
 	{0x24, kKernelCallInst, "Mov",                   "32"},
 	{0x25, kBinaryOpInst,   "Add",                   "32"},
 	{0x26, kKernelCallInst, "VideoFromString1",      "V"},
-	{0x27, kKernelCallInst, "VideoFromString2",      "V"},
+	{0x27, kKernelCallInst, "VideoFromString2",      "BV"},
 	{0x28, kKernelCallInst, "Nop16",                 "2"},
 	{0x29, kKernelCallInst, "Stop-MIDI",             ""},
 	{0x2A, kKernelCallInst, "End-Script",            ""},
@@ -174,7 +174,7 @@ const std::vector<GroovieOpcode> GroovieEngine::opcodesV2 = {
 	{0x19, kKernelCallInst, "Sleep",                 "2"},
 	{0x1A, kCondJumpInst,   "JmpStrCmp-NE",          "3A@"},
 	{0x1B, kKernelCallInst, "XOR-Obfuscate",         "3A"},
-	{0x1C, kKernelCallInst, "VDX-Transition",        "4"},
+	{0x1C, kKernelCallInst, "VDX-Transition",        "B4"},
 	{0x1D, kKernelCallInst, "Swap",                  "32"},
 	{0x1E, kKernelCallInst, "Invalid",               "1"},
 	{0x1F, kUnaryOpPreInst, "Inc",                   "3"},
@@ -185,7 +185,7 @@ const std::vector<GroovieOpcode> GroovieEngine::opcodesV2 = {
 	{0x24, kKernelCallInst, "Mov",                   "32"},
 	{0x25, kBinaryOpInst,   "Add",                   "32"},
 	{0x26, kKernelCallInst, "VideoFromString1",      "V"},
-	{0x27, kKernelCallInst, "VideoFromString2",      "V"},
+	{0x27, kKernelCallInst, "VideoFromString2",      "BV"},
 	{0x28, kKernelCallInst, "Invalid",               "2"},
 	{0x29, kKernelCallInst, "Nop",                   ""},
 	{0x2A, kKernelCallInst, "End-Script",            ""},
diff --git a/decompiler/groovie/opcodes.h b/decompiler/groovie/opcodes.h
index ce3baf86..105f8129 100644
--- a/decompiler/groovie/opcodes.h
+++ b/decompiler/groovie/opcodes.h
@@ -35,6 +35,7 @@ struct GroovieOpcode {
 		// S = Script name
 		// V = Video name
 		// C = Indexed value
+		// B = first bit
 };
 
 } // End of namespace Groovie
diff --git a/decompiler/reassembler.cpp b/decompiler/reassembler.cpp
index 486dc99c..06d0e051 100644
--- a/decompiler/reassembler.cpp
+++ b/decompiler/reassembler.cpp
@@ -30,39 +30,35 @@ void Reassembler::assemble() {
 	_binary.clear();
 
 	while(!_f.eos()) {
-		try {
-			std::string line = readLine();
-			auto comment = splitString(line, line.find(";"), 1, true);// remove comments
-			if(line.empty())
-				continue;
-			
-			auto label = splitString(line, line.find(": "), 2);
-			auto instruction = splitString(line, line.find(" "), 1);
-			if(instruction.empty()) {
-				// if it didn't find a space, that means there are no arguments
-				instruction = line;
-				line = "";
-			}
-			std::cout << label << ": " << instruction;
-
-			// parse arguments
-			std::vector<std::string> args;
-			size_t s = 0, e = 0;
-			for(s = 0; s < line.length(); s = e + 2) {
-				if(s > 0) std::cout << ", ";
-				else std::cout << " ";
-				e = getEndArgument(line, s);
-				size_t len = e - s;
-				args.push_back(line.substr(s, len));
-				std::cout << args.back();
-			}
-			std::cout << "; " << comment << "\n";
-			// TODO: maybe parse the arguments into a ValueList of the Value subclasses
-
-			doAssembly(label, instruction, args, comment);
-		} catch(Common::FileException &e) {
-			break;
+		std::string line = readLine();
+		auto comment = splitString(line, line.find(";"), 1, true);// remove comments
+		if(line.empty())
+			continue;
+		
+		auto label = splitString(line, line.find(": "), 2);
+		auto instruction = splitString(line, line.find(" "), 1);
+		if(instruction.empty()) {
+			// if it didn't find a space, that means there are no arguments
+			instruction = line;
+			line = "";
+		}
+		std::cout << label << ": " << instruction;
+
+		// parse arguments
+		std::vector<std::string> args;
+		size_t s = 0, e = 0;
+		for(s = 0; s < line.length(); s = e + 2) {
+			if(s > 0) std::cout << ", ";
+			else std::cout << " ";
+			e = getEndArgument(line, s);
+			size_t len = e - s;
+			args.push_back(line.substr(s, len));
+			std::cout << args.back();
 		}
+		std::cout << "; " << comment << "\n";
+		// TODO: maybe parse the arguments into a ValueList of the Value subclasses
+
+		doAssembly(label, instruction, args, comment);
 	}
 
 	// 2nd pass in order to set jump addresses after reading all labels
@@ -105,15 +101,15 @@ void Reassembler::dumpBinary(std::ostream &output) {
 
 std::string Reassembler::readLine() {
 	std::string line;
-	while(!_f.eos()) {
-		try {
-			char c = _f.readByte();
-			if(c == '\n')
-				break;
-			line += c;
-		} catch(Common::FileException &e) {
-			break;
+	try {
+		while(!_f.eos()) {
+			
+				char c = _f.readByte();
+				if(c == '\n')
+					break;
+				line += c;
 		}
+	} catch(Common::FileException &e) {
 	}
 	return line;
 }
@@ -136,6 +132,9 @@ std::string Reassembler::splitString(std::string &from, size_t pos, size_t separ
 
 void Reassembler::addInstruction(const std::vector<byte> &bytes, int type, size_t jumpAddrStart, size_t jumpAddrLen, const std::string &label, const std::string &jumpToLabel) {
 	if(!label.empty()) {
+		if(_labels.count(label)) {
+			throw std::runtime_error("label: " + label + " already exists");
+		}
 		_labels.emplace(label, _binary.size());
 	}
 
@@ -171,3 +170,10 @@ size_t Reassembler::getEndArgument(const std::string &s, size_t start) {
 	}
 	return s.length();
 }
+
+void Reassembler::splitArrayString(const std::string &arg, std::string &first, std::string &second) {
+	size_t e = getEndArgument(arg, 2);
+	first = arg.substr(2, e - 2);
+	second = arg.substr(e + 2);
+	second.pop_back();
+}
diff --git a/decompiler/reassembler.h b/decompiler/reassembler.h
index 7161496a..e3dff31b 100644
--- a/decompiler/reassembler.h
+++ b/decompiler/reassembler.h
@@ -43,7 +43,7 @@ private:
 	std::vector<Jump> _jumps;
 
 protected:
-	virtual void doAssembly(const std::string &label, std::string &instruction, const std::vector<std::string> &args, const std::string &comment) throw(std::exception) = 0; // push_back to _binary
+	virtual void doAssembly(const std::string &label, std::string &instruction, const std::vector<std::string> &args, const std::string &comment) = 0; // push_back to _binary
 	virtual void doDumpBinary(std::ostream &output);
 	std::string readLine();
 	std::string splitString(std::string &from, size_t pos, size_t separator_len=0, bool reverse=false);
@@ -53,6 +53,7 @@ public:
 	void assemble();
 	void dumpBinary(std::ostream &output);
 	size_t getEndArgument(const std::string &s, size_t start);
+	void splitArrayString(const std::string &arg, std::string &first, std::string &second);
 };
 
 #endif


Commit: 2f8d472d3fac10bfcd5233173dcc4657cedce53c
    https://github.com/scummvm/scummvm-tools/commit/2f8d472d3fac10bfcd5233173dcc4657cedce53c
Author: Die4Ever (die4ever2005 at gmail.com)
Date: 2022-11-02T01:03:05-04:00

Commit Message:
update .gitignore with extract_hadesch_img

Changed paths:
    .gitignore


diff --git a/.gitignore b/.gitignore
index 73fb9c4e..adc13c49 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,6 +15,7 @@
 /deprince
 /descumm
 /desword2
+/extract_hadesch_img
 /extract_mohawk
 /extract_gob_cdi
 /extract_ngi




More information about the Scummvm-git-logs mailing list