[Scummvm-cvs-logs] SF.net SVN: scummvm: [29429] tools/trunk
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Tue Nov 6 11:19:31 CET 2007
Revision: 29429
http://scummvm.svn.sourceforge.net/scummvm/?rev=29429&view=rev
Author: fingolfin
Date: 2007-11-06 02:19:31 -0800 (Tue, 06 Nov 2007)
Log Message:
-----------
Moved notices() helper function to util.*; unified some code in the extract_(mm|zak)* utils
Modified Paths:
--------------
tools/trunk/extract_loom_tg16.c
tools/trunk/extract_mm_apple.c
tools/trunk/extract_mm_c64.c
tools/trunk/extract_mm_nes.c
tools/trunk/extract_zak_c64.c
tools/trunk/util.c
tools/trunk/util.h
Modified: tools/trunk/extract_loom_tg16.c
===================================================================
--- tools/trunk/extract_loom_tg16.c 2007-11-06 09:44:54 UTC (rev 29428)
+++ tools/trunk/extract_loom_tg16.c 2007-11-06 10:19:31 UTC (rev 29429)
@@ -30,22 +30,6 @@
/* if not defined, dumps all resources to separate files */
#define MAKE_LFLS
-
-#ifdef _MSC_VER
- #define vsnprintf _vsnprintf
-#endif
-
-void notice(const char *s, ...) {
- char buf[1024];
- va_list va;
-
- va_start(va, s);
- vsnprintf(buf, 1024, s, va);
- va_end(va);
-
- fprintf(stdout, "%s\n", buf);
-}
-
uint8 read_cbyte (FILE *input, short *ctr) {
(*ctr) += 1;
return readByte(input);
Modified: tools/trunk/extract_mm_apple.c
===================================================================
--- tools/trunk/extract_mm_apple.c 2007-11-06 09:44:54 UTC (rev 29428)
+++ tools/trunk/extract_mm_apple.c 2007-11-06 10:19:31 UTC (rev 29429)
@@ -23,10 +23,6 @@
#include "util.h"
#include <stdarg.h>
-#ifdef _MSC_VER
- #define vsnprintf _vsnprintf
-#endif
-
void writeByteAlt(FILE *fp, uint8 b) {
writeByte(fp, (uint8)(b ^ 0xFF));
}
@@ -36,19 +32,25 @@
#define writeByte writeByteAlt
#define writeUint16LE writeUint16LEAlt
-void notice(const char *s, ...) {
- char buf[1024];
- va_list va;
+#define NUM_ROOMS 55
- va_start(va, s);
- vsnprintf(buf, 1024, s, va);
- va_end(va);
+unsigned char room_disks[NUM_ROOMS], room_tracks[NUM_ROOMS], room_sectors[NUM_ROOMS];
- fprintf(stdout, "%s\n", buf);
-}
+static const int SectorOffset[36] = {
+ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256,
+ 272, 288, 304, 320, 336, 352, 368,
+ 384, 400, 416, 432, 448, 464,
+ 480, 496, 512, 528, 544, 560
+};
+static const int ResourcesPerFile[NUM_ROOMS] = {
+ 0, 11, 1, 3, 9, 12, 1, 13, 10, 6,
+ 4, 1, 7, 1, 1, 2, 7, 8, 19, 9,
+ 6, 9, 2, 6, 8, 4, 16, 8, 3, 3,
+ 12, 12, 2, 8, 1, 1, 2, 1, 9, 1,
+ 3, 7, 3, 3, 13, 5, 4, 3, 1, 1,
+ 3, 10, 1, 0, 0
+};
-unsigned char room_disks[55], room_tracks[55], room_sectors[55];
-
int main (int argc, char **argv) {
FILE *input1, *input2, *output;
char fname[256];
@@ -60,9 +62,9 @@
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]);
fseek(input1, 142080, SEEK_SET);
fseek(input2, 143104, SEEK_SET);
@@ -87,11 +89,11 @@
writeByte(output, readByte(input1));
/* copy room offsets */
- for (i = 0; i < 55; i++) {
+ for (i = 0; i < NUM_ROOMS; i++) {
room_disks[i] = readByte(input1);
writeByte(output, room_disks[i]);
}
- for (i = 0; i < 55; i++) {
+ for (i = 0; i < NUM_ROOMS; i++) {
room_sectors[i] = readByte(input1);
writeByte(output, room_sectors[i]);
room_tracks[i] = readByte(input1);
@@ -120,27 +122,14 @@
fclose(output);
- for (i = 0; i < 55; i++) {
- const int SectorOffset[36] = {
- 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256,
- 272, 288, 304, 320, 336, 352, 368,
- 384, 400, 416, 432, 448, 464,
- 480, 496, 512, 528, 544, 560
- };
- const int ResourcesPerFile[55] = {
- 0, 11, 1, 3, 9, 12, 1, 13, 10, 6,
- 4, 1, 7, 1, 1, 2, 7, 8, 19, 9,
- 6, 9, 2, 6, 8, 4, 16, 8, 3, 3,
- 12, 12, 2, 8, 1, 1, 2, 1, 9, 1,
- 3, 7, 3, 3, 13, 5, 4, 3, 1, 1,
- 3, 10, 1, 0, 0
- };
+ for (i = 0; i < NUM_ROOMS; i++) {
FILE *input;
if (room_disks[i] == '1')
input = input1;
else if (room_disks[i] == '2')
input = input2;
- else continue;
+ else
+ continue;
sprintf(fname,"%02i.LFL", i);
output = fopen(fname, "wb");
Modified: tools/trunk/extract_mm_c64.c
===================================================================
--- tools/trunk/extract_mm_c64.c 2007-11-06 09:44:54 UTC (rev 29428)
+++ tools/trunk/extract_mm_c64.c 2007-11-06 10:19:31 UTC (rev 29429)
@@ -23,10 +23,6 @@
#include "util.h"
#include <stdarg.h>
-#ifdef _MSC_VER
- #define vsnprintf _vsnprintf
-#endif
-
void writeByteAlt(FILE *fp, uint8 b) {
writeByte(fp, (uint8)(b ^ 0xFF));
}
@@ -36,19 +32,26 @@
#define writeByte writeByteAlt
#define writeUint16LE writeUint16LEAlt
-void notice(const char *s, ...) {
- char buf[1024];
- va_list va;
+#define NUM_ROOMS 55
- va_start(va, s);
- vsnprintf(buf, 1024, s, va);
- va_end(va);
+unsigned char room_disks[NUM_ROOMS], room_tracks[NUM_ROOMS], room_sectors[NUM_ROOMS];
- fprintf(stdout, "%s\n", buf);
-}
+static const int SectorOffset[36] = {
+ 0,
+ 0, 21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 273, 294, 315, 336,
+ 357, 376, 395, 414, 433, 452, 471,
+ 490, 508, 526, 544, 562, 580,
+ 598, 615, 632, 649, 666
+};
+static const int ResourcesPerFile[NUM_ROOMS] = {
+ 0, 11, 1, 3, 9, 12, 1, 13, 10, 6,
+ 4, 1, 7, 1, 1, 2, 7, 8, 19, 9,
+ 6, 9, 2, 6, 8, 4, 16, 8, 3, 3,
+ 12, 12, 2, 8, 1, 1, 2, 1, 9, 1,
+ 3, 7, 3, 3, 13, 5, 4, 3, 1, 1,
+ 3, 10, 1, 0, 0
+};
-unsigned char room_disks[55], room_tracks[55], room_sectors[55];
-
int main (int argc, char **argv) {
FILE *input1, *input2, *output;
char fname[256];
@@ -60,11 +63,10 @@
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 = readUint16LE(input1);
if (signature != 0x0A31)
@@ -85,11 +87,11 @@
writeByte(output, readByte(input1));
/* copy room offsets */
- for (i = 0; i < 55; i++) {
+ for (i = 0; i < NUM_ROOMS; i++) {
room_disks[i] = readByte(input1);
writeByte(output, room_disks[i]);
}
- for (i = 0; i < 55; i++) {
+ for (i = 0; i < NUM_ROOMS; i++) {
room_sectors[i] = readByte(input1);
writeByte(output, room_sectors[i]);
room_tracks[i] = readByte(input1);
@@ -116,28 +118,14 @@
fclose(output);
- for (i = 0; i < 55; i++) {
- const int SectorOffset[36] = {
- 0,
- 0, 21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 273, 294, 315, 336,
- 357, 376, 395, 414, 433, 452, 471,
- 490, 508, 526, 544, 562, 580,
- 598, 615, 632, 649, 666
- };
- const int ResourcesPerFile[55] = {
- 0, 11, 1, 3, 9, 12, 1, 13, 10, 6,
- 4, 1, 7, 1, 1, 2, 7, 8, 19, 9,
- 6, 9, 2, 6, 8, 4, 16, 8, 3, 3,
- 12, 12, 2, 8, 1, 1, 2, 1, 9, 1,
- 3, 7, 3, 3, 13, 5, 4, 3, 1, 1,
- 3, 10, 1, 0, 0
- };
+ for (i = 0; i < NUM_ROOMS; i++) {
FILE *input;
if (room_disks[i] == '1')
input = input1;
else if (room_disks[i] == '2')
input = input2;
- else continue;
+ else
+ continue;
sprintf(fname,"%02i.LFL", i);
output = fopen(fname, "wb");
Modified: tools/trunk/extract_mm_nes.c
===================================================================
--- tools/trunk/extract_mm_nes.c 2007-11-06 09:44:54 UTC (rev 29428)
+++ tools/trunk/extract_mm_nes.c 2007-11-06 10:19:31 UTC (rev 29429)
@@ -27,10 +27,6 @@
/* if not defined, dumps all resources to separate files */
#define MAKE_LFLS
-#ifdef _MSC_VER
- #define vsnprintf _vsnprintf
-#endif
-
#ifdef MAKE_LFLS
void writeByteAlt(FILE *fp, uint8 b) {
writeByte(fp, (uint8)(b ^ 0xFF));
@@ -42,17 +38,6 @@
#define writeUint16LE writeUint16LEAlt
#endif
-void notice(const char *s, ...) {
- char buf[1024];
- va_list va;
-
- va_start(va, s);
- vsnprintf(buf, 1024, s, va);
- va_end(va);
-
- fprintf(stdout, "%s\n", buf);
-}
-
typedef enum _res_type {
NES_UNKNOWN,
NES_GLOBDATA,
Modified: tools/trunk/extract_zak_c64.c
===================================================================
--- tools/trunk/extract_zak_c64.c 2007-11-06 09:44:54 UTC (rev 29428)
+++ tools/trunk/extract_zak_c64.c 2007-11-06 10:19:31 UTC (rev 29429)
@@ -23,10 +23,6 @@
#include "util.h"
#include <stdarg.h>
-#ifdef _MSC_VER
- #define vsnprintf _vsnprintf
-#endif
-
void writeByteAlt(FILE *fp, uint8 b) {
writeByte(fp, (uint8)(b ^ 0xFF));
}
@@ -36,19 +32,26 @@
#define writeByte writeByteAlt
#define writeUint16LE writeUint16LEAlt
-void notice(const char *s, ...) {
- char buf[1024];
- va_list va;
+#define NUM_ROOMS 59
- va_start(va, s);
- vsnprintf(buf, 1024, s, va);
- va_end(va);
+unsigned char room_disks[NUM_ROOMS], room_tracks[NUM_ROOMS], room_sectors[NUM_ROOMS];
- fprintf(stdout, "%s\n", buf);
-}
+static const int SectorOffset[36] = {
+ 0,
+ 0, 21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 273, 294, 315, 336,
+ 357, 376, 395, 414, 433, 452, 471,
+ 490, 508, 526, 544, 562, 580,
+ 598, 615, 632, 649, 666
+};
+static const int ResourcesPerFile[NUM_ROOMS] = {
+ 0, 29, 12, 14, 13, 4, 4, 10, 7, 4,
+ 14, 19, 5, 4, 7, 6, 11, 9, 4, 4,
+ 1, 3, 3, 5, 1, 9, 4, 10, 13, 6,
+ 7, 10, 2, 6, 1, 11, 2, 5, 7, 1,
+ 7, 1, 4, 2, 8, 6, 6, 6, 4, 13,
+ 3, 1, 2, 1, 2, 1, 10, 1, 1
+};
-unsigned char room_disks[59], room_tracks[59], room_sectors[59];
-
int main (int argc, char **argv) {
FILE *input1, *input2, *output;
char fname[256];
@@ -84,14 +87,14 @@
writeByte(output, readByte(input1));
/* copy room offsets */
- for (i = 0; i < 59; i++) {
+ for (i = 0; i < NUM_ROOMS; i++) {
room_disks[i] = readByte(input1);
writeByte(output, room_disks[i]);
}
- for (i = 0; i < 59; i++) {
+ for (i = 0; i < NUM_ROOMS; i++) {
room_sectors[i] = readByte(input1);
- room_tracks[i] = readByte(input1);
writeByte(output, room_sectors[i]);
+ room_tracks[i] = readByte(input1);
writeByte(output, room_tracks[i]);
}
@@ -112,30 +115,17 @@
writeByte(output, readByte(input1));
for (i = 0; i < 127; i++)
writeUint16LE(output, readUint16LE(input1));
+
fclose(output);
- for (i = 0; i < 59; i++) {
- const int SectorOffset[36] = {
- 0,
- 0, 21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 273, 294, 315, 336,
- 357, 376, 395, 414, 433, 452, 471,
- 490, 508, 526, 544, 562, 580,
- 598, 615, 632, 649, 666
- };
- const int ResourcesPerFile[59] = {
- 0, 29, 12, 14, 13, 4, 4, 10, 7, 4,
- 14, 19, 5, 4, 7, 6, 11, 9, 4, 4,
- 1, 3, 3, 5, 1, 9, 4, 10, 13, 6,
- 7, 10, 2, 6, 1, 11, 2, 5, 7, 1,
- 7, 1, 4, 2, 8, 6, 6, 6, 4, 13,
- 3, 1, 2, 1, 2, 1, 10, 1, 1
- };
+ for (i = 0; i < NUM_ROOMS; i++) {
FILE *input;
if (room_disks[i] == '1')
input = input1;
else if (room_disks[i] == '2')
input = input2;
- else continue;
+ else
+ continue;
sprintf(fname,"%02i.LFL", i);
output = fopen(fname, "wb");
Modified: tools/trunk/util.c
===================================================================
--- tools/trunk/util.c 2007-11-06 09:44:54 UTC (rev 29428)
+++ tools/trunk/util.c 2007-11-06 10:19:31 UTC (rev 29429)
@@ -62,6 +62,17 @@
fprintf(stderr, "DEBUG: %s!\n", buf);
}
+void notice(const char *s, ...) {
+ char buf[1024];
+ va_list va;
+
+ va_start(va, s);
+ vsnprintf(buf, 1024, s, va);
+ va_end(va);
+
+ fprintf(stdout, "%s\n", buf);
+}
+
uint8 readByte(FILE *fp) {
return fgetc(fp);
}
Modified: tools/trunk/util.h
===================================================================
--- tools/trunk/util.h 2007-11-06 09:44:54 UTC (rev 29428)
+++ tools/trunk/util.h 2007-11-06 10:19:31 UTC (rev 29429)
@@ -228,6 +228,7 @@
void NORETURN_PRE error(const char *s, ...) NORETURN_POST;
void warning(const char *s, ...);
void debug(int level, const char *s, ...);
+void notice(const char *s, ...);
#if defined(__cplusplus)
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list