[Scummvm-cvs-logs] CVS: tools Makefile,1.53,1.54 extract_loom_tg16.c,1.3,1.4 extract_mm_c64.c,1.1,1.2 extract_mm_nes.c,1.12,1.13 extract_zak_c64.c,1.1,1.2 util.c,1.8,1.9

kirben kirben at users.sourceforge.net
Tue Jul 19 16:44:02 CEST 2005


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

Modified Files:
	Makefile extract_loom_tg16.c extract_mm_c64.c extract_mm_nes.c 
	extract_zak_c64.c util.c 
Log Message:

Add patch:
1241249  - Allow ScummVM tools to compile with MSVC, other cleanup


Index: Makefile
===================================================================
RCS file: /cvsroot/scummvm/tools/Makefile,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- Makefile	9 Jun 2005 12:38:44 -0000	1.53
+++ Makefile	19 Jul 2005 23:38:30 -0000	1.54
@@ -58,13 +58,13 @@
 compress_scumm_bun$(EXEEXT): compress_scumm_bun.o compress.o util.o
 	$(CXX) $(LDFLAGS) -o $@ $+
 
-extract_loom_tg16$(EXEEXT): extract_loom_tg16.o
+extract_loom_tg16$(EXEEXT): extract_loom_tg16.o util.o
 	$(CC) $(LDFLAGS) -o $@ $+
 
-extract_mm_c64$(EXEEXT): extract_mm_c64.o
+extract_mm_c64$(EXEEXT): extract_mm_c64.o util.o
 	$(CC) $(LDFLAGS) -o $@ $+
 
-extract_mm_nes$(EXEEXT): extract_mm_nes.o
+extract_mm_nes$(EXEEXT): extract_mm_nes.o util.o
 	$(CC) $(LDFLAGS) -o $@ $+
 
 compress_queen$(EXEEXT): compress_queen.o util.o
@@ -79,7 +79,7 @@
 extract_simon1_amiga$(EXEEXT): extract_simon1_amiga.o
 	$(CC) $(LDFLAGS) -o $@ $+
 
-extract_zak_c64$(EXEEXT): extract_zak_c64.o
+extract_zak_c64$(EXEEXT): extract_zak_c64.o util.o
 	$(CC) $(LDFLAGS) -o $@ $+
 
 compress_simon$(EXEEXT): compress_simon.o compress.o util.o

Index: extract_loom_tg16.c
===================================================================
RCS file: /cvsroot/scummvm/tools/extract_loom_tg16.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- extract_loom_tg16.c	1 Jan 2005 10:33:30 -0000	1.3
+++ extract_loom_tg16.c	19 Jul 2005 23:38:30 -0000	1.4
@@ -23,6 +23,7 @@
 #include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
+#include "util.h"
 
 typedef int BOOL;
 #define TRUE 1
@@ -32,97 +33,46 @@
 /* if not defined, dumps all resources to separate files */
 #define	MAKE_LFLS
 
-#ifdef WIN32
-	#define CDECL __cdecl
-#else
-	#define CDECL 
-#endif
 
-void	CDECL	debug (const char *Text, ...)
-{
-	va_list marker;
-	va_start(marker,Text);
-	vfprintf(stdout,Text,marker);
-	fprintf(stdout,"\n");
-	va_end(marker);
-}
+#ifdef _MSC_VER
+	#define	vsnprintf _vsnprintf
+#endif
 
-void	CDECL	error (const char *Text, ...)
-{
-	va_list marker;
-	va_start(marker,Text);
-	vfprintf(stderr,Text,marker);
-	fprintf(stderr,"\n");
-	va_end(marker);
-	exit(1);
-}
+void notice(const char *s, ...) {
+	char buf[1024];
+	va_list va;
 
-void	CDECL	_assert (BOOL condition, const char *Text, ...)
-{
-	va_list marker;
-	if (condition)
-		return;
-	va_start(marker,Text);
-	vfprintf(stderr,Text,marker);
-	fprintf(stderr,"\n");
-	va_end(marker);
-	/* exit(1); */
-}
+	va_start(va, s);
+	vsnprintf(buf, 1024, s, va);
+	va_end(va);
 
-unsigned char	read_byte (FILE *input)
-{
-	unsigned char val;
-	_assert(fread(&val,1,1,input) == 1,"read_byte - unexpected EOF");
-	return val;
-}
-unsigned short	read_word (FILE *input)
-{
-	unsigned short val;
-	_assert(fread(&val,2,1,input) == 1,"read_word - unexpected EOF");
-	return val;
-}
-void	write_byte (FILE *output, unsigned char val)
-{
-	fwrite(&val,1,1,output);
-}
-void	write_word (FILE *output, unsigned short val)
-{
-	fwrite(&val,2,1,output);
-}
-void	write_long (FILE *output, unsigned long val)
-{
-	fwrite(&val,4,1,output);
+	fprintf(stdout, "%s\n", buf);
 }
 
-
 unsigned char	read_cbyte (FILE *input, short *ctr)
 {
-	unsigned char val;
-	_assert(fread(&val,1,1,input) == 1,"read_cbyte - unexpected EOF");
 	(*ctr) += 1;
-	return val;
+	return readByte(input);
 }
 unsigned short	read_cword (FILE *input, short *ctr)
 {
-	unsigned short val;
-	_assert(fread(&val,2,1,input) == 1,"read_cword - unexpected EOF");
 	(*ctr) += 2;
-	return val;
+	return readUint16LE(input);
 }
 
-void	write_cbyte (FILE *output, unsigned char val, short *ctr)
+void	write_cbyte (FILE *output, uint8 val, short *ctr)
 {
-	fwrite(&val,1,1,output);
+	writeByte(output, val);
 	(*ctr) += 1;
 }
-void	write_cword (FILE *output, unsigned short val, short *ctr)
+void	write_cword (FILE *output, uint16 val, short *ctr)
 {
-	fwrite(&val,2,1,output);
+	writeUint16LE(output, val);
 	(*ctr) += 2;
 }
-void	write_clong (FILE *output, unsigned long val, short *ctr)
+void	write_clong (FILE *output, uint32 val, short *ctr)
 {
-	fwrite(&val,4,1,output);
+	writeUint32LE(output, val);
 	(*ctr) += 4;
 }
 
@@ -761,7 +711,8 @@
 	signed short i, rlen;
 	unsigned char junk, rtype, rid;
 
-	_assert(res != NULL,"extract_resource - no resource specified");
+	if (res == NULL)
+		error("extract_resource - no resource specified");
 	if ((r_offset(res) == 0) && (r_length(res) == 0))
 		return;	/* if offset/length are both 0, skip it */
 	fseek(input,r_offset(res),SEEK_SET);
@@ -770,22 +721,24 @@
 	{
 	case RES_CHARSET:
 		rlen = r_length(res);
-		write_word(output,(unsigned short)(rlen+4));
-		write_word(output,0);
+		writeUint16LE(output,(unsigned short)(rlen+4));
+		writeUint16LE(output,0);
 		for (i = 0; i < rlen; i++)
-			write_byte(output,read_byte(input));
+			writeByte(output,readByte(input));
 		break;
 	case RES_GLOBDATA:
 		rlen = read_cword(input,&i);
 		junk = read_cbyte(input,&i);
 		rtype = read_cbyte(input,&i);
 		rid = read_cbyte(input,&i);
-		_assert(rlen == r_length(res),"extract_resource(globdata) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res));
-		_assert(rtype == 0x11,"extract_resource(globdata) - resource tag is incorrect!");
-		write_long(output,(unsigned short)(rlen + 1));
-		write_word(output,'O0');	/* 0O - Object Index */
+		if (rlen != r_length(res))
+			error("extract_resource(globdata) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res));
+		if (rtype != 0x11)
+			error("extract_resource(globdata) - resource tag is incorrect!");
+		writeUint32LE(output,(unsigned short)(rlen + 1));
+		writeUint16LE(output,'O0');	/* 0O - Object Index */
 		for (i = 5; i < rlen; i++)
-			write_byte(output,read_byte(input));
+			writeByte(output,readByte(input));
 		break;
 #ifdef MAKE_LFLS
 	case RES_ROOM:
@@ -796,10 +749,12 @@
 			rtype = read_cbyte(input,&i);
 			rid = read_cbyte(input,&i);
 /*
-			debug("room res len %04X, junk %02X, type %02X, id %02X",rlen,junk,rtype,rid);
+			notice("room res len %04X, junk %02X, type %02X, id %02X",rlen,junk,rtype,rid);
 */
-			_assert(rlen == r_length(res),"extract_resource(room) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res));
-			_assert(rtype == 0x01,"extract_resource(room) - resource tag is incorrect!");
+			if (rlen != r_length(res))
+				error("extract_resource(room) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res));
+			if (rtype != 0x01)
+				error("extract_resource(room) - resource tag is incorrect!");
 			off = ftell(output);
 			rlen = 0;
 			write_clong(output,0,&rlen);
@@ -809,7 +764,7 @@
 				unsigned short slen;
 				unsigned char stype;
 /* BM, HD, SL, NL, PA - current unknowns
-				debug("reading local resource at offset %04X of %04X",i,len);
+				notice("reading local resource at offset %04X of %04X",i,len);
 */
 				slen = read_cword(input,&i);
 				if (slen == 0xFFFF)
@@ -878,40 +833,44 @@
 					break;
 				default:
 					fseek(input,slen,SEEK_CUR);
-					debug("extract_resource(room) - unknown resource tag encountered: len %04X type %02X",slen,stype);
+					warning("extract_resource(room) - unknown resource tag encountered: len %04X type %02X",slen,stype);
 				}
 			}
 			fseek(output,off,SEEK_SET);
-			write_long(output,rlen);
+			writeUint32LE(output,rlen);
 			fseek(output,0,SEEK_END);
 		}
 		break;
 	case RES_SOUND:
-		_assert(FALSE,"extract_resource(sound) - sound resources are not supported!");
+		error("extract_resource(sound) - sound resources are not supported!");
 		break;
 	case RES_COSTUME:
 		rlen = read_cword(input,&i);
 		junk = read_cbyte(input,&i);
 		rtype = read_cbyte(input,&i);
 		rid = read_cbyte(input,&i);
-		_assert(rlen == r_length(res),"extract_resource(costume) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res));
-		_assert(rtype == 0x03,"extract_resource(costume) - resource tag is incorrect!");
-		write_long(output,(unsigned short)(rlen + 1));
-		write_word(output,'OC');	/* CO - Costume */
+		if (rlen != r_length(res))
+			error("extract_resource(costume) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res));
+		if (rtype != 0x03)
+			error("extract_resource(costume) - resource tag is incorrect!");
+		writeUint32LE(output,(unsigned short)(rlen + 1));
+		writeUint16LE(output,'OC');	/* CO - Costume */
 		for (i = 5; i < rlen; i++)
-			write_byte(output,read_byte(input));
+			writeByte(output,readByte(input));
 		break;
 	case RES_SCRIPT:
 		rlen = read_cword(input,&i);
 		junk = read_cbyte(input,&i);
 		rtype = read_cbyte(input,&i);
 		rid = read_cbyte(input,&i);
-		_assert(rlen == r_length(res),"extract_resource(script) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res));
-		_assert(rtype == 0x02,"extract_resource(script) - resource tag is incorrect!");
-		write_long(output,(unsigned short)(rlen + 1));
-		write_word(output,'CS');	/* SC - Script */
+		if (rlen != r_length(res))
+			error("extract_resource(script) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res));
+		if (rtype != 0x02)
+			error("extract_resource(script) - resource tag is incorrect!");
+		writeUint32LE(output,(unsigned short)(rlen + 1));
+		writeUint16LE(output,'CS');	/* SC - Script */
 		for (i = 5; i < rlen; i++)
-			write_byte(output,read_byte(input));
+			writeByte(output,readByte(input));
 		break;
 	case RES_UNKNOWN:
 #else
@@ -921,15 +880,16 @@
 	case RES_SCRIPT:
 	case RES_UNKNOWN:
 		rlen = read_word(input);
-		_assert(rlen == r_length(res),"extract_resource - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res));
-		write_word(output,rlen);
+		if (rlen != r_length(res))
+			error("extract_resource - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res));
+		writeUint16LE(output,rlen);
 		for (i = 2; i < rlen; i++)
-			write_byte(output,read_byte(input));
+			writeByte(output,readByte(input));
 		break;
 		break;
 #endif
 	default:
-		debug("extract_resource - unknown resource type %d specified!",res->type);
+		warning("extract_resource - unknown resource type %d specified!",res->type);
 	}
 }
 
@@ -1154,7 +1114,7 @@
 	len = ftell(file);
 	fseek(file,0,SEEK_SET);
 	for (i = 0; i < len; i++)
-		CRC = (CRC >> 8) ^ CRCtable[(CRC ^ read_byte(file)) & 0xFF];
+		CRC = (CRC >> 8) ^ CRCtable[(CRC ^ readByte(file)) & 0xFF];
 	return CRC ^ 0xFFFFFFFF;
 }
 
@@ -1179,7 +1139,7 @@
 	{
 	case 0x29EED3C5:
 		ISO = ISO_USA;
-		debug("ISO contents verified as Loom USA (track 2)");
+		notice("ISO contents verified as Loom USA (track 2)");
 		break;
 	default:
 		error("ISO contents not recognized!");
@@ -1194,7 +1154,7 @@
 		sprintf(fname,"%02i.LFL",lfl->num);
 		if (!(output = fopen(fname,"wb")))
 			error("Error: unable to create %s!",fname);
-		debug("Creating %s...",fname);
+		notice("Creating %s...",fname);
 		for (j = 0; lfl->entries[j] != NULL; j++)
 		{
 			p_resource entry = lfl->entries[j];
@@ -1217,7 +1177,7 @@
 				lfl_index.sound_addr[entry - res_sounds] = (unsigned short)ftell(output);
 				break;
 			default:
-				debug("Unknown resource type %d detected in LFL index!",entry->type);
+				notice("Unknown resource type %d detected in LFL index!",entry->type);
 				break;
 			}
 			extract_resource(input,output,entry);
@@ -1226,48 +1186,48 @@
 	}
 	if (!(output = fopen("00.LFL","wb")))
 		error("Error: unable to create index file!");
-	debug("Creating 00.LFL...");
+	notice("Creating 00.LFL...");
 
 	lfl_index.num_rooms = NUM_ROOMS;
 	lfl_index.num_costumes = NUM_COSTUMES;
 	lfl_index.num_scripts = NUM_SCRIPTS;
 	lfl_index.num_sounds = NUM_SOUNDS;
 
-	write_long(output,8+5*lfl_index.num_rooms);
-	write_word(output,'R0');	/* 0R - room index */
-	write_word(output,lfl_index.num_rooms);
+	writeUint32LE(output,8+5*lfl_index.num_rooms);
+	writeUint16LE(output,'R0');	/* 0R - room index */
+	writeUint16LE(output,lfl_index.num_rooms);
 	for (i = 0; i < lfl_index.num_rooms; i++)
 	{
-		write_byte(output,lfl_index.room_lfl[i]);
-		write_long(output,lfl_index.room_addr[i]);
+		writeByte(output,lfl_index.room_lfl[i]);
+		writeUint32LE(output,lfl_index.room_addr[i]);
 	}
 
-	write_long(output,8+5*lfl_index.num_scripts);
-	write_word(output,'S0');	/* 0S - script index */
-	write_word(output,lfl_index.num_scripts);
+	writeUint32LE(output,8+5*lfl_index.num_scripts);
+	writeUint16LE(output,'S0');	/* 0S - script index */
+	writeUint16LE(output,lfl_index.num_scripts);
 	for (i = 0; i < lfl_index.num_scripts; i++)
 	{
-		write_byte(output,lfl_index.script_lfl[i]);
-		write_long(output,lfl_index.script_addr[i]);
+		writeByte(output,lfl_index.script_lfl[i]);
+		writeUint32LE(output,lfl_index.script_addr[i]);
 	}
 
-	write_long(output,8+5*lfl_index.num_costumes);
-	write_word(output,'C0');	/* 0C - costume index */
-	write_word(output,lfl_index.num_costumes);
+	writeUint32LE(output,8+5*lfl_index.num_costumes);
+	writeUint16LE(output,'C0');	/* 0C - costume index */
+	writeUint16LE(output,lfl_index.num_costumes);
 	for (i = 0; i < lfl_index.num_costumes; i++)
 	{
-		write_byte(output,lfl_index.costume_lfl[i]);
-		write_long(output,lfl_index.costume_addr[i]);
+		writeByte(output,lfl_index.costume_lfl[i]);
+		writeUint32LE(output,lfl_index.costume_addr[i]);
 	}
 
 /*
-	write_long(output,8+5*lfl_index.num_sounds);
-	write_word(output,'N0');	0N - sounds index
-	write_word(output,lfl_index.num_sounds);
+	writeUint32LE(output,8+5*lfl_index.num_sounds);
+	writeUint16LE(output,'N0');	0N - sounds index
+	writeUint16LE(output,lfl_index.num_sounds);
 	for (i = 0; i < lfl_index.num_sounds; i++)
 	{
-		write_byte(output,lfl_index.sound_lfl[i]);
-		write_long(output,lfl_index.sound_addr[i]);
+		writeByte(output,lfl_index.sound_lfl[i]);
+		writeUint32LE(output,lfl_index.sound_addr[i]);
 	}
 */
 
@@ -1277,19 +1237,19 @@
 
 	if (!(output = fopen("97.LFL","wb")))
 		error("Error: unable to create charset file!");
-	debug("Creating 97.LFL...");
+	notice("Creating 97.LFL...");
 	extract_resource(input,output,&res_charset);
 	fclose(output);
 
 	if (!(output = fopen("98.LFL","wb")))
 		error("Error: unable to create charset file!");
-	debug("Creating 98.LFL...");
+	notice("Creating 98.LFL...");
 	extract_resource(input,output,&res_charset);
 	fclose(output);
 
 	if (!(output = fopen("99.LFL","wb")))
 		error("Error: unable to create charset file!");
-	debug("Creating 99.LFL...");
+	notice("Creating 99.LFL...");
 	extract_resource(input,output,&res_charset);
 	fclose(output);
 
@@ -1307,6 +1267,6 @@
 	for (i = 0; i < NUM_SOUNDS; i++)
 		dump_resource(input,"sound-%d.dmp",i,&res_sounds[i]);
 #endif	/* MAKE_LFLS */
-	debug("All done!");
+	notice("All done!");
 	return 0;
 }

Index: extract_mm_c64.c
===================================================================
RCS file: /cvsroot/scummvm/tools/extract_mm_c64.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- extract_mm_c64.c	17 May 2005 23:35:17 -0000	1.1
+++ extract_mm_c64.c	19 Jul 2005 23:38:30 -0000	1.2
@@ -28,64 +28,32 @@
 #define TRUE 1
 #define FALSE 0
 
-#ifdef WIN32
-	#define CDECL __cdecl
-#else
-	#define CDECL 
+#ifdef _MSC_VER
+	#define	vsnprintf _vsnprintf
 #endif
 
-void CDECL debug (const char *Text, ...)
+#ifdef MAKE_LFLS
+#define writeByte writeByteAlt
+#define writeUint16LE writeUint16LEAlt
+void writeByte(FILE *fp, uint8 b)
 {
-	va_list marker;
-	va_start(marker,Text);
-	vfprintf(stdout,Text,marker);
-	fprintf(stdout,"\n");
-	va_end(marker);
+	writeByteAlt(fp, (uint8)(b ^ 0xFF));
 }
-
-void CDECL error (const char *Text, ...)
+void writeUint16LE(FILE *fp, uint16 value)
 {
-	va_list marker;
-	va_start(marker,Text);
-	vfprintf(stderr,Text,marker);
-	fprintf(stderr,"\n");
-	va_end(marker);
-	exit(1);
+	writeUint16LEAlt(fp, (uint16)(value ^ 0xFFFF));
 }
+#endif
 
-void CDECL _assert (BOOL condition, const char *Text, ...)
-{
-	va_list marker;
-	if (condition)
-		return;
-	va_start(marker,Text);
-	vfprintf(stderr,Text,marker);
-	fprintf(stderr,"\n");
-	va_end(marker);
-	exit(1);
-}
+void notice(const char *s, ...) {
+	char buf[1024];
+	va_list va;
 
-unsigned char	read_byte (FILE *input)
-{
-	unsigned char val;
-	_assert(fread(&val,1,1,input) == 1,"read_byte - unexpected EOF");
-	return val;
-}
-unsigned short	read_word (FILE *input)
-{
-	unsigned short val;
-	_assert(fread(&val,2,1,input) == 1,"read_word - unexpected EOF");
-	return val;
-}
-void	write_byte (FILE *output, unsigned char val)
-{
-	val ^= 0xFF;
-	fwrite(&val,1,1,output);
-}
-void	write_word (FILE *output, unsigned short val)
-{
-	val ^= 0xFFFF;
-	fwrite(&val,2,1,output);
+	va_start(va, s);
+	vsnprintf(buf, 1024, s, va);
+	va_end(va);
+
+	fprintf(stdout, "%s\n", buf);
 }
 
 unsigned char room_disks[55], room_tracks[55], room_sectors[55];
@@ -109,51 +77,51 @@
 
 
 	/* check signature */
-	signature = read_word(input1);
+	signature = readUint16LE(input1);
 	if (signature != 0x0A31)
-		error("Error: signature not found in disk 1!\n");
-	signature = read_word(input2);
+		error("Signature not found in disk 1!");
+	signature = readUint16LE(input2);
 	if (signature != 0x0132)
-		error("Error: signature not found in disk 2!\n");
+		error("Signature not found in disk 2!");
 
 	if (!(output = fopen("00.LFL","wb")))
-		error("Error: unable to create index file!");
-	debug("Creating 00.LFL...");
+		error("Unable to create index file!");
+	notice("Creating 00.LFL...");
 
 	/* write signature */
-	write_word(output, signature);
+	writeUint16LE(output, signature);
 
 	/* copy object flags */
 	for (i = 0; i < 256; i++)
-		write_byte(output, read_byte(input1));
+		writeByte(output, readByte(input1));
 
 	/* copy room offsets */
 	for (i = 0; i < 55; i++)
 	{
-		room_disks[i] = read_byte(input1);
-		write_byte(output, room_disks[i]);
+		room_disks[i] = readByte(input1);
+		writeByte(output, room_disks[i]);
 	}
 	for (i = 0; i < 55; i++)
 	{
-		room_sectors[i] = read_byte(input1);
-		write_byte(output, room_sectors[i]);
-		room_tracks[i] = read_byte(input1);
-		write_byte(output, room_tracks[i]);
+		room_sectors[i] = readByte(input1);
+		writeByte(output, room_sectors[i]);
+		room_tracks[i] = readByte(input1);
+		writeByte(output, room_tracks[i]);
 	}
 	for (i = 0; i < 25; i++)
-		write_byte(output, read_byte(input1));
+		writeByte(output, readByte(input1));
 	for (i = 0; i < 25; i++)
-		write_word(output, read_word(input1));
+		writeUint16LE(output, readUint16LE(input1));
 
 	for (i = 0; i < 160; i++)
-		write_byte(output, read_byte(input1));
+		writeByte(output, readByte(input1));
 	for (i = 0; i < 160; i++)
-		write_word(output, read_word(input1));
+		writeUint16LE(output, readUint16LE(input1));
 
 	for (i = 0; i < 70; i++)
-		write_byte(output, read_byte(input1));
+		writeByte(output, readByte(input1));
 	for (i = 0; i < 70; i++)
-		write_word(output, read_word(input1));
+		writeUint16LE(output, readUint16LE(input1));
 	fclose(output);
 
 	for (i = 0; i < 55; i++)
@@ -183,19 +151,21 @@
 		else	continue;
 
 		sprintf(fname,"%02i.LFL", i);
-		printf("Creating %s...\n",fname);
 		output = fopen(fname, "wb");
+		if (output == NULL)
+			error("Unable to create %s!",fname);
+		notice("Creating %s...",fname);
 		fseek(input, (SectorOffset[room_tracks[i]] + room_sectors[i]) * 256, SEEK_SET);
 		for (j = 0; j < ResourcesPerFile[i]; j++)
 		{
-			unsigned short len = read_word(input);
-			write_word(output, len);
+			unsigned short len = readUint16LE(input);
+			writeUint16LE(output, len);
 			for (len -= 2; len > 0; len--)
-				write_byte(output, read_byte(input));
+				writeByte(output, readByte(input));
 		}
 		rewind(input);
 	}
 
-	debug("All done!");
+	notice("All done!");
 	return 0;
 }

Index: extract_mm_nes.c
===================================================================
RCS file: /cvsroot/scummvm/tools/extract_mm_nes.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- extract_mm_nes.c	19 Apr 2005 19:42:45 -0000	1.12
+++ extract_mm_nes.c	19 Jul 2005 23:38:30 -0000	1.13
@@ -19,10 +19,8 @@
  *
  */
 
-#include <stdio.h>
+#include "util.h"
 #include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
 
 typedef int BOOL;
 #define TRUE 1
@@ -32,68 +30,32 @@
 /* if not defined, dumps all resources to separate files */
 #define	MAKE_LFLS
 
-#ifdef WIN32
-	#define CDECL __cdecl
-#else
-	#define CDECL 
+#ifdef _MSC_VER
+	#define	vsnprintf _vsnprintf
 #endif
 
-void CDECL debug (const char *Text, ...)
+#ifdef MAKE_LFLS
+#define writeByte writeByteAlt
+#define writeUint16LE writeUint16LEAlt
+void writeByte(FILE *fp, uint8 b)
 {
-	va_list marker;
-	va_start(marker,Text);
-	vfprintf(stdout,Text,marker);
-	fprintf(stdout,"\n");
-	va_end(marker);
+	writeByteAlt(fp, (uint8)(b ^ 0xFF));
 }
-
-void CDECL error (const char *Text, ...)
+void writeUint16LE(FILE *fp, uint16 value)
 {
-	va_list marker;
-	va_start(marker,Text);
-	vfprintf(stderr,Text,marker);
-	fprintf(stderr,"\n");
-	va_end(marker);
-	exit(1);
+	writeUint16LEAlt(fp, (uint16)(value ^ 0xFFFF));
 }
+#endif
 
-void CDECL _assert (BOOL condition, const char *Text, ...)
-{
-	va_list marker;
-	if (condition)
-		return;
-	va_start(marker,Text);
-	vfprintf(stderr,Text,marker);
-	fprintf(stderr,"\n");
-	va_end(marker);
-	exit(1);
-}
+void notice(const char *s, ...) {
+	char buf[1024];
+	va_list va;
 
-unsigned char	read_byte (FILE *input)
-{
-	unsigned char val;
-	_assert(fread(&val,1,1,input) == 1,"read_byte - unexpected EOF");
-	return val;
-}
-unsigned short	read_word (FILE *input)
-{
-	unsigned short val;
-	_assert(fread(&val,2,1,input) == 1,"read_word - unexpected EOF");
-	return val;
-}
-void	write_byte (FILE *output, unsigned char val)
-{
-#ifdef	MAKE_LFLS
-	val ^= 0xFF;
-#endif
-	fwrite(&val,1,1,output);
-}
-void	write_word (FILE *output, unsigned short val)
-{
-#ifdef	MAKE_LFLS
-	val ^= 0xFFFF;
-#endif
-	fwrite(&val,2,1,output);
+	va_start(va, s);
+	vsnprintf(buf, 1024, s, va);
+	va_end(va);
+
+	fprintf(stdout, "%s\n", buf);
 }
 
 typedef enum _res_type { RES_UNKNOWN, RES_GLOBDATA, RES_ROOM, RES_SCRIPT, RES_SOUND, RES_COSTUME, RES_ROOMGFX, RES_COSTUMEGFX, RES_SPRPALS, RES_SPRDESC, RES_SPRLENS, RES_SPROFFS , RES_SPRDATA, RES_CHARSET, RES_PREPLIST } res_type;
@@ -104,8 +66,8 @@
 
 typedef	struct	_resource
 {
-	unsigned long offset[NUM_ROMSETS];
-	unsigned short length[NUM_ROMSETS];
+	uint32 offset[NUM_ROMSETS];
+	uint16 length[NUM_ROMSETS];
 	res_type type;
 }	t_resource, *p_resource;
 t_resource res_roomgfx[40] = {
@@ -531,22 +493,23 @@
 	{ {0x3FB5A,0x3FB90,0x3FBA9,0x3FBAF}, {0x000E,0x000E,0x000E,0x0010}, RES_PREPLIST };
 
 
-unsigned long r_offset (p_resource res)
+uint32 r_offset (p_resource res)
 {
 	return res->offset[ROMset];
 }
-unsigned short r_length (p_resource res)
+uint16 r_length (p_resource res)
 {
 	return res->length[ROMset];
 }
 
 void	extract_resource (FILE *input, FILE *output, p_resource res)
 {
-	unsigned short len, i, j;
-	unsigned char val;
-	unsigned char cnt;
+	uint16 len, i, j;
+	uint8 val;
+	uint8 cnt;
 
-	_assert(res != NULL,"extract_resource - no resource specified");
+	if (res == NULL)
+		error("extract_resource - no resource specified");
 	if ((r_offset(res) == 0) && (r_length(res) == 0))
 		return;	/* there are 8 scripts that are zero bytes long, so we should skip them */
 	fseek(input,16 + r_offset(res),SEEK_SET);
@@ -556,78 +519,81 @@
 	case RES_GLOBDATA:
 		len = r_length(res);
 		for (i = 0; i < len; i++)
-			write_byte(output,read_byte(input));
+			writeByte(output,readByte(input));
 		break;
 	case RES_ROOMGFX:
 	case RES_COSTUMEGFX:
-		write_word(output,(unsigned short)(r_length(res) + 2));
-		len = read_byte(input);
-		write_byte(output,(unsigned char)len);
+		writeUint16LE(output,(uint16)(r_length(res) + 2));
+		len = readByte(input);
+		writeByte(output,(uint8)len);
 		if (!len)
 			len = 256;
 		len = len << 4;
 		for (i = 0; i < len;)
 		{
-			write_byte(output,cnt = read_byte(input));
+			writeByte(output,cnt = readByte(input));
 			for (j = 0; j < (cnt & 0x7F); j++, i++)
 				if ((cnt & 0x80) || (j == 0))
-					write_byte(output,read_byte(input));
+					writeByte(output,readByte(input));
 		}
-		_assert(ftell(input) - r_offset(res) - 16 == r_length(res),"extract_resource - length mismatch while extracting graphics resource (was %04X, should be %04X)",ftell(input) - r_offset(res) - 16,r_length(res));
+		if (ftell(input) - r_offset(res) - 16 != r_length(res))
+			error("extract_resource - length mismatch while extracting graphics resource (was %04X, should be %04X)",ftell(input) - r_offset(res) - 16,r_length(res));
 		break;
 	case RES_ROOM:
 	case RES_SCRIPT:
-		len = read_word(input);
-		_assert(len == r_length(res),"extract_resource - length mismatch while extracting room/script resource (was %04X, should be %04X)",len,r_length(res));
+		len = readUint16LE(input);
+		if (len != r_length(res))
+			error("extract_resource - length mismatch while extracting room/script resource (was %04X, should be %04X)",len,r_length(res));
 		fseek(input,-2,SEEK_CUR);
 		for (i = 0; i < len; i++)
-			write_byte(output,read_byte(input));
+			writeByte(output,readByte(input));
 		break;
 	case RES_SOUND:
 		len = r_length(res) + 2;
-		val = read_byte(input);
-		cnt = read_byte(input);
+		val = readByte(input);
+		cnt = readByte(input);
 		if ((val == 2) && (cnt == 100))
 		{
-			write_word(output,len);
-			write_byte(output,val);
-			write_byte(output,cnt);
-			cnt = read_byte(input);
-			write_byte(output,cnt);
+			writeUint16LE(output,len);
+			writeByte(output,val);
+			writeByte(output,cnt);
+			cnt = readByte(input);
+			writeByte(output,cnt);
 			for (i = 0; i < cnt; i++)
-				write_byte(output,read_byte(input));
+				writeByte(output,readByte(input));
 			for (i = 0; i < cnt; i++)
-				write_byte(output,read_byte(input));
+				writeByte(output,readByte(input));
 			while (1)
 			{
-				write_byte(output,val = read_byte(input));
+				writeByte(output,val = readByte(input));
 				if (val >= 0xFE)
 					break;
 			}
 		}
 		else if (((val == 0) || (val == 1) || (val == 4)) && (cnt == 10))
 		{
-			write_word(output,len);
-			write_byte(output,val);
-			write_byte(output,cnt);
+			writeUint16LE(output,len);
+			writeByte(output,val);
+			writeByte(output,cnt);
 			while (1)
 			{
-				write_byte(output,val = read_byte(input));
+				writeByte(output,val = readByte(input));
 				if (val >= 0xFE)
 					break;
 				if (val >= 0x10)
-					write_byte(output,read_byte(input));
+					writeByte(output,readByte(input));
 				else
 				{
-					write_byte(output,read_byte(input));
-					write_byte(output,read_byte(input));
-					write_byte(output,read_byte(input));
-					write_byte(output,read_byte(input));
+					writeByte(output,readByte(input));
+					writeByte(output,readByte(input));
+					writeByte(output,readByte(input));
+					writeByte(output,readByte(input));
 				}
 			}
 		}
 		else	error("extract_resource - unknown sound type %d/%d detected",val,cnt);
-		_assert(ftell(input) - r_offset(res) - 16 == r_length(res),"extract_resource - length mismatch while extracting sound resource (was %04X, should be %04X)",ftell(input) - r_offset(res) - 16,r_length(res));
+		if (ftell(input) - r_offset(res) - 16 != r_length(res))
+			error("extract_resource - length mismatch while extracting sound resource (was %04X, should be %04X)",ftell(input) - r_offset(res) - 16,r_length(res));
 		break;
 	case RES_COSTUME:
 	case RES_SPRPALS:
@@ -637,23 +603,23 @@
 	case RES_SPRDATA:
 	case RES_CHARSET:
 		len = r_length(res);
-		write_word(output,(unsigned short)(len + 2));
+		writeUint16LE(output,(uint16)(len + 2));
 		for (i = 0; i < len; i++)
-			write_byte(output,read_byte(input));
+			writeByte(output,readByte(input));
 		break;
 	case RES_PREPLIST:
 		len = r_length(res);
-		write_word(output,0x002A);
-		write_byte(output,' ');
+		writeUint16LE(output,0x002A);
+		writeByte(output,' ');
 		for (i = 1; i < 8; i++)
-			write_byte(output,0);
+			writeByte(output,0);
 		for (j = 0; j < 4; j++)
 		{
-			write_byte(output,' ');
-			for (i = 1; (val = read_byte(input)); i++)
-				write_byte(output,val);
+			writeByte(output,' ');
+			for (i = 1; (val = readByte(input)); i++)
+				writeByte(output,val);
 			for (; i < 8; i++)
-				write_byte(output,0);
+				writeByte(output,0);
 		}
 		break;
 	default:
@@ -794,14 +760,14 @@
 #endif
 struct	_lfl_index
 {
-	unsigned char	room_lfl[55];
-	unsigned short	room_addr[55];
-	unsigned char	costume_lfl[80];
-	unsigned short	costume_addr[80];
-	unsigned char	script_lfl[200];
-	unsigned short	script_addr[200];
-	unsigned char	sound_lfl[100];
-	unsigned short	sound_addr[100];
+	uint8	room_lfl[55];
+	uint16	room_addr[55];
+	uint8	costume_lfl[80];
+	uint16	costume_addr[80];
+	uint8	script_lfl[200];
+	uint16	script_addr[200];
+	uint8	sound_lfl[100];
+	uint16	sound_addr[100];
 } GCC_PACK lfl_index;
 #if defined(_MSC_VER)
 #pragma	pack(pop)
@@ -814,18 +780,18 @@
 	sprintf(fname,fn_template,num);
 	if (!(output = fopen(fname,"wb")))
 		error("Error: unable to create %s!",fname);
-	debug("Extracting resource to %s",fname);
+	notice("Extracting resource to %s",fname);
 	extract_resource(input,output,res);
 	fclose(output);
 }
 #endif	/* MAKE_LFLS */
 
-unsigned long	CRCtable[256];
+uint32	CRCtable[256];
 void	InitCRC (void)
 {
-	const unsigned long poly = 0xEDB88320;
+	const uint32 poly = 0xEDB88320;
 	int i, j;
-	unsigned long n;
+	uint32 n;
 	for (i = 0; i < 256; i++)
 	{
 		n = i;
@@ -834,16 +800,16 @@
 		CRCtable[i] = n;
 	}
 }
-unsigned long	CheckROM (FILE *file)
+uint32	CheckROM (FILE *file)
 {
-	unsigned long CRC = 0xFFFFFFFF;
-	unsigned long i;
-	unsigned char header[16];
+	uint32 CRC = 0xFFFFFFFF;
+	uint32 i;
+	uint8 header[16];
 	fread(header,16,1,file);
 	if (memcmp("NES\x1A",header,4))
 		error("Selected file is not a valid NES ROM image!");
 	for (i = 0; i < header[4] << 14; i++)
-		CRC = (CRC >> 8) ^ CRCtable[(CRC ^ read_byte(file)) & 0xFF];
+		CRC = (CRC >> 8) ^ CRCtable[(CRC ^ readByte(file)) & 0xFF];
 	return CRC ^ 0xFFFFFFFF;
 }
 
@@ -852,7 +818,7 @@
 	FILE *input, *output;
 	char fname[256];
 	int i, j;
-	unsigned long CRC;
+	uint32 CRC;
 
 	if (argc < 2)
 	{
@@ -870,19 +836,19 @@
 	{
 	case 0x0D9F5BD1:
 		ROMset = ROMSET_USA;
-		debug("ROM contents verified as Maniac Mansion (USA)");
+		notice("ROM contents verified as Maniac Mansion (USA)");
 		break;
 	case 0xF59CFC3D:
 		ROMset = ROMSET_EUROPE;
-		debug("ROM contents verified as Maniac Mansion (Europe)");
+		notice("ROM contents verified as Maniac Mansion (Europe)");
 		break;
 	case 0x3F2BDA65:
 		ROMset = ROMSET_SWEDEN;
-		debug("ROM contents verified as Maniac Mansion (Sweden)");
+		notice("ROM contents verified as Maniac Mansion (Sweden)");
 		break;
 	case 0xF4B70BFE:
 		ROMset = ROMSET_FRANCE;
-		debug("ROM contents verified as Maniac Mansion (France)");
+		notice("ROM contents verified as Maniac Mansion (France)");
 		break;
 	case 0x3DA2085E:
 		error("Maniac Mansion (Japan) is not supported!");
@@ -900,7 +866,7 @@
 		sprintf(fname,"%02i.LFL",lfl->num);
 		if (!(output = fopen(fname,"wb")))
 			error("Error: unable to create %s!",fname);
-		debug("Creating %s...",fname);
+		notice("Creating %s...",fname);
 		for (j = 0; lfl->entries[j] != NULL; j++)
 		{
 			p_resource entry = lfl->entries[j];
@@ -908,55 +874,55 @@
 			{
 			case RES_ROOM:
 				lfl_index.room_lfl[entry - res_rooms] = lfl->num;
-				lfl_index.room_addr[entry - res_rooms] = (unsigned short)ftell(output);
+				lfl_index.room_addr[entry - res_rooms] = (uint16)ftell(output);
 				break;
 			case RES_COSTUME:
 				lfl_index.costume_lfl[entry - res_costumes] = lfl->num;
-				lfl_index.costume_addr[entry - res_costumes] = (unsigned short)ftell(output);
+				lfl_index.costume_addr[entry - res_costumes] = (uint16)ftell(output);
 				break;
 			case RES_SPRDESC:
 				lfl_index.costume_lfl[entry - res_sprdesc + 25] = lfl->num;
-				lfl_index.costume_addr[entry - res_sprdesc + 25] = (unsigned short)ftell(output);
+				lfl_index.costume_addr[entry - res_sprdesc + 25] = (uint16)ftell(output);
 				break;
 			case RES_SPRLENS:
 				lfl_index.costume_lfl[entry - res_sprlens + 27] = lfl->num;
-				lfl_index.costume_addr[entry - res_sprlens + 27] = (unsigned short)ftell(output);
+				lfl_index.costume_addr[entry - res_sprlens + 27] = (uint16)ftell(output);
 				break;
 			case RES_SPROFFS:
 				lfl_index.costume_lfl[entry - res_sproffs + 29] = lfl->num;
-				lfl_index.costume_addr[entry - res_sproffs + 29] = (unsigned short)ftell(output);
+				lfl_index.costume_addr[entry - res_sproffs + 29] = (uint16)ftell(output);
 				break;
 			case RES_SPRDATA:
 				lfl_index.costume_lfl[entry - res_sprdata + 31] = lfl->num;
-				lfl_index.costume_addr[entry - res_sprdata + 31] = (unsigned short)ftell(output);
+				lfl_index.costume_addr[entry - res_sprdata + 31] = (uint16)ftell(output);
 				break;
 			case RES_COSTUMEGFX:
 				lfl_index.costume_lfl[entry - res_costumegfx + 33] = lfl->num;
-				lfl_index.costume_addr[entry - res_costumegfx + 33] = (unsigned short)ftell(output);
+				lfl_index.costume_addr[entry - res_costumegfx + 33] = (uint16)ftell(output);
 				break;
 			case RES_SPRPALS:
 				lfl_index.costume_lfl[entry - res_sprpals + 35] = lfl->num;
-				lfl_index.costume_addr[entry - res_sprpals + 35] = (unsigned short)ftell(output);
+				lfl_index.costume_addr[entry - res_sprpals + 35] = (uint16)ftell(output);
 				break;
 			case RES_ROOMGFX:
 				lfl_index.costume_lfl[entry - res_roomgfx + 37] = lfl->num;
-				lfl_index.costume_addr[entry - res_roomgfx + 37] = (unsigned short)ftell(output);
+				lfl_index.costume_addr[entry - res_roomgfx + 37] = (uint16)ftell(output);
 				break;
 			case RES_SCRIPT:
 				lfl_index.script_lfl[entry - res_scripts] = lfl->num;
-				lfl_index.script_addr[entry - res_scripts] = (unsigned short)ftell(output);
+				lfl_index.script_addr[entry - res_scripts] = (uint16)ftell(output);
 				break;
 			case RES_SOUND:
 				lfl_index.sound_lfl[entry - res_sounds] = lfl->num;
-				lfl_index.sound_addr[entry - res_sounds] = (unsigned short)ftell(output);
+				lfl_index.sound_addr[entry - res_sounds] = (uint16)ftell(output);
 				break;
 			case RES_CHARSET:
 				lfl_index.costume_lfl[77] = lfl->num;
-				lfl_index.costume_addr[77] = (unsigned short)ftell(output);
+				lfl_index.costume_addr[77] = (uint16)ftell(output);
 				break;
 			case RES_PREPLIST:
 				lfl_index.costume_lfl[78] = lfl->num;
-				lfl_index.costume_addr[78] = (unsigned short)ftell(output);
+				lfl_index.costume_addr[78] = (uint16)ftell(output);
 				break;
 			default:
 				error("Unindexed entry found!");
@@ -964,16 +930,16 @@
 			}
 			extract_resource(input,output,entry);
 		}
-		write_word(output,0xF5D1);
+		writeUint16LE(output,0xF5D1);
 		fclose(output);
 	}
 	if (!(output = fopen("00.LFL","wb")))
 		error("Error: unable to create index file!");
-	debug("Creating 00.LFL...");
-	write_word(output,0x4643);
+	notice("Creating 00.LFL...");
+	writeUint16LE(output,0x4643);
 	extract_resource(input,output,&res_globdata);
 	for (i = 0; i < (int)sizeof(lfl_index); i++)
-		write_byte(output,((unsigned char *)&lfl_index)[i]);
+		writeByte(output,((uint8 *)&lfl_index)[i]);
 	fclose(output);
 #else	/* !MAKE_LFLS */
 	dump_resource(input,"globdata.dmp",0,&res_globdata);
@@ -1000,7 +966,7 @@
 	for (i = 0; i < 2; i++)
 		dump_resource(input,"sproffs-%d.dmp",i,&res_sproffs[i]);
 #endif	/* MAKE_LFLS */
-	debug("All done!");
+	notice("All done!");
 
 	return 0;
 }

Index: extract_zak_c64.c
===================================================================
RCS file: /cvsroot/scummvm/tools/extract_zak_c64.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- extract_zak_c64.c	17 May 2005 23:35:17 -0000	1.1
+++ extract_zak_c64.c	19 Jul 2005 23:38:31 -0000	1.2
@@ -1,4 +1,4 @@
-/* MM_C64_Extract - Extract data files from C64 version of Maniac Mansion
+/* Zak_C64_Extract - Extract data files from C64 version of Zak McKracken
  * Copyright (C) 2004-2005  The ScummVM Team
  *
  * This program is free software; you can redistribute it and/or
@@ -28,64 +28,32 @@
 #define TRUE 1
 #define FALSE 0
 
-#ifdef WIN32
-	#define CDECL __cdecl
-#else
-	#define CDECL 
+#ifdef _MSC_VER
+	#define	vsnprintf _vsnprintf
 #endif
 
-void CDECL debug (const char *Text, ...)
+#ifdef MAKE_LFLS
+#define writeByte writeByteAlt
+#define writeUint16LE writeUint16LEAlt
+void writeByte(FILE *fp, uint8 b)
 {
-	va_list marker;
-	va_start(marker,Text);
-	vfprintf(stdout,Text,marker);
-	fprintf(stdout,"\n");
-	va_end(marker);
+	writeByteAlt(fp, (uint8)(b ^ 0xFF));
 }
-
-void CDECL error (const char *Text, ...)
+void writeUint16LE(FILE *fp, uint16 value)
 {
-	va_list marker;
-	va_start(marker,Text);
-	vfprintf(stderr,Text,marker);
-	fprintf(stderr,"\n");
-	va_end(marker);
-	exit(1);
+	writeUint16LEAlt(fp, (uint16)(value ^ 0xFFFF));
 }
+#endif
 
-void CDECL _assert (BOOL condition, const char *Text, ...)
-{
-	va_list marker;
-	if (condition)
-		return;
-	va_start(marker,Text);
-	vfprintf(stderr,Text,marker);
-	fprintf(stderr,"\n");
-	va_end(marker);
-	exit(1);
-}
+void notice(const char *s, ...) {
+	char buf[1024];
+	va_list va;
 
-unsigned char	read_byte (FILE *input)
-{
-	unsigned char val;
-	_assert(fread(&val,1,1,input) == 1,"read_byte - unexpected EOF");
-	return val;
-}
-unsigned short	read_word (FILE *input)
-{
-	unsigned short val;
-	_assert(fread(&val,2,1,input) == 1,"read_word - unexpected EOF");
-	return val;
-}
-void	write_byte (FILE *output, unsigned char val)
-{
-	val ^= 0xFF;
-	fwrite(&val,1,1,output);
-}
-void	write_word (FILE *output, unsigned short val)
-{
-	val ^= 0xFFFF;
-	fwrite(&val,2,1,output);
+	va_start(va, s);
+	vsnprintf(buf, 1024, s, va);
+	va_end(va);
+
+	fprintf(stdout, "%s\n", buf);
 }
 
 unsigned char room_disks[59], room_tracks[59], room_sectors[59];
@@ -103,57 +71,57 @@
 		return 1;
 	}
 	if (!(input1 = fopen(argv[1],"rb")))
-		error("Error: unable to open file %s for input!",argv[1]);
+		error("Unable to open file %s for input!",argv[1]);
 	if (!(input2 = fopen(argv[2],"rb")))
-		error("Error: unable to open file %s for input!",argv[2]);
+		error("Unable to open file %s for input!",argv[2]);
 
 	/* check signature */
-	signature = read_word(input1);
+	signature = readUint16LE(input1);
 	if (signature != 0x0A31)
-		error("Error: signature not found in disk 1!\n");
-	signature = read_word(input2);
+		error("Signature not found in disk 1!");
+	signature = readUint16LE(input2);
 	if (signature != 0x0132)
-		error("Error: signature not found in disk 2!\n");
+		error("Signature not found in disk 2!");
 
 	if (!(output = fopen("00.LFL","wb")))
-		error("Error: unable to create index file!");
-	debug("Creating 00.LFL...");
+		error("Unable to create index file!");
+	notice("Creating 00.LFL...");
 
 	/* write signature */
-	write_word(output, signature);
+	writeUint16LE(output, signature);
 
 	/* copy object flags */
 	for (i = 0; i < 775; i++)
-		write_byte(output, read_byte(input1));
+		writeByte(output, readByte(input1));
 
 	/* copy room offsets */
 	for (i = 0; i < 59; i++)
 	{
-		room_disks[i] = read_byte(input1);
-		write_byte(output, room_disks[i]);
+		room_disks[i] = readByte(input1);
+		writeByte(output, room_disks[i]);
 	}
 	for (i = 0; i < 59; i++)
 	{
-		room_sectors[i] = read_byte(input1);
-		room_tracks[i] = read_byte(input1);
-		write_byte(output, room_sectors[i]);
-		write_byte(output, room_tracks[i]);
+		room_sectors[i] = readByte(input1);
+		room_tracks[i] = readByte(input1);
+		writeByte(output, room_sectors[i]);
+		writeByte(output, room_tracks[i]);
 	}
 
 	for (i = 0; i < 38; i++)
-		write_byte(output, read_byte(input1));
+		writeByte(output, readByte(input1));
 	for (i = 0; i < 38; i++)
-		write_word(output, read_word(input1));
+		writeUint16LE(output, readUint16LE(input1));
 
 	for (i = 0; i < 155; i++)
-		write_byte(output, read_byte(input1));
+		writeByte(output, readByte(input1));
 	for (i = 0; i < 155; i++)
-		write_word(output, read_word(input1));
+		writeUint16LE(output, readUint16LE(input1));
 
 	for (i = 0; i < 127; i++)
-		write_byte(output, read_byte(input1));
+		writeByte(output, readByte(input1));
 	for (i = 0; i < 127; i++)
-		write_word(output, read_word(input1));
+		writeUint16LE(output, readUint16LE(input1));
 	fclose(output);
 
 	for (i = 0; i < 59; i++)
@@ -183,19 +151,21 @@
 		else	continue;
 
 		sprintf(fname,"%02i.LFL", i);
-		printf("Creating %s...\n",fname);
 		output = fopen(fname, "wb");
+		if (output == NULL)
+			error("Unable to create %s!",fname);
+		notice("Creating %s...",fname);
 		fseek(input, (SectorOffset[room_tracks[i]] + room_sectors[i]) * 256, SEEK_SET);
 		for (j = 0; j < ResourcesPerFile[i]; j++)
 		{
-			unsigned short len = read_word(input);
-			write_word(output, len);
+			unsigned short len = readUint16LE(input);
+			writeUint16LE(output, len);
 			for (len -= 2; len > 0; len--)
-				write_byte(output, read_byte(input));
+				writeByte(output, readByte(input));
 		}
 		rewind(input);
 	}
 
-	debug("All done!");
+	notice("All done!");
 	return 0;
 }

Index: util.c
===================================================================
RCS file: /cvsroot/scummvm/tools/util.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- util.c	13 Apr 2005 06:49:01 -0000	1.8
+++ util.c	19 Jul 2005 23:38:31 -0000	1.9
@@ -22,6 +22,10 @@
 #include "util.h"
 #include <stdarg.h>
 
+#ifdef _MSC_VER
+	#define	vsnprintf _vsnprintf
+#endif
+
 void error(const char *s, ...) {
 	char buf[1024];
 	va_list va;





More information about the Scummvm-git-logs mailing list