[Scummvm-cvs-logs] SF.net SVN: scummvm: [30963] scummvm/trunk/tools
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Mon Feb 25 15:13:13 CET 2008
Revision: 30963
http://scummvm.svn.sourceforge.net/scummvm/?rev=30963&view=rev
Author: fingolfin
Date: 2008-02-25 06:13:12 -0800 (Mon, 25 Feb 2008)
Log Message:
-----------
Moved tools to all-C++ code (ensures consistency of all code during compilation, and allows us to use advanced stuff, like code from common/, in the tools)
Added Paths:
-----------
scummvm/trunk/tools/create_igortbl/create_igortbl.cpp
scummvm/trunk/tools/create_kyradat/util.cpp
scummvm/trunk/tools/qtable/qtable.cpp
Removed Paths:
-------------
scummvm/trunk/tools/create_igortbl/create_igortbl.c
scummvm/trunk/tools/create_kyradat/util.c
scummvm/trunk/tools/qtable/qtable.c
Deleted: scummvm/trunk/tools/create_igortbl/create_igortbl.c
===================================================================
--- scummvm/trunk/tools/create_igortbl/create_igortbl.c 2008-02-25 14:10:17 UTC (rev 30962)
+++ scummvm/trunk/tools/create_igortbl/create_igortbl.c 2008-02-25 14:13:12 UTC (rev 30963)
@@ -1,290 +0,0 @@
-/* ScummVM Tools
- * Copyright (C) 2007 The ScummVM project
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-// HACK to allow building with the SDL backend on MinGW
-// see bug #1800764 "TOOLS: MinGW tools building broken"
-#ifdef main
-#undef main
-#endif // main
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include "../../engines/igor/resource_ids.h"
-
-/*
- uint32 : 'ITBL'
- uint32 : version/tag
- uint32 : offset to strings table
- uint8 : number of game versions
- repeat (number of game versions) {
- uint32 : borland overlay size
- uint32 : offset to resources table
- uint32 : offset to sounds table
- }
- repeat (number of resources tables) {
- uint16 : number of entries
- repeat (number of entries) {
- uint16 : id
- uint32 : offset
- uint32 : length
- }
- }
- repeat (number of sounds tables) {
- uint16 : number of entries
- repeat (number of entries) {
- uint32 : offset
- }
- }
- uint16 : number of strings
- repeat (number of strings) {
- uint8 : id
- uint8 : language (0:any, 1:english, 2:spanish)
- uint8 : strlen
- char[] : string
- }
-*/
-
-#define MAX_TABLES 10
-#define TABLE_SIZE(x) (sizeof(x)/sizeof(x[0]))
-
-typedef unsigned char uint8;
-typedef unsigned short uint16;
-typedef unsigned int uint32;
-
-struct ResourceEntry {
- int id;
- uint32 offs;
- uint32 size;
-};
-
-static struct ResourceEntry _resourceEntriesEngDemo100[] = {
-#include "resource_en_demo100.h"
-};
-
-static struct ResourceEntry _resourceEntriesEngDemo110[] = {
-#include "resource_en_demo110.h"
-};
-
-static struct ResourceEntry _resourceEntriesSpaCd[] = {
-#include "resource_sp_cdrom.h"
-};
-
-static struct {
- struct ResourceEntry *p;
- int count;
-} _resourceEntriesList[] = {
- { _resourceEntriesEngDemo100, TABLE_SIZE(_resourceEntriesEngDemo100) },
- { _resourceEntriesEngDemo110, TABLE_SIZE(_resourceEntriesEngDemo110) },
- { _resourceEntriesSpaCd, TABLE_SIZE(_resourceEntriesSpaCd) },
- { 0, 0 }
-};
-
-static const uint32 _soundEntriesEngDemo[] = {
-#include "fsd_en_demo.h"
-};
-
-static const uint32 _soundEntriesSpaCd[] = {
-#include "fsd_sp_cdrom.h"
-};
-
-static struct {
- const uint32 *p;
- int count;
-} _soundEntriesList[] = {
- { _soundEntriesEngDemo, TABLE_SIZE(_soundEntriesEngDemo) },
- { _soundEntriesSpaCd, TABLE_SIZE(_soundEntriesSpaCd) },
- { 0, 0 }
-};
-
-enum {
- STR_LANG_ANY = 0,
- STR_LANG_ENG = 1,
- STR_LANG_SPA = 2
-};
-
-struct StringEntry {
- int id;
- uint8 language;
- const char *str;
-};
-
-static struct StringEntry _stringEntries[] = {
-#include "strings.h"
-};
-
-struct GameVersion {
- uint32 borlandOverlaySize;
- struct ResourceEntry *resourceEntries;
- const uint32 *soundEntries;
-};
-
-static const struct GameVersion _gameVersions[] = {
- { 4086790, _resourceEntriesEngDemo100, _soundEntriesEngDemo },
- { 4094103, _resourceEntriesEngDemo110, _soundEntriesEngDemo },
- { 9115648, _resourceEntriesSpaCd, _soundEntriesSpaCd }
-};
-
-static const uint32 ITBL_TAG = 0x4954424C;
-static const uint32 CURRENT_VERSION = 4;
-static const uint32 DEFAULT_OFFSET = 0x12345678;
-
-struct TablePtrOffset {
- const void *p;
- uint32 offset;
-};
-
-static int _tablePtrOffsetCount = 0;
-struct TablePtrOffset _tablePtrOffset[MAX_TABLES];
-
-static void addPtrOffset(FILE *fp, const void *p) {
- assert(_tablePtrOffsetCount < MAX_TABLES);
- _tablePtrOffset[_tablePtrOffsetCount].p = p;
- _tablePtrOffset[_tablePtrOffsetCount].offset = ftell(fp);
- ++_tablePtrOffsetCount;
-}
-
-static uint32 getPtrOffset(const void *p) {
- int i;
- uint32 fileOffset = 0;
-
- for (i = 0; i < _tablePtrOffsetCount; ++i) {
- if (_tablePtrOffset[i].p == p) {
- fileOffset = _tablePtrOffset[i].offset;
- break;
- }
- }
- assert(fileOffset != 0);
- return fileOffset;
-}
-
-static void writeByte(FILE *fp, uint8 b) {
- fwrite(&b, 1, 1, fp);
-}
-
-static void writeUint16BE(FILE *fp, uint16 value) {
- writeByte(fp, (uint8)(value >> 8));
- writeByte(fp, (uint8)(value & 0xFF));
-}
-
-static void writeUint32BE(FILE *fp, uint32 value) {
- writeUint16BE(fp, (uint16)(value >> 16));
- writeUint16BE(fp, (uint16)(value & 0xFFFF));
-}
-
-int compareResourceEntry(const void *a, const void *b) {
- return ((struct ResourceEntry *)a)->id - ((struct ResourceEntry *)b)->id;
-}
-
-static void writeResourceEntriesTable(FILE *fp, struct ResourceEntry *re, int count) {
- int i;
-
- qsort(re, count, sizeof(struct ResourceEntry), compareResourceEntry);
- writeUint16BE(fp, count);
- for (i = 0; i < count; ++i, ++re) {
- writeUint16BE(fp, re->id);
- writeUint32BE(fp, re->offs);
- writeUint32BE(fp, re->size);
- }
-}
-
-static void writeSoundEntriesTable(FILE *fp, const uint32 *fsd, int count) {
- int i;
-
- writeUint16BE(fp, count);
- for (i = 0; i < count; ++i) {
- writeUint32BE(fp, fsd[i]);
- }
-}
-
-int compareStringEntry(const void *a, const void *b) {
- return ((struct StringEntry *)a)->id - ((struct StringEntry *)b)->id;
-}
-
-static void writeStringEntriesTable(FILE *fp, struct StringEntry *se, int count) {
- int i, len;
-
- qsort(se, count, sizeof(struct StringEntry), compareStringEntry);
- writeUint16BE(fp, count);
- for (i = 0; i < count; ++i, ++se) {
- writeUint16BE(fp, se->id);
- writeByte(fp, se->language);
- len = strlen(se->str);
- assert(len < 256);
- writeByte(fp, len);
- fwrite(se->str, 1, len, fp);
- }
-}
-
-static void createTableFile(FILE *fp) {
- int i, gameVersionsCount;
-
- gameVersionsCount = TABLE_SIZE(_gameVersions);
-
- /* header */
- writeUint32BE(fp, ITBL_TAG);
- writeUint32BE(fp, CURRENT_VERSION);
- writeUint32BE(fp, DEFAULT_OFFSET); /* strings table offset */
- writeByte(fp, gameVersionsCount);
-
- /* game versions */
- for (i = 0; i < gameVersionsCount; ++i) {
- writeUint32BE(fp, _gameVersions[i].borlandOverlaySize);
- writeUint32BE(fp, DEFAULT_OFFSET); /* resource table offset */
- writeUint32BE(fp, DEFAULT_OFFSET); /* sound table offset */
- }
-
- /* resources tables */
- for (i = 0; _resourceEntriesList[i].p; ++i) {
- addPtrOffset(fp, _resourceEntriesList[i].p);
- writeResourceEntriesTable(fp, _resourceEntriesList[i].p, _resourceEntriesList[i].count);
- }
-
- /* sounds tables */
- for (i = 0; _soundEntriesList[i].p; ++i) {
- addPtrOffset(fp, _soundEntriesList[i].p);
- writeSoundEntriesTable(fp, _soundEntriesList[i].p, _soundEntriesList[i].count);
- }
-
- /* strings table */
- addPtrOffset(fp, _stringEntries);
- writeStringEntriesTable(fp, _stringEntries, TABLE_SIZE(_stringEntries));
-
- /* fix offsets */
- fseek(fp, 8, SEEK_SET);
- writeUint32BE(fp, getPtrOffset(_stringEntries));
- for (i = 0; i < gameVersionsCount; ++i) {
- fseek(fp, 17 + i * 12, SEEK_SET);
- writeUint32BE(fp, getPtrOffset(_gameVersions[i].resourceEntries));
- writeUint32BE(fp, getPtrOffset(_gameVersions[i].soundEntries));
- }
-}
-
-int main(int argc, char *argv[]) {
- FILE *fp = fopen("IGOR.TBL", "wb");
- if (fp) {
- createTableFile(fp);
- fclose(fp);
- }
- return 0;
-}
Copied: scummvm/trunk/tools/create_igortbl/create_igortbl.cpp (from rev 30962, scummvm/trunk/tools/create_igortbl/create_igortbl.c)
===================================================================
--- scummvm/trunk/tools/create_igortbl/create_igortbl.cpp (rev 0)
+++ scummvm/trunk/tools/create_igortbl/create_igortbl.cpp 2008-02-25 14:13:12 UTC (rev 30963)
@@ -0,0 +1,290 @@
+/* ScummVM Tools
+ * Copyright (C) 2007 The ScummVM project
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+// HACK to allow building with the SDL backend on MinGW
+// see bug #1800764 "TOOLS: MinGW tools building broken"
+#ifdef main
+#undef main
+#endif // main
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "../../engines/igor/resource_ids.h"
+
+/*
+ uint32 : 'ITBL'
+ uint32 : version/tag
+ uint32 : offset to strings table
+ uint8 : number of game versions
+ repeat (number of game versions) {
+ uint32 : borland overlay size
+ uint32 : offset to resources table
+ uint32 : offset to sounds table
+ }
+ repeat (number of resources tables) {
+ uint16 : number of entries
+ repeat (number of entries) {
+ uint16 : id
+ uint32 : offset
+ uint32 : length
+ }
+ }
+ repeat (number of sounds tables) {
+ uint16 : number of entries
+ repeat (number of entries) {
+ uint32 : offset
+ }
+ }
+ uint16 : number of strings
+ repeat (number of strings) {
+ uint8 : id
+ uint8 : language (0:any, 1:english, 2:spanish)
+ uint8 : strlen
+ char[] : string
+ }
+*/
+
+#define MAX_TABLES 10
+#define TABLE_SIZE(x) (sizeof(x)/sizeof(x[0]))
+
+typedef unsigned char uint8;
+typedef unsigned short uint16;
+typedef unsigned int uint32;
+
+struct ResourceEntry {
+ int id;
+ uint32 offs;
+ uint32 size;
+};
+
+static struct ResourceEntry _resourceEntriesEngDemo100[] = {
+#include "resource_en_demo100.h"
+};
+
+static struct ResourceEntry _resourceEntriesEngDemo110[] = {
+#include "resource_en_demo110.h"
+};
+
+static struct ResourceEntry _resourceEntriesSpaCd[] = {
+#include "resource_sp_cdrom.h"
+};
+
+static struct {
+ struct ResourceEntry *p;
+ int count;
+} _resourceEntriesList[] = {
+ { _resourceEntriesEngDemo100, TABLE_SIZE(_resourceEntriesEngDemo100) },
+ { _resourceEntriesEngDemo110, TABLE_SIZE(_resourceEntriesEngDemo110) },
+ { _resourceEntriesSpaCd, TABLE_SIZE(_resourceEntriesSpaCd) },
+ { 0, 0 }
+};
+
+static const uint32 _soundEntriesEngDemo[] = {
+#include "fsd_en_demo.h"
+};
+
+static const uint32 _soundEntriesSpaCd[] = {
+#include "fsd_sp_cdrom.h"
+};
+
+static struct {
+ const uint32 *p;
+ int count;
+} _soundEntriesList[] = {
+ { _soundEntriesEngDemo, TABLE_SIZE(_soundEntriesEngDemo) },
+ { _soundEntriesSpaCd, TABLE_SIZE(_soundEntriesSpaCd) },
+ { 0, 0 }
+};
+
+enum {
+ STR_LANG_ANY = 0,
+ STR_LANG_ENG = 1,
+ STR_LANG_SPA = 2
+};
+
+struct StringEntry {
+ int id;
+ uint8 language;
+ const char *str;
+};
+
+static struct StringEntry _stringEntries[] = {
+#include "strings.h"
+};
+
+struct GameVersion {
+ uint32 borlandOverlaySize;
+ struct ResourceEntry *resourceEntries;
+ const uint32 *soundEntries;
+};
+
+static const struct GameVersion _gameVersions[] = {
+ { 4086790, _resourceEntriesEngDemo100, _soundEntriesEngDemo },
+ { 4094103, _resourceEntriesEngDemo110, _soundEntriesEngDemo },
+ { 9115648, _resourceEntriesSpaCd, _soundEntriesSpaCd }
+};
+
+static const uint32 ITBL_TAG = 0x4954424C;
+static const uint32 CURRENT_VERSION = 4;
+static const uint32 DEFAULT_OFFSET = 0x12345678;
+
+struct TablePtrOffset {
+ const void *p;
+ uint32 offset;
+};
+
+static int _tablePtrOffsetCount = 0;
+struct TablePtrOffset _tablePtrOffset[MAX_TABLES];
+
+static void addPtrOffset(FILE *fp, const void *p) {
+ assert(_tablePtrOffsetCount < MAX_TABLES);
+ _tablePtrOffset[_tablePtrOffsetCount].p = p;
+ _tablePtrOffset[_tablePtrOffsetCount].offset = ftell(fp);
+ ++_tablePtrOffsetCount;
+}
+
+static uint32 getPtrOffset(const void *p) {
+ int i;
+ uint32 fileOffset = 0;
+
+ for (i = 0; i < _tablePtrOffsetCount; ++i) {
+ if (_tablePtrOffset[i].p == p) {
+ fileOffset = _tablePtrOffset[i].offset;
+ break;
+ }
+ }
+ assert(fileOffset != 0);
+ return fileOffset;
+}
+
+static void writeByte(FILE *fp, uint8 b) {
+ fwrite(&b, 1, 1, fp);
+}
+
+static void writeUint16BE(FILE *fp, uint16 value) {
+ writeByte(fp, (uint8)(value >> 8));
+ writeByte(fp, (uint8)(value & 0xFF));
+}
+
+static void writeUint32BE(FILE *fp, uint32 value) {
+ writeUint16BE(fp, (uint16)(value >> 16));
+ writeUint16BE(fp, (uint16)(value & 0xFFFF));
+}
+
+int compareResourceEntry(const void *a, const void *b) {
+ return ((struct ResourceEntry *)a)->id - ((struct ResourceEntry *)b)->id;
+}
+
+static void writeResourceEntriesTable(FILE *fp, struct ResourceEntry *re, int count) {
+ int i;
+
+ qsort(re, count, sizeof(struct ResourceEntry), compareResourceEntry);
+ writeUint16BE(fp, count);
+ for (i = 0; i < count; ++i, ++re) {
+ writeUint16BE(fp, re->id);
+ writeUint32BE(fp, re->offs);
+ writeUint32BE(fp, re->size);
+ }
+}
+
+static void writeSoundEntriesTable(FILE *fp, const uint32 *fsd, int count) {
+ int i;
+
+ writeUint16BE(fp, count);
+ for (i = 0; i < count; ++i) {
+ writeUint32BE(fp, fsd[i]);
+ }
+}
+
+int compareStringEntry(const void *a, const void *b) {
+ return ((struct StringEntry *)a)->id - ((struct StringEntry *)b)->id;
+}
+
+static void writeStringEntriesTable(FILE *fp, struct StringEntry *se, int count) {
+ int i, len;
+
+ qsort(se, count, sizeof(struct StringEntry), compareStringEntry);
+ writeUint16BE(fp, count);
+ for (i = 0; i < count; ++i, ++se) {
+ writeUint16BE(fp, se->id);
+ writeByte(fp, se->language);
+ len = strlen(se->str);
+ assert(len < 256);
+ writeByte(fp, len);
+ fwrite(se->str, 1, len, fp);
+ }
+}
+
+static void createTableFile(FILE *fp) {
+ int i, gameVersionsCount;
+
+ gameVersionsCount = TABLE_SIZE(_gameVersions);
+
+ /* header */
+ writeUint32BE(fp, ITBL_TAG);
+ writeUint32BE(fp, CURRENT_VERSION);
+ writeUint32BE(fp, DEFAULT_OFFSET); /* strings table offset */
+ writeByte(fp, gameVersionsCount);
+
+ /* game versions */
+ for (i = 0; i < gameVersionsCount; ++i) {
+ writeUint32BE(fp, _gameVersions[i].borlandOverlaySize);
+ writeUint32BE(fp, DEFAULT_OFFSET); /* resource table offset */
+ writeUint32BE(fp, DEFAULT_OFFSET); /* sound table offset */
+ }
+
+ /* resources tables */
+ for (i = 0; _resourceEntriesList[i].p; ++i) {
+ addPtrOffset(fp, _resourceEntriesList[i].p);
+ writeResourceEntriesTable(fp, _resourceEntriesList[i].p, _resourceEntriesList[i].count);
+ }
+
+ /* sounds tables */
+ for (i = 0; _soundEntriesList[i].p; ++i) {
+ addPtrOffset(fp, _soundEntriesList[i].p);
+ writeSoundEntriesTable(fp, _soundEntriesList[i].p, _soundEntriesList[i].count);
+ }
+
+ /* strings table */
+ addPtrOffset(fp, _stringEntries);
+ writeStringEntriesTable(fp, _stringEntries, TABLE_SIZE(_stringEntries));
+
+ /* fix offsets */
+ fseek(fp, 8, SEEK_SET);
+ writeUint32BE(fp, getPtrOffset(_stringEntries));
+ for (i = 0; i < gameVersionsCount; ++i) {
+ fseek(fp, 17 + i * 12, SEEK_SET);
+ writeUint32BE(fp, getPtrOffset(_gameVersions[i].resourceEntries));
+ writeUint32BE(fp, getPtrOffset(_gameVersions[i].soundEntries));
+ }
+}
+
+int main(int argc, char *argv[]) {
+ FILE *fp = fopen("IGOR.TBL", "wb");
+ if (fp) {
+ createTableFile(fp);
+ fclose(fp);
+ }
+ return 0;
+}
Deleted: scummvm/trunk/tools/create_kyradat/util.c
===================================================================
--- scummvm/trunk/tools/create_kyradat/util.c 2008-02-25 14:10:17 UTC (rev 30962)
+++ scummvm/trunk/tools/create_kyradat/util.c 2008-02-25 14:13:12 UTC (rev 30963)
@@ -1,137 +0,0 @@
-/* Scumm Tools
- * Copyright (C) 2003-2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "util.h"
-#include <stdarg.h>
-
-#ifdef _MSC_VER
- #define vsnprintf _vsnprintf
-#endif
-
-void error(const char *s, ...) {
- char buf[1024];
- va_list va;
-
- va_start(va, s);
- vsnprintf(buf, 1024, s, va);
- va_end(va);
-
- fprintf(stderr, "ERROR: %s!\n", buf);
-
- exit(1);
-}
-
-void warning(const char *s, ...) {
- char buf[1024];
- va_list va;
-
- va_start(va, s);
- vsnprintf(buf, 1024, s, va);
- va_end(va);
-
- fprintf(stderr, "WARNING: %s!\n", buf);
-}
-
-void debug(int level, const char *s, ...) {
- char buf[1024];
- va_list va;
-
- va_start(va, s);
- vsnprintf(buf, 1024, s, va);
- va_end(va);
-
- fprintf(stderr, "DEBUG: %s!\n", buf);
-}
-
-uint8 readByte(FILE *fp) {
- return fgetc(fp);
-}
-
-uint16 readUint16BE(FILE *fp) {
- uint16 ret = 0;
- ret |= fgetc(fp) << 8;
- ret |= fgetc(fp);
- return ret;
-}
-
-uint16 readUint16LE(FILE *fp) {
- uint16 ret = 0;
- ret |= fgetc(fp);
- ret |= fgetc(fp) << 8;
- return ret;
-}
-
-uint32 readUint32BE(FILE *fp) {
- uint32 ret = 0;
- ret |= fgetc(fp) << 24;
- ret |= fgetc(fp) << 16;
- ret |= fgetc(fp) << 8;
- ret |= fgetc(fp);
- return ret;
-}
-
-uint32 readUint32LE(FILE *fp) {
- uint32 ret = 0;
- ret |= fgetc(fp);
- ret |= fgetc(fp) << 8;
- ret |= fgetc(fp) << 16;
- ret |= fgetc(fp) << 24;
- return ret;
-}
-
-void writeByte(FILE *fp, uint8 b) {
- fwrite(&b, 1, 1, fp);
-}
-
-void writeUint16BE(FILE *fp, uint16 value) {
- writeByte(fp, (uint8)(value >> 8));
- writeByte(fp, (uint8)(value));
-}
-
-void writeUint16LE(FILE *fp, uint16 value) {
- writeByte(fp, (uint8)(value));
- writeByte(fp, (uint8)(value >> 8));
-}
-
-void writeUint32BE(FILE *fp, uint32 value) {
- writeByte(fp, (uint8)(value >> 24));
- writeByte(fp, (uint8)(value >> 16));
- writeByte(fp, (uint8)(value >> 8));
- writeByte(fp, (uint8)(value));
-}
-
-void writeUint32LE(FILE *fp, uint32 value) {
- writeByte(fp, (uint8)(value));
- writeByte(fp, (uint8)(value >> 8));
- writeByte(fp, (uint8)(value >> 16));
- writeByte(fp, (uint8)(value >> 24));
-}
-
-uint32 fileSize(FILE *fp) {
- uint32 sz;
- uint32 pos = ftell(fp);
- fseek(fp, 0, SEEK_END);
- sz = ftell(fp);
- fseek(fp, pos, SEEK_SET);
- return sz;
-}
-
Copied: scummvm/trunk/tools/create_kyradat/util.cpp (from rev 30962, scummvm/trunk/tools/create_kyradat/util.c)
===================================================================
--- scummvm/trunk/tools/create_kyradat/util.cpp (rev 0)
+++ scummvm/trunk/tools/create_kyradat/util.cpp 2008-02-25 14:13:12 UTC (rev 30963)
@@ -0,0 +1,137 @@
+/* Scumm Tools
+ * Copyright (C) 2003-2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "util.h"
+#include <stdarg.h>
+
+#ifdef _MSC_VER
+ #define vsnprintf _vsnprintf
+#endif
+
+void error(const char *s, ...) {
+ char buf[1024];
+ va_list va;
+
+ va_start(va, s);
+ vsnprintf(buf, 1024, s, va);
+ va_end(va);
+
+ fprintf(stderr, "ERROR: %s!\n", buf);
+
+ exit(1);
+}
+
+void warning(const char *s, ...) {
+ char buf[1024];
+ va_list va;
+
+ va_start(va, s);
+ vsnprintf(buf, 1024, s, va);
+ va_end(va);
+
+ fprintf(stderr, "WARNING: %s!\n", buf);
+}
+
+void debug(int level, const char *s, ...) {
+ char buf[1024];
+ va_list va;
+
+ va_start(va, s);
+ vsnprintf(buf, 1024, s, va);
+ va_end(va);
+
+ fprintf(stderr, "DEBUG: %s!\n", buf);
+}
+
+uint8 readByte(FILE *fp) {
+ return fgetc(fp);
+}
+
+uint16 readUint16BE(FILE *fp) {
+ uint16 ret = 0;
+ ret |= fgetc(fp) << 8;
+ ret |= fgetc(fp);
+ return ret;
+}
+
+uint16 readUint16LE(FILE *fp) {
+ uint16 ret = 0;
+ ret |= fgetc(fp);
+ ret |= fgetc(fp) << 8;
+ return ret;
+}
+
+uint32 readUint32BE(FILE *fp) {
+ uint32 ret = 0;
+ ret |= fgetc(fp) << 24;
+ ret |= fgetc(fp) << 16;
+ ret |= fgetc(fp) << 8;
+ ret |= fgetc(fp);
+ return ret;
+}
+
+uint32 readUint32LE(FILE *fp) {
+ uint32 ret = 0;
+ ret |= fgetc(fp);
+ ret |= fgetc(fp) << 8;
+ ret |= fgetc(fp) << 16;
+ ret |= fgetc(fp) << 24;
+ return ret;
+}
+
+void writeByte(FILE *fp, uint8 b) {
+ fwrite(&b, 1, 1, fp);
+}
+
+void writeUint16BE(FILE *fp, uint16 value) {
+ writeByte(fp, (uint8)(value >> 8));
+ writeByte(fp, (uint8)(value));
+}
+
+void writeUint16LE(FILE *fp, uint16 value) {
+ writeByte(fp, (uint8)(value));
+ writeByte(fp, (uint8)(value >> 8));
+}
+
+void writeUint32BE(FILE *fp, uint32 value) {
+ writeByte(fp, (uint8)(value >> 24));
+ writeByte(fp, (uint8)(value >> 16));
+ writeByte(fp, (uint8)(value >> 8));
+ writeByte(fp, (uint8)(value));
+}
+
+void writeUint32LE(FILE *fp, uint32 value) {
+ writeByte(fp, (uint8)(value));
+ writeByte(fp, (uint8)(value >> 8));
+ writeByte(fp, (uint8)(value >> 16));
+ writeByte(fp, (uint8)(value >> 24));
+}
+
+uint32 fileSize(FILE *fp) {
+ uint32 sz;
+ uint32 pos = ftell(fp);
+ fseek(fp, 0, SEEK_END);
+ sz = ftell(fp);
+ fseek(fp, pos, SEEK_SET);
+ return sz;
+}
+
Deleted: scummvm/trunk/tools/qtable/qtable.c
===================================================================
--- scummvm/trunk/tools/qtable/qtable.c 2008-02-25 14:10:17 UTC (rev 30962)
+++ scummvm/trunk/tools/qtable/qtable.c 2008-02-25 14:13:12 UTC (rev 30963)
@@ -1,188 +0,0 @@
-// HACK to allow building with the SDL backend on MinGW
-// see bug #1800764 "TOOLS: MinGW tools building broken"
-#ifdef main
-#undef main
-#endif // main
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-/*
- Table file format for scummvm/queen
- uint32 : 'QTBL'
- uint32 : version/tag
- repeat (number of resources tables) {
- uint16 : number of entries
- repeat (number of entries) {
- char[12] : name
- uint8 : queen.%d
- uint32 : offset in queen.%d
- uint32 : length in queen.%d
- }
- }
-*/
-
-#define MAX_VERSIONS 20
-#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
-
-typedef unsigned char uint8;
-typedef unsigned short uint16;
-typedef unsigned int uint32;
-
-typedef struct DataFileEntry {
- uint8 bundle;
- uint32 offset;
- uint32 length;
- char name[13];
-} DataFileEntry;
-
-typedef struct DataFileEntriesTable {
- const DataFileEntry *fileEntries;
- uint16 fileEntriesCount;
-} DataFileEntriesTable;
-
-typedef struct TableFile {
- const char *outfile;
- DataFileEntriesTable dataFileEntriesTable[MAX_VERSIONS];
- uint16 dataFileEntriesTableCount;
-} TableFile;
-
-typedef struct GameVersion {
- const char *id;
- uint32 dataSize;
- DataFileEntry *dataFileEntries;
- uint16 dataFileEntriesCount;
- uint8 queenTblVersion;
- uint32 queenTblOffset;
-} GameVersion;
-
-#include "fat_eng_floppy.h"
-#include "fat_eng_cdrom.h"
-#include "fat_fre_floppy.h"
-#include "fat_fre_cdrom.h"
-#include "fat_ger_floppy.h"
-#include "fat_ger_cdrom.h"
-#include "fat_ita_floppy.h"
-#include "fat_ita_cdrom.h"
-#include "fat_spa_cdrom.h"
-#include "fat_heb_cdrom.h"
-#include "fat_pc_demo_pcgames.h"
-#include "fat_pc_demo.h"
-#include "fat_pc_interview.h"
-#include "fat_amiga_eng_floppy.h"
-#include "fat_amiga_demo.h"
-#include "fat_amiga_interview.h"
-
-
-#define FAT(x) x, (sizeof(x)/sizeof(x[0]))
-
-static GameVersion gameVersionsTable[] = {
- { "PEM10", 22677657, FAT(fatEngFl), 1, 0 },
- { "CEM10", 190787021, FAT(fatEngCd), 1, 0 },
- { "PFM10", 22157304, FAT(fatFreFl), 1, 0 },
- { "CFM10", 186689095, FAT(fatFreCd), 1, 0 },
- { "PGM10", 22240013, FAT(fatGerFl), 1, 0 },
- { "CGM10", 217648975, FAT(fatGerCd), 1, 0 },
- { "PIM10", 22461366, FAT(fatItaFl), 1, 0 },
- { "CIM10", 190795582, FAT(fatItaCd), 1, 0 },
- { "CSM10", 190730602, FAT(fatSpaCd), 1, 0 },
- { "CHM10", 190705558, FAT(fatHebCd), 1, 0 },
- { "PE100", 3724538, FAT(fatPCDemoPcGames), 1, 0 },
- { "PE100", 3732177, FAT(fatPCDemo), 1, 0 },
- { "PEint", 1915913, FAT(fatPCInterview), 1, 0 },
- { "aEM10", 351775, FAT(fatAmigaEngFl), 2, 0 },
- { "CE101", 563335, FAT(fatAmigaDemo), 2, 0 },
- { "PE100", 597032, FAT(fatAmigaInterview), 2, 0 }
-};
-
-static const uint32 QTBL_TAG = 0x5154424C;
-static const uint32 CURRENT_VERSION = 2;
-
-static void writeByte(FILE *fp, uint8 b) {
- fwrite(&b, 1, 1, fp);
-}
-
-static void writeUint16BE(FILE *fp, uint16 value) {
- writeByte(fp, (uint8)(value >> 8));
- writeByte(fp, (uint8)(value & 0xFF));
-}
-
-static void writeUint32BE(FILE *fp, uint32 value) {
- writeUint16BE(fp, (uint16)(value >> 16));
- writeUint16BE(fp, (uint16)(value & 0xFFFF));
-}
-
-static void writeEntry(FILE *fp, const DataFileEntry *dfe) {
- fwrite(dfe->name, 12, 1, fp);
- writeByte(fp, dfe->bundle);
- writeUint32BE(fp, dfe->offset);
- writeUint32BE(fp, dfe->length);
-}
-
-static void createTableFile(TableFile *tf) {
- FILE *out;
- uint16 i, j;
- uint32 offset; /* dump offset */
-
- /* setup file entries table */
- assert(ARRAYSIZE(gameVersionsTable) < MAX_VERSIONS);
- for (i = 0; i < ARRAYSIZE(gameVersionsTable); ++i) {
- const GameVersion *gv = &gameVersionsTable[i];
- tf->dataFileEntriesTable[i].fileEntries = gv->dataFileEntries;
- tf->dataFileEntriesTable[i].fileEntriesCount = gv->dataFileEntriesCount;
- }
- tf->dataFileEntriesTableCount = ARRAYSIZE(gameVersionsTable);
-
- /* write queen table file */
- out = fopen(tf->outfile, "wb");
- if (!out) {
- printf("ERROR: can't write output file.\n");
- return;
- }
- /* write header tag */
- writeUint32BE(out, QTBL_TAG);
- /* write version */
- writeUint32BE(out, CURRENT_VERSION);
- /* write tables */
- offset = 4 + 4;
- for(i = 0; i < tf->dataFileEntriesTableCount; ++i) {
- const DataFileEntriesTable *dfet = &tf->dataFileEntriesTable[i];
- /* write number of entries in table */
- writeUint16BE(out, dfet->fileEntriesCount);
- /* write table entries */
- for (j = 0; j < dfet->fileEntriesCount; ++j) {
- const DataFileEntry *dfe = &dfet->fileEntries[j];
- writeEntry(out, dfe);
- }
- assert(gameVersionsTable[i].queenTblVersion <= CURRENT_VERSION);
- gameVersionsTable[i].queenTblOffset = offset;
- /* update offset */
- offset += 2 + dfet->fileEntriesCount * (12 + 1 + 4 + 4);
- }
- fclose(out);
-}
-
-static void printGameVersionTable() {
- int i;
- printf("const RetailGameVersion Resource::_gameVersions[] = {\n");
- for (i = 0; i < ARRAYSIZE(gameVersionsTable); ++i) {
- const GameVersion *gv = &gameVersionsTable[i];
- printf("\t{ \"%s\", %d, 0x%08X, %9d },\n", gv->id, gv->queenTblVersion, gv->queenTblOffset, gv->dataSize);
- }
- printf("};\n");
-}
-
-int main(int argc, char *argv[]) {
- TableFile tf;
- if (argc < 2) {
- printf("syntax: %s tablefile\n", argv[0]);
- exit(0);
- }
- memset(&tf, 0, sizeof(tf));
- tf.outfile = argv[1];
- createTableFile(&tf);
- printGameVersionTable();
- return 0;
-}
Copied: scummvm/trunk/tools/qtable/qtable.cpp (from rev 30962, scummvm/trunk/tools/qtable/qtable.c)
===================================================================
--- scummvm/trunk/tools/qtable/qtable.cpp (rev 0)
+++ scummvm/trunk/tools/qtable/qtable.cpp 2008-02-25 14:13:12 UTC (rev 30963)
@@ -0,0 +1,188 @@
+// HACK to allow building with the SDL backend on MinGW
+// see bug #1800764 "TOOLS: MinGW tools building broken"
+#ifdef main
+#undef main
+#endif // main
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+/*
+ Table file format for scummvm/queen
+ uint32 : 'QTBL'
+ uint32 : version/tag
+ repeat (number of resources tables) {
+ uint16 : number of entries
+ repeat (number of entries) {
+ char[12] : name
+ uint8 : queen.%d
+ uint32 : offset in queen.%d
+ uint32 : length in queen.%d
+ }
+ }
+*/
+
+#define MAX_VERSIONS 20
+#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
+
+typedef unsigned char uint8;
+typedef unsigned short uint16;
+typedef unsigned int uint32;
+
+typedef struct DataFileEntry {
+ uint8 bundle;
+ uint32 offset;
+ uint32 length;
+ char name[13];
+} DataFileEntry;
+
+typedef struct DataFileEntriesTable {
+ const DataFileEntry *fileEntries;
+ uint16 fileEntriesCount;
+} DataFileEntriesTable;
+
+typedef struct TableFile {
+ const char *outfile;
+ DataFileEntriesTable dataFileEntriesTable[MAX_VERSIONS];
+ uint16 dataFileEntriesTableCount;
+} TableFile;
+
+typedef struct GameVersion {
+ const char *id;
+ uint32 dataSize;
+ DataFileEntry *dataFileEntries;
+ uint16 dataFileEntriesCount;
+ uint8 queenTblVersion;
+ uint32 queenTblOffset;
+} GameVersion;
+
+#include "fat_eng_floppy.h"
+#include "fat_eng_cdrom.h"
+#include "fat_fre_floppy.h"
+#include "fat_fre_cdrom.h"
+#include "fat_ger_floppy.h"
+#include "fat_ger_cdrom.h"
+#include "fat_ita_floppy.h"
+#include "fat_ita_cdrom.h"
+#include "fat_spa_cdrom.h"
+#include "fat_heb_cdrom.h"
+#include "fat_pc_demo_pcgames.h"
+#include "fat_pc_demo.h"
+#include "fat_pc_interview.h"
+#include "fat_amiga_eng_floppy.h"
+#include "fat_amiga_demo.h"
+#include "fat_amiga_interview.h"
+
+
+#define FAT(x) x, (sizeof(x)/sizeof(x[0]))
+
+static GameVersion gameVersionsTable[] = {
+ { "PEM10", 22677657, FAT(fatEngFl), 1, 0 },
+ { "CEM10", 190787021, FAT(fatEngCd), 1, 0 },
+ { "PFM10", 22157304, FAT(fatFreFl), 1, 0 },
+ { "CFM10", 186689095, FAT(fatFreCd), 1, 0 },
+ { "PGM10", 22240013, FAT(fatGerFl), 1, 0 },
+ { "CGM10", 217648975, FAT(fatGerCd), 1, 0 },
+ { "PIM10", 22461366, FAT(fatItaFl), 1, 0 },
+ { "CIM10", 190795582, FAT(fatItaCd), 1, 0 },
+ { "CSM10", 190730602, FAT(fatSpaCd), 1, 0 },
+ { "CHM10", 190705558, FAT(fatHebCd), 1, 0 },
+ { "PE100", 3724538, FAT(fatPCDemoPcGames), 1, 0 },
+ { "PE100", 3732177, FAT(fatPCDemo), 1, 0 },
+ { "PEint", 1915913, FAT(fatPCInterview), 1, 0 },
+ { "aEM10", 351775, FAT(fatAmigaEngFl), 2, 0 },
+ { "CE101", 563335, FAT(fatAmigaDemo), 2, 0 },
+ { "PE100", 597032, FAT(fatAmigaInterview), 2, 0 }
+};
+
+static const uint32 QTBL_TAG = 0x5154424C;
+static const uint32 CURRENT_VERSION = 2;
+
+static void writeByte(FILE *fp, uint8 b) {
+ fwrite(&b, 1, 1, fp);
+}
+
+static void writeUint16BE(FILE *fp, uint16 value) {
+ writeByte(fp, (uint8)(value >> 8));
+ writeByte(fp, (uint8)(value & 0xFF));
+}
+
+static void writeUint32BE(FILE *fp, uint32 value) {
+ writeUint16BE(fp, (uint16)(value >> 16));
+ writeUint16BE(fp, (uint16)(value & 0xFFFF));
+}
+
+static void writeEntry(FILE *fp, const DataFileEntry *dfe) {
+ fwrite(dfe->name, 12, 1, fp);
+ writeByte(fp, dfe->bundle);
+ writeUint32BE(fp, dfe->offset);
+ writeUint32BE(fp, dfe->length);
+}
+
+static void createTableFile(TableFile *tf) {
+ FILE *out;
+ uint16 i, j;
+ uint32 offset; /* dump offset */
+
+ /* setup file entries table */
+ assert(ARRAYSIZE(gameVersionsTable) < MAX_VERSIONS);
+ for (i = 0; i < ARRAYSIZE(gameVersionsTable); ++i) {
+ const GameVersion *gv = &gameVersionsTable[i];
+ tf->dataFileEntriesTable[i].fileEntries = gv->dataFileEntries;
+ tf->dataFileEntriesTable[i].fileEntriesCount = gv->dataFileEntriesCount;
+ }
+ tf->dataFileEntriesTableCount = ARRAYSIZE(gameVersionsTable);
+
+ /* write queen table file */
+ out = fopen(tf->outfile, "wb");
+ if (!out) {
+ printf("ERROR: can't write output file.\n");
+ return;
+ }
+ /* write header tag */
+ writeUint32BE(out, QTBL_TAG);
+ /* write version */
+ writeUint32BE(out, CURRENT_VERSION);
+ /* write tables */
+ offset = 4 + 4;
+ for(i = 0; i < tf->dataFileEntriesTableCount; ++i) {
+ const DataFileEntriesTable *dfet = &tf->dataFileEntriesTable[i];
+ /* write number of entries in table */
+ writeUint16BE(out, dfet->fileEntriesCount);
+ /* write table entries */
+ for (j = 0; j < dfet->fileEntriesCount; ++j) {
+ const DataFileEntry *dfe = &dfet->fileEntries[j];
+ writeEntry(out, dfe);
+ }
+ assert(gameVersionsTable[i].queenTblVersion <= CURRENT_VERSION);
+ gameVersionsTable[i].queenTblOffset = offset;
+ /* update offset */
+ offset += 2 + dfet->fileEntriesCount * (12 + 1 + 4 + 4);
+ }
+ fclose(out);
+}
+
+static void printGameVersionTable() {
+ unsigned int i;
+ printf("const RetailGameVersion Resource::_gameVersions[] = {\n");
+ for (i = 0; i < ARRAYSIZE(gameVersionsTable); ++i) {
+ const GameVersion *gv = &gameVersionsTable[i];
+ printf("\t{ \"%s\", %d, 0x%08X, %9d },\n", gv->id, gv->queenTblVersion, gv->queenTblOffset, gv->dataSize);
+ }
+ printf("};\n");
+}
+
+int main(int argc, char *argv[]) {
+ TableFile tf;
+ if (argc < 2) {
+ printf("syntax: %s tablefile\n", argv[0]);
+ exit(0);
+ }
+ memset(&tf, 0, sizeof(tf));
+ tf.outfile = argv[1];
+ createTableFile(&tf);
+ printGameVersionTable();
+ return 0;
+}
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