[Scummvm-cvs-logs] CVS: scummvm/tools/skycpt Makefile,NONE,1.1.2.2 ReadMe.txt,NONE,1.1.2.2 AsciiCptCompile.cpp,1.1,1.1.2.1 KmpSearch.cpp,1.1,1.1.2.1 KmpSearch.h,1.1,1.1.2.1 cptcompiler.cpp,1.1,1.1.2.1 idFinder.cpp,1.1.2.1,1.1.2.2 stdafx.h,1.1,1.1.2.1

Robert Göffringmann lavosspawn at users.sourceforge.net
Thu Nov 3 16:52:09 CET 2005


Update of /cvsroot/scummvm/scummvm/tools/skycpt
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10514/tools/skycpt

Modified Files:
      Tag: branch-0-8-0
	AsciiCptCompile.cpp KmpSearch.cpp KmpSearch.h cptcompiler.cpp 
	idFinder.cpp stdafx.h 
Added Files:
      Tag: branch-0-8-0
	Makefile ReadMe.txt 
Log Message:
copied from CVS head

--- NEW FILE: Makefile ---
# This worked for me
# Sorry if it doesn't work for you, but I don't know how to write Makefiles.
# After all, I'm only a windows user.
# I would've liked to test it on linux, but I couldn't find the Start button.

TARGET=TXT2CPT
OBJS=AsciiCptCompile.o cptcompiler.o cpthelp.o idFinder.o KmpSearch.o stdafx.o TextFile.o

all: $(TARGET)

clean:
	rm -f $(TARGET) $(OBJS)

$(TARGET): $(OBJS)
	$(CC) $(OBJS) $(LDFLAGS) -o $(TARGET)

%.o: %.cpp
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
--- NEW FILE: ReadMe.txt ---

Since V.0.8.0 ScummVM requires the SKY.CPT file for running Beneath a Steel Sky.
This file contains data that was originally included in the SKY.EXE and was also included
in the ScummVM executable before 0.8.0.
Including all this data in the executable has the disadvantage that it wastes memory.
Even when playing a completely different game (like, e.g. Day of the Tentacle) ScummVM would
have the Beneath a Steel Sky data lying around in memory. This doesn't make much of a difference
on a 1GB RAM windows system, but for platforms like PALM and PocketPC it's a real problem,
so this data was moved into the SKY.CPT file and is loaded at runtime when BASS is started.

This program creates the SKY.CPT file.

If you want to create your own file, *PLEASE* simply forget about it.
It's a long and annoying procedure and won't help you with anything.
This program was only included in ScummVM's source tree because the Debian license
forces us to.
Instead download the file from http://www.scummvm.org/SKY.CPT
Also, please be aware that if you create your own CPT file (if it isn't exactly the same as the
one we offer for download at www.scummvm.org), it will be incompatible and the savegames produced
using the file will be incompatible with ScummVM using the normal CPT file.
The incompatibility will not be detected by ScummVM, it will most probably simply crash.

If you still want to waste your time by creating this file:
1) compile the tool
2) run it once, it'll complain that it's missing 7 files, the RESET.* files but
	it creates an incomplete COMPACT.DBG file anyways, which you rename to SKY.CPT.
3) download the 7 different Beneath a Steel Sky versions:
	v.0.00288: The first floppy version that was released
	v.0.00303: Another floppy version
	v.0.00331: Another floppy version
	v.0.00348: Another floppy version
	v.0.00365: CD Demo
	v.0.00368: Full CD version
	v.0.00372: Final CD version
4) Change scummvm/sky/logic.cpp, function fnSkipIntroCode
	so that it calls _skyControl->doLoadSavePanel()
5) Compile the patched ScummVM.
6) Start each of the BASS versions, enjoy the intro over and over again.
	Afterwards, it'll automatically show the load/save dialog where you save the game.
7) Rename the Savegame files you created to "RESET.*", depending on the version.
	e.g. RESET.288 for v.0.00288
8) Copy the files into the skycpt tool directory, execute the tool again.
	It'll create a new COMPACT.DBG.
9) Rename this file to SKY.CPT.
10) DELETE THE FUCKING FILE BECAUSE IT'S PROBABLY BROKEN, NOT WORTH BOTHERING WITH ANYWAYS
	AND DOWNLOAD THE SKY.CPT FILE FROM THE URL ABOVE!!
	
Oh, I almost forgot.
The program only works on little endian systems and probably isn't alignment safe either.
It may also leak memory or accidentially reformat your harddisk. Who knows.
You've been warned.

Index: AsciiCptCompile.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/tools/skycpt/AsciiCptCompile.cpp,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- AsciiCptCompile.cpp	14 Oct 2005 07:58:30 -0000	1.1
+++ AsciiCptCompile.cpp	4 Nov 2005 00:51:23 -0000	1.1.2.1
@@ -18,8 +18,13 @@
 
 void doCompile(FILE *inf, FILE *debOutf, FILE *resOutf, TextFile *cptDef, FILE *sve);
 
-int _tmain(int argc, _TCHAR* argv[])
+int main(int argc, char* argv[])
 {
+	uint8 testBuf[4] = { 0x11, 0x22, 0x33, 0x44 };
+	if (*(uint32*)testBuf != 0x44332211) {
+		printf("Sorry, this program only works on little endian systems.\nGoodbye.\n");
+		return 0;
+	}
 	TextFile *cptDef = new TextFile("compact.txt");
 	FILE *inf = fopen("compact.txt", "r");
 	FILE *dbg = fopen("compact.dbg", "wb");

Index: KmpSearch.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/tools/skycpt/KmpSearch.cpp,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- KmpSearch.cpp	14 Oct 2005 07:58:30 -0000	1.1
+++ KmpSearch.cpp	4 Nov 2005 00:51:23 -0000	1.1.2.1
@@ -1,5 +1,10 @@
 #include "stdafx.h"
 #include "KmpSearch.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef _MSC_VER
 
 __declspec(naked) void __fastcall KmpSearch::init(const char *subStr) {
 	__asm {
@@ -127,3 +132,15 @@
 	}
 }
 
+#else
+
+void __fastcall KmpSearch::init(const char *subStr) {
+	strcpy(_subStr, subStr);
+}
+
+char * __fastcall KmpSearch::search(const char *str) {
+	return strstr(str, _subStr);
+}
+
+#endif
+

Index: KmpSearch.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/tools/skycpt/KmpSearch.h,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- KmpSearch.h	14 Oct 2005 07:58:30 -0000	1.1
+++ KmpSearch.h	4 Nov 2005 00:51:23 -0000	1.1.2.1
@@ -1,6 +1,10 @@
 #ifndef __KmpSearch__
 #define __KmpSearch__
 
+#ifndef _MSC_VER
+#define __fastcall
+#endif
+
 class KmpSearch {
 public:
 	void __fastcall init(const char *subStr);

Index: cptcompiler.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/tools/skycpt/cptcompiler.cpp,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- cptcompiler.cpp	14 Oct 2005 07:58:30 -0000	1.1
+++ cptcompiler.cpp	4 Nov 2005 00:51:23 -0000	1.1.2.1
@@ -1,6 +1,9 @@
 #include "stdafx.h"
 #include "cpthelp.h"
 #include "textfile.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 uint32 crop(char *line);
 uint16 findCptId(char *name, TextFile *cptFile);
@@ -243,19 +246,29 @@
 	uint16 maxStrl = 0;
 	uint16 maxCptl = 0;
 
+	printf("Processing...\n");
 	CptObj *resCpts;
 	uint16 baseLists[NUM_DATA_LISTS];
 	memset(baseLists, 0, NUM_DATA_LISTS * 2);
 	resCpts = (CptObj*)malloc(MAX_CPTS * sizeof(CptObj));
 	memset(resCpts, 0, MAX_CPTS * sizeof(CptObj));
+	printf(" MainLists...\n");
 	processMainLists(inf, resCpts, baseLists);
+	printf(" Compacts...\n");
 	processCpts(inf, resCpts);
+	printf(" Turntables...\n");
 	processTurntabs(inf, resCpts);
+	printf(" Animation tables...\n");
 	processBins(inf, resCpts, "ANIMSEQS", "ANIMSEQ", ANIMSEQ);
+	printf(" Unknown binaries...\n");
 	processBins(inf, resCpts, "MISCBINS", "MISCBIN", MISCBIN);
+	printf(" Get To tables...\n");
 	processBins(inf, resCpts, "GETTOTAB", "GET_TOS", GETTOTAB);
+	printf(" Scratch buffers...\n");
 	processBins(inf, resCpts, "SCRATCHR", "SCRATCH", ROUTEBUF);
+	printf(" Symbolic links...\n");
 	processSymlinks(inf, resCpts, baseLists);
+	printf("Converting to binary data...\n");
 	uint32 numCpts = 1;
 	for (uint32 cnt = 1; cnt < MAX_CPTS; cnt++)
 		if (resCpts[cnt].data || resCpts[cnt].dbgName || resCpts[cnt].len)
@@ -351,6 +364,7 @@
 		fwrite(dlinks + cnt * 2 + 1, 2, 1, debOutf);
 		fwrite(dlinks + cnt * 2 + 1, 2, 1, resOutf);
 	}
+	printf("Processing diff data...\n");
 	// 288 diffdata
 	FILE *dif = fopen("288diff.txt", "r");
 	assert(dif);
@@ -408,6 +422,7 @@
 	fwrite(&diffDest, 1, 2, resOutf);
 	fwrite(diff, 2, diffDest, resOutf);
 
+	printf("Converting Save data...\n");
 	// the IDs of the compacts to be saved
 	char cptName[1024];
 	uint16 saveIds[2048];
@@ -428,50 +443,76 @@
 	fwrite(&numIds, 2, 1, resOutf);
 	fwrite(saveIds, 2, numIds, resOutf);
 
+	printf("Converting Reset data...\n");
 	// now append the reset data
-	uint16 gameVers[6] = { 303, 331, 348, 365, 368, 372 };
-	FILE *res288 = fopen("RESET.288", "rb");
-	fseek(res288, 0, SEEK_END);
-	assert((ftell(res288) / 2) < 65536);
-	uint16 resSize = (uint16)(ftell(res288) / 2);
-	fseek(res288, 0, SEEK_SET);
-	uint16 *buf288 = (uint16*)malloc(resSize * 2);
-	fread(buf288, 2, resSize, res288);
-	fclose(res288);
-	fwrite(&resSize, 1, 2, debOutf);
-	fwrite(buf288, 2, resSize, debOutf);
+	uint16 gameVers[7] = { 303, 331, 348, 365, 368, 372, 288 };
+	// make sure all files exist
+	bool filesExist = true;
+	char inName[32];
+	for (int i = 0; i < 7; i++) {
+		sprintf(inName, "reset.%03d", gameVers[i]);
+		FILE *test = fopen(inName, "rb");
+		if (test)
+			fclose(test);
+		else {
+			filesExist = false;
+			printf("File %s not found\n", inName);
+		}
+	}
+	
+	if (filesExist) {
+		FILE *res288 = fopen("RESET.288", "rb");
+		fseek(res288, 0, SEEK_END);
+		assert((ftell(res288) / 2) < 65536);
+		uint16 resSize = (uint16)(ftell(res288) / 2);
+		fseek(res288, 0, SEEK_SET);
+		uint16 *buf288 = (uint16*)malloc(resSize * 2);
+		fread(buf288, 2, resSize, res288);
+		fclose(res288);
+		fwrite(&resSize, 1, 2, debOutf);
+		fwrite(buf288, 2, resSize, debOutf);
 
-	uint16 tmp = 7;
-	fwrite(&tmp, 2, 1, debOutf);
-	tmp = 288;
-	fwrite(&tmp, 2, 1, debOutf);
-	tmp = 0;
-	fwrite(&tmp, 2, 1, debOutf);
-	printf("reset destination: %d\n", ftell(debOutf));
-	for (int cnt = 0; cnt < 6; cnt++) {
-		char inName[32];
-		uint16 diff[8192];
-		uint16 diffPos = 0;
-		sprintf(inName, "reset.%03d", gameVers[cnt]);
-		FILE *resDiff = fopen(inName, "rb");
-		fseek(resDiff, 0, SEEK_END);
-		assert(ftell(resDiff) == (resSize * 2));
-		fseek(resDiff, 0, SEEK_SET);
-		uint16 *bufDif = (uint16*)malloc(resSize *2);
-		fread(bufDif, 2, resSize, resDiff);
-		fclose(resDiff);
-		for (uint16 eCnt = 0; eCnt < resSize; eCnt++)
-			if (buf288[eCnt] != bufDif[eCnt]) {
-				diff[diffPos++] = eCnt;
-				diff[diffPos++] = bufDif[eCnt];
-			}
-		free(bufDif);
-		fwrite(gameVers + cnt, 1, 2, debOutf);
-		assert(!(diffPos & 1));
-		diffPos /= 2;
-		fwrite(&diffPos, 1, 2, debOutf);
-		fwrite(diff, 2, 2 * diffPos, debOutf);
-		printf("diff v0.0%03d: 2 * 2 * %d\n", gameVers[cnt], diffPos);
+		uint16 tmp = 7;
+		fwrite(&tmp, 2, 1, debOutf);
+		tmp = 288;
+		fwrite(&tmp, 2, 1, debOutf);
+		tmp = 0;
+		fwrite(&tmp, 2, 1, debOutf);
+		printf("reset destination: %d\n", ftell(debOutf));
+		for (int cnt = 0; cnt < 6; cnt++) {
+			uint16 diff[8192];
+			uint16 diffPos = 0;
+			sprintf(inName, "reset.%03d", gameVers[cnt]);
+			FILE *resDiff = fopen(inName, "rb");
+			fseek(resDiff, 0, SEEK_END);
+			assert(ftell(resDiff) == (resSize * 2));
+			fseek(resDiff, 0, SEEK_SET);
+			uint16 *bufDif = (uint16*)malloc(resSize *2);
+			fread(bufDif, 2, resSize, resDiff);
+			fclose(resDiff);
+			for (uint16 eCnt = 0; eCnt < resSize; eCnt++)
+				if (buf288[eCnt] != bufDif[eCnt]) {
+					diff[diffPos++] = eCnt;
+					diff[diffPos++] = bufDif[eCnt];
+				}
+			free(bufDif);
+			fwrite(gameVers + cnt, 1, 2, debOutf);
+			assert(!(diffPos & 1));
+			diffPos /= 2;
+			fwrite(&diffPos, 1, 2, debOutf);
+			fwrite(diff, 2, 2 * diffPos, debOutf);
+			printf("diff v0.0%03d: 2 * 2 * %d\n", gameVers[cnt], diffPos);
+		}
+	} else {
+		printf("Creating CPT file with Dummy reset data @ %d\n", ftell(debOutf));
+		uint16 resetFields16 = 4;
+		fwrite(&resetFields16, 2, 1, debOutf);
+		uint32 blah = 8;
+		fwrite(&blah, 4, 1, debOutf); // size field: 8 bytes
+		blah = (uint32)-1;
+		fwrite(&blah, 4, 1, debOutf); // save file revision. -1 is unknown to scummvm, so it'll refuse to load it.
+		resetFields16 = 0;
+		fwrite(&resetFields16, 2, 1, debOutf); // numDiffs: 0, no further reset blocks.
 	}
 
 	// now fill the raw-compact-data-size header field

Index: idFinder.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/tools/skycpt/idFinder.cpp,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- idFinder.cpp	18 Oct 2005 02:11:28 -0000	1.1.2.1
+++ idFinder.cpp	4 Nov 2005 00:51:23 -0000	1.1.2.2
@@ -1,6 +1,9 @@
 #include "stdafx.h"
 #include "TextFile.h"
 #include "KmpSearch.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 uint16 findCptId(char *name, TextFile *cptFile) {
 	KmpSearch *kmp = new KmpSearch();

Index: stdafx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/tools/skycpt/stdafx.h,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- stdafx.h	14 Oct 2005 07:58:30 -0000	1.1
+++ stdafx.h	4 Nov 2005 00:51:23 -0000	1.1.2.1
@@ -2,13 +2,15 @@
 // oder projektspezifische Includedateien, die häufig benutzt, aber
 // in unregelmäßigen Abständen geändert werden.
 //
+#ifndef __STDAFX_H__
+#define __STDAFX_H__
 
+#ifdef _MSC_VER
 #pragma once
 
-
 #include <iostream>
 #include <tchar.h>
-
+#endif
 
 typedef unsigned char byte;
 typedef unsigned char uint8;
@@ -30,4 +32,5 @@
 	uint16 type;
 	//uint16 id;
 };
-// TODO: Verweisen Sie hier auf zusätzliche Header, die Ihr Programm erfordert
+
+#endif // __STDAFX_H__





More information about the Scummvm-git-logs mailing list