[Scummvm-cvs-logs] CVS: scummex descumm6.cpp,NONE,1.1 Makefile,1.3,1.4 descumm.cpp,1.1.1.1,1.2 descumm.h,1.1.1.1,1.2 scummex.cpp,1.7,1.8 scummex.h,1.4,1.5 wxwindows.cpp,1.4,1.5 wxwindows.h,1.2,1.3

Adrien Mercier yoshizf at users.sourceforge.net
Fri Sep 19 13:53:26 CEST 2003


Update of /cvsroot/scummvm/scummex
In directory sc8-pr-cvs1:/tmp/cvs-serv4423

Modified Files:
	Makefile descumm.cpp descumm.h scummex.cpp scummex.h 
	wxwindows.cpp wxwindows.h 
Added Files:
	descumm6.cpp 
Log Message:
Added descumm6 and a dialog which choose the good Scumm version for the game

--- NEW FILE: descumm6.cpp ---
/* DeScumm - Scumm Script Disassembler (version 6-8 scripts)
 * Copyright (C) 2001  Ludvig Strigeus
 * Copyright (C) 2002, 2003  The ScummVM Team
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header: /cvsroot/scummvm/scummex/descumm6.cpp,v 1.1 2003/09/19 19:57:07 yoshizf Exp $
[...2360 lines suppressed...]
		break;
	case 0xEC:
		ext("rp|getActorLayer");
		break;
	case 0xED:
		ext("rp|getObjectNewDir");
		break;
	case 0xF3:
		ext("rsp|readINI");
		break;
	case 0xFA:
		get_byte();
		ext("s|unknownFA");
		break;
	default:
		invalidop(NULL, code);
		break;
	}
}


Index: Makefile
===================================================================
RCS file: /cvsroot/scummvm/scummex/Makefile,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Makefile	19 Sep 2003 15:42:00 -0000	1.3
+++ Makefile	19 Sep 2003 19:57:07 -0000	1.4
@@ -1,7 +1,7 @@
 CXX      := g++
 RESSW    := --define __WIN32__ --define __WIN95__ --define __GNUWIN32__
 REZ_CMD  := `wx-config --rezflags`
-OBJS     := file.o scummex.o resource.o mixer.o image.o sound.o wxwindows.o descumm.o
+OBJS     := file.o scummex.o resource.o mixer.o image.o sound.o wxwindows.o descumm.o descumm6.o
 CXXFLAGS := -DOSUNIX -g -O -Wall -Wuninitialized -Wshadow -Wstrict-prototypes -Wno-unused-variable -Wno-long-long -Wno-multichar -Wno-unknown-pragmas
 CXXFLAGS += `wx-config --cxxflags` `sdl-config --cflags`
 LIBS     := `wx-config --libs` `sdl-config --libs` -lSDL_mixer
@@ -22,6 +22,6 @@
 	$(REZ_CMD) scummex
 
 clean:
-	rm -f scummex file.o scummex.o resource.o mixer.o image.o sound.o wxwindows.o descumm.o
+	rm -f scummex file.o scummex.o resource.o mixer.o image.o sound.o wxwindows.o descumm.o descumm6.o
 
 .PHONY: all clean mac

Index: descumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/descumm.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- descumm.cpp	18 Sep 2003 16:26:53 -0000	1.1.1.1
+++ descumm.cpp	19 Sep 2003 19:57:07 -0000	1.2
@@ -92,10 +92,8 @@
 bool IndyFlag = false;
 bool GF_UNBLOCKED = false;
 
-
 void emit_if(char *buf, char *condition);
 
-
 const char *var_names2[] = {
 	/* 0 */
 	"VAR_EGO",
@@ -186,7 +184,6 @@
 	return s;
 }
 
-
 char *DeScumm::get_var(char *buf)
 {
 	int i;
@@ -294,8 +291,6 @@
 	return strecpy(buf, "\"");
 }
 
-
-
 char *DeScumm::add_a_tok(char *buf, int type)
 {
 	switch (type) {
@@ -1026,67 +1021,6 @@
 	case 0x06:
 		do_tok(buf, "ShakeOff", 0);
 		break;
-/*
-	case 0x07:
-		do_tok(buf, "Unused", 0);
-		break;
-	case 0x08:
-		buf =
-			do_tok(buf, "roomFunc2",
-						 ((opcode & 0x80) ? A1V : A1B) | ((opcode & 0x40) ? A2V : A2B) |
-						 ((opcode & 0x20) ? A3V : A3B));
-		break;
-	case 0x09:
-		buf = do_tok(buf, "saveLoad?", ((opcode & 0x80) ? A1V : A1B) | ((opcode & 0x40) ? A2V : A2B));
-		break;
-	case 0x0A:
-		buf = do_tok(buf, "screenEffect?", ((opcode & 0x80) ? A1V : A1W));
-		break;
-	case 0x0B:
-		buf =
-			do_tok(buf, "roomFunc2",
-						 ANOLASTPAREN | ((opcode & 0x80) ? A1V : A1W) | ((opcode & 0x40) ?
-																														 A2V : A2W) |
-						 ((opcode & 0x20) ? A3V : A3W));
-		opcode = get_byte();
-		buf =
-			do_tok(buf, NULL,
-						 ASTARTCOMMA | ANOFIRSTPAREN | ((opcode & 0x80) ? A1V : A1B) |
-						 ((opcode & 0x40) ? A2V : A2B));
-		break;
-
-	case 0x0C:
-		buf =
-			do_tok(buf, "roomFunc3",
-						 ANOLASTPAREN | ((opcode & 0x80) ? A1V : A1W) | ((opcode & 0x40) ?
-																														 A2V : A2W) |
-						 ((opcode & 0x20) ? A3V : A3W));
-		opcode = get_byte();
-		buf =
-			do_tok(buf, NULL,
-						 ASTARTCOMMA | ANOFIRSTPAREN | ((opcode & 0x80) ? A1V : A1B) |
-						 ((opcode & 0x40) ? A2V : A2B));
-		break;
-
-	case 0x0D:
-		do_tok(buf, "save-string", ((opcode & 0x80) ? A1V : A1B) | A2ASCII);
-		break;
-	case 0x0E:
-		do_tok(buf, "load-string", ((opcode & 0x80) ? A1V : A1B) | A2ASCII);
-		break;
-
-	case 0x0F:
-		buf = do_tok(buf, "palManipulate", ANOLASTPAREN | ((opcode & 0x80) ? A1V : A1B));
-		opcode = get_byte();
-		buf =
-			do_tok(buf, NULL,
-						 ASTARTCOMMA | ANOFIRSTPAREN | ANOLASTPAREN | ((opcode & 0x80) ?
-																													 A1V : A1B) |
-						 ((opcode & 0x40) ? A2V : A2B));
-		opcode = get_byte();
-		buf = do_tok(buf, NULL, ASTARTCOMMA | ANOFIRSTPAREN | ((opcode & 0x80) ? A1V : A1B));
-		break;
-*/
 	case 0x10:
 		do_tok(buf, "colorCycleDelay", ((opcode & 0x80) ? A1V : A1B) | ((opcode & 0x40) ? A2V : A2B));
 		break;
@@ -2960,29 +2894,48 @@
 	return p;
 }
 
-
-DeScumm::DeScumm(File& _input, int size)
+DeScumm::DeScumm(File& _input, int size, int scummVersion)
 {
 	byte *mem, *memorg;
 	int len;
 	char *buf;
 
-	scriptVersion = 5;
-	g_jump_opcode = 0x18;
+	scriptVersion = scummVersion;
+	switch (scriptVersion) {
+		case 1:
+		case 2:
+			GF_UNBLOCKED = true;
+			g_jump_opcode = 0x18;
+			break;
+
+		case 3:
+		case 4:
+		case 5:
+			g_jump_opcode = 0x18;
+			break;
+
+		case 6:
+		case 7:
+			g_jump_opcode = 0x73;
+			break;
+
+		case 8:
+			g_jump_opcode = 0x66;
+			break;
+	}
 	
 	len = size;
 	memorg = mem = (byte *)malloc(size);
 	_input.read(mem, size);
 	size_of_code = size;
 
-	buf = (char *)malloc(4096);
+	output = buf = (char *)malloc(8192);
 
 	offs_of_line = 0;
 
 	if (GF_UNBLOCKED) {
 		if (size_of_code < 4) {
-			printf("File too small to be a script\n");
-			exit(0);
+			return;
 		}
 		// Hack to detect verb script: first 4 bytes should be file length
 		if (TO_LE_32(*((uint32 *)mem)) == size_of_code) {
@@ -2993,15 +2946,19 @@
 		} else {
 			mem += 4;
 		}
-	} else if (scriptVersion == 5) {
+	} else if (scriptVersion > 4) {
 		if (size_of_code < 8) {
-			printf("File too small to be a script\n");
-			exit(0);
+			return;
 		}
 		switch (TO_BE_32(*((uint32 *)mem))) {
 		case 'LSCR':
-			printf("Script# %d\n", (byte)mem[8]);
-			mem += 9;
+			if (scriptVersion == 8) {
+				mem += 12;
+			} else if (scriptVersion == 7) {
+				mem += 10;
+			} else {
+				mem += 9;
+			}
 			break;											/* Local script */
 		case 'SCRP':
 			mem += 8;
@@ -3013,20 +2970,23 @@
 			mem += 8;
 			break;											/* Exit code */
 		case 'VERB':
-			offs_of_line = skipVerbHeader_V5(mem + 8) - mem;
+			if (scriptVersion == 8) {
+				mem = skipVerbHeader_V8(mem + 8);
+			} else if (scriptVersion > 5) {
+				offs_of_line = skipVerbHeader_V67(mem);
+			} else {
+				offs_of_line = skipVerbHeader_V5(mem + 8) - mem;
+			}
 			break;											/* Verb */
 		default:
-			printf("Unknown script type!\n");
-			exit(0);
+			return;
 		}
 	} else {
 		if (size_of_code < 6) {
-			printf("File too small to be a script\n");
-			exit(0);
+			return;
 		}
 		switch (TO_LE_16(*((uint16 *)mem + 2))) {
 		case MKID('LS'):
-			printf("Script# %d\n", (byte)mem[6]);
 			mem += 7;
 			break;			/* Local script */
 		case MKID('SC'):
@@ -3042,8 +3002,7 @@
 			offs_of_line = skipVerbHeader_V34(mem);
 			break;			/* Verb */
 		default:
-			printf("Unknown script type!\n");
-			exit(0);
+			return;
 		}
 	}
 
@@ -3057,10 +3016,15 @@
 		byte opcode = *cur_pos;
 		int j = num_block_stack;
 		buf[0] = 0;
-		if (scriptVersion <= 2)
+		if (scriptVersion <= 2) {
 			get_tok_V12(buf);
-		else
+		} else if (scriptVersion <= 5) {
 			get_tok_V345(buf);
+		} else if (scriptVersion == 8) {
+			next_line_V8();
+		} else {
+			next_line_V67();
+		}
 		if (buf[0]) {
 			writePendingElse();
 			if (haveElse) {

Index: descumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/descumm.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- descumm.h	18 Sep 2003 16:26:53 -0000	1.1.1.1
+++ descumm.h	19 Sep 2003 19:57:07 -0000	1.2
@@ -103,6 +103,13 @@
 //
 extern uint size_of_code;
 
+struct StackEnt {
+	byte type;
+	long data;
+	StackEnt *left, *right;
+	char *str;
+	StackEnt **list;
+};
 
 class DeScumm {
 private:
@@ -160,8 +167,42 @@
 	byte *skipVerbHeader_V5(byte *p);
 
 public:
-	DeScumm(File& _input, int size);
-	
+	DeScumm(File& _input, int size, int scummVersion);
+
+private:
+	char *output;
+
+	const char *getVarName(uint var);
+	void push(StackEnt * se);
+	void invalidop(const char *cmd, int op);
+	byte *skipVerbHeader_V8(byte *p);
+	int skipVerbHeader_V67(byte *p);
+	StackEnt *se_new(int type);
+	void se_free(StackEnt * se);
+	StackEnt *se_neg(StackEnt * se);
+	StackEnt *se_int(int i);
+	StackEnt *se_var(int i);
+	StackEnt *se_array(int i, StackEnt * dim2, StackEnt * dim1);
+	StackEnt *se_oper(StackEnt * a, int op);
+	StackEnt *se_oper(StackEnt * a, int op, StackEnt * b);
+	StackEnt *se_complex(const char *s);
+	char *se_astext(StackEnt * se, char *where, bool wantparens = true);
+	StackEnt *pop();
+	void kill(StackEnt * se);
+	void doAssign(StackEnt * dst, StackEnt * src);
+	void doAdd(StackEnt * se, int val);
+	StackEnt *dup(StackEnt * se);
+	void writeArray(int i, StackEnt * dim2, StackEnt * dim1, StackEnt * value);
+	void writeVar(int i, StackEnt * value);
+	void addArray(int i, StackEnt * dim1, int val);
+	void addVar(int i, int val);
+	StackEnt *se_get_string();
+	StackEnt *se_get_list();
+	void ext(const char *fmt);
+	void jump();
+	void jumpif(StackEnt * se, bool negate);
+	void next_line_V8();
+	void next_line_V67();
 	
 };
 

Index: scummex.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/scummex.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- scummex.cpp	19 Sep 2003 15:47:42 -0000	1.7
+++ scummex.cpp	19 Sep 2003 19:57:07 -0000	1.8
@@ -112,19 +112,23 @@
 }
 
 void ScummEX::Descumm() {
-	_input.seek(_blockTable[block_id].offset, SEEK_SET);
-	DeScumm(_input, _blockTable[block_id].blockSize);
-}
 	
+	_input.seek(_blockTable[_blockId].offset, SEEK_SET);
+	_scummVersion = _gui->getScummVersionDialog();
+	if (_scummVersion != 0) {
+		DeScumm(_input, _blockTable[_blockId].blockSize, _scummVersion);
+	}
+}
+
 void ScummEX::FileDump(const char *filename) {
 
 	uint32 size = 0, tot_size = 0;
 	char fbuf2[2048];
 
 	_output.open(filename, 2, 0);
-	_input.seek(_blockTable[block_id].offset, SEEK_SET);
+	_input.seek(_blockTable[_blockId].offset, SEEK_SET);
 
-	while (tot_size < _blockTable[block_id].blockSize) {
+	while (tot_size < _blockTable[_blockId].blockSize) {
 		size = _input.read(fbuf2, 1);
 		tot_size += size;
 		_output.write(fbuf2, 1);
@@ -142,8 +146,8 @@
 	int len, offset, nlines, bytes_per_line;
 	byte c;
 	
-	len = _blockTable[block_id].blockSize;
-	offset = _blockTable[block_id].offset;
+	len = _blockTable[_blockId].blockSize;
+	offset = _blockTable[_blockId].offset;
 	bytes_per_line = 16;
 	nlines = len / bytes_per_line;
 	
@@ -152,16 +156,16 @@
 	if (text == NULL)
 		return;
 
-	sprintf(title, "%s Block at offset %d", _blockTable[block_id].blockName, _blockTable[block_id].offset);
+	sprintf(title, "%s Block at offset %d", _blockTable[_blockId].blockName, _blockTable[_blockId].offset);
 	
-	_input.seek(_blockTable[block_id].offset, SEEK_SET);
+	_input.seek(_blockTable[_blockId].offset, SEEK_SET);
 
-	dataorg = data = (byte*) malloc(_blockTable[block_id].blockSize);
+	dataorg = data = (byte*) malloc(_blockTable[_blockId].blockSize);
 
 	if (data == NULL)
 		return;
 
-	_input.read(data, _blockTable[block_id].blockSize);
+	_input.read(data, _blockTable[_blockId].blockSize);
 
 	while (len >= bytes_per_line) {
 		sprintf(buf, "%06X: ", offset);
@@ -238,37 +242,37 @@
 
 void ScummEX::iMUSEPlay()
 {
-	_sound->playiMUSE(_input, _blockTable, block_id, _input);
+	_sound->playiMUSE(_input, _blockTable, _blockId, _input);
 }
 
 void ScummEX::iMUSEDump(const char *filename)
 {
 	_output.open(filename, 2, 0);
 
-	_sound->playiMUSE(_input, _blockTable, block_id, _output, 1);
+	_sound->playiMUSE(_input, _blockTable, _blockId, _output, 1);
 }
 
 void ScummEX::SOUPlay()
 {
-	_sound->playSOU(_blockTable, _input, block_id, _input);
+	_sound->playSOU(_blockTable, _input, _blockId, _input);
 }
 
 void ScummEX::paletteDraw()
 {
 	_image = new Image();
-	_image->drawPalette(_blockTable, block_id, _input);
+	_image->drawPalette(_blockTable, _blockId, _input);
 }
 
 void ScummEX::bgDraw()
 {
 	_image = new Image();
-	_image->drawBG(_input, _blockTable, block_id, "");
+	_image->drawBG(_input, _blockTable, _blockId, "");
 }
 
 void ScummEX::objectDraw()
 {
 	_image = new Image();
-	_image->drawObject(_input, _blockTable, block_id);
+	_image->drawObject(_input, _blockTable, _blockId);
 }
 
 void ScummEX::FileInfo() {
@@ -278,7 +282,7 @@
 }
 	
 void ScummEX::UpdateInfosFromTree(int blockid) {
-	block_id = blockid;
+	_blockId = blockid;
 
 	_gui->updateLabel("TypeLabel", "Type", (uint32)_blockTable[blockid].blockType);
 	_gui->updateLabel("OffsetLabel", "Offset", _blockTable[blockid].offset);

Index: scummex.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/scummex.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- scummex.h	19 Sep 2003 15:47:42 -0000	1.4
+++ scummex.h	19 Sep 2003 19:57:07 -0000	1.5
@@ -40,7 +40,8 @@
 public:
 	File _input;
 	File _output;
-	uint32 block_id;
+	uint32 _blockId;
+	int _scummVersion;
 	
 
 	ScummEX();

Index: wxwindows.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/wxwindows.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- wxwindows.cpp	19 Sep 2003 01:36:40 -0000	1.4
+++ wxwindows.cpp	19 Sep 2003 19:57:07 -0000	1.5
@@ -25,7 +25,7 @@
 #include "scummex.h"
 #include "icons.h"
 
-wxTreeItemId iter[9], itemid;
+wxTreeItemId iter[11], itemid;
 wxTreeCtrl *tree;
 wxStaticText *TypeLabel, *OffsetLabel, *SizeLabel, *DescriptionLabel;
 wxStaticText *SpecLabel[6];
@@ -81,6 +81,71 @@
 	HtmlHelp->DisplayContents();
 }
 
+int GUI_wxWindows::getScummVersionDialog() {
+	int choice;
+	wxString games[22] = {
+	"Maniac Mansion (C64)",
+	"Maniac Mansion (PC)",
+	"Zak McKracken",
+	"Zak McKracken (FM Towns)",
+	"Indiana Jones & The Last Crusade",
+	"Sampler (Loom, Indy3, SOMI)",
+	"The Secret of Monkey Island (Demo)",
+	"The Secret of Monkey Island (EGA)",
+	"The Secret of Monkey Island",
+	"Loom",
+	"Loom (CD)",
+	"Monkey Island 2: LeChuck's Revenge",
+	"Indiana Jones & The Fate of Atlantis",
+	"Day of the Tentacle",
+	"Sam & Max Hit The Road (Demo)",
+	"Sam & Max Hit The Road (Mac demo)",
+	"Sam & Max Hit The Road (Disk)",
+	"Sam & Max Hit The Road (CD)",
+	"Full Throttle",
+	"The Dig",
+	"The Dig (Win95)",
+	"The Curse of Monkey Island"
+	};
+	
+	wxSingleChoiceDialog *dialog = new wxSingleChoiceDialog(frame, "Please select the correct game", "Scumm version selection", 22, games, NULL, wxOK|wxCANCEL|wxCENTRE, wxDefaultPosition);
+	if (dialog->ShowModal() == wxID_OK) {
+		choice = dialog->GetSelection();
+		switch (choice) {
+			case 0:
+				return 1;
+			case 1:
+			case 2:
+				return 2;
+			case 3:
+			case 4:
+			case 9:
+				return 3;
+			case 5:
+			case 6:
+			case 7:
+				return 4;
+			case 8:
+			case 10:
+			case 11:
+			case 12:
+				return 5;
+			case 13:
+			case 14:
+			case 16:
+				return 6;
+			case 17:
+			case 18:
+			case 19:
+				return 7;
+			case 20:
+			case 21:
+				return 8;
+		}
+	}
+	return 0;
+}
+
 void GUI_wxWindows::FileInfoDialog(int size, int encbyte) {
 	char buf[256];
 	char msg[512];
@@ -320,7 +385,7 @@
 
 void GUI_wxWindows::add_tree_elements(char *itemName, int blockid, int level, int type) {
 
-	assert(level <= 8);
+	assert(level <= 10);
 	itemid = iter[level] = tree->AppendItem(iter[level-1], itemName, -1, -1, new TreeItemData(blockid, type));
 
 	if (blocksInfo[type].iconid != 0) {
@@ -795,7 +860,7 @@
 	val1 = SpecButton1->Disconnect(ID_SpecButton1, wxEVT_COMMAND_BUTTON_CLICKED);
 	val2 = SpecButton2->Disconnect(ID_SpecButton2, wxEVT_COMMAND_BUTTON_CLICKED);
 
-	itemtype = item->block_type;
+	itemtype = item->_blockType;
 	switch (itemtype) {
 		case LECF:
 		case LABN:
@@ -1053,6 +1118,6 @@
 		
 	BigIcon->SetBitmap(bigIconBitmap);
 			
-	_scummex->UpdateInfosFromTree(item->block_id);
+	_scummex->UpdateInfosFromTree(item->_blockId);
 	event.Skip();
 }

Index: wxwindows.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/wxwindows.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- wxwindows.h	18 Sep 2003 19:37:14 -0000	1.2
+++ wxwindows.h	19 Sep 2003 19:57:07 -0000	1.3
@@ -95,13 +95,14 @@
 	void updateLabel(char *label, char *title, uint32 text);
 	virtual bool OnInit();
 	void add_tree_elements(char *itemName, int blockid, int level, int type);
+	int getScummVersionDialog();
 };
 
 class TreeItemData : public wxTreeItemData {
 	public:
-		TreeItemData(int blockid, int blocktype) : block_id(blockid), block_type(blocktype) { }
-		int block_id;
-		int block_type;
+		TreeItemData(int blockid, int blocktype) : _blockId(blockid), _blockType(blocktype) { }
+		int _blockId;
+		int _blockType;
 };
 		
 enum





More information about the Scummvm-git-logs mailing list