Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,140 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
// Disable symbol overrides so that we can use system headers.
#define FORBIDDEN_SYMBOL_ALLOW_ALL
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "util.h"
#include "create_cryomni3d_dat.h"
struct Parts {
size_t (*writeHeader)(FILE *f, uint32 offset, uint32 size);
size_t (*writeData)(FILE *f);
uint32 offset;
uint32 size;
};
#define DEFINE_GAME_PLATFORM_LANG_FUNCS(game, platform, lang) \
size_t write ## game ## _ ## platform ## _ ## lang ## _Header(FILE *f, \
uint32 offset, uint32 size); \
size_t write ## game ## _ ## platform ## _ ## lang ## _Data(FILE *f);
#define GAME_PLATFORM_LANG_PART(game, platform, lang) { write ## game ## _ ## platform ## _ ## lang ## _Header, \
write ## game ## _ ## platform ## _ ## lang ## _Data, 0, 0 }
DEFINE_GAME_PLATFORM_LANG_FUNCS(Versailles, ALL, FR)
DEFINE_GAME_PLATFORM_LANG_FUNCS(Versailles, ALL, BR)
DEFINE_GAME_PLATFORM_LANG_FUNCS(Versailles, ALL, DE)
DEFINE_GAME_PLATFORM_LANG_FUNCS(Versailles, ALL, EN)
DEFINE_GAME_PLATFORM_LANG_FUNCS(Versailles, ALL, ES)
DEFINE_GAME_PLATFORM_LANG_FUNCS(Versailles, ALL, IT)
DEFINE_GAME_PLATFORM_LANG_FUNCS(Versailles, ALL, JA)
DEFINE_GAME_PLATFORM_LANG_FUNCS(Versailles, ALL, KO)
DEFINE_GAME_PLATFORM_LANG_FUNCS(Versailles, ALL, ZT)
static Parts gamesParts[] = {
GAME_PLATFORM_LANG_PART(Versailles, ALL, FR),
GAME_PLATFORM_LANG_PART(Versailles, ALL, BR),
GAME_PLATFORM_LANG_PART(Versailles, ALL, DE),
GAME_PLATFORM_LANG_PART(Versailles, ALL, EN),
GAME_PLATFORM_LANG_PART(Versailles, ALL, ES),
GAME_PLATFORM_LANG_PART(Versailles, ALL, IT),
GAME_PLATFORM_LANG_PART(Versailles, ALL, JA),
GAME_PLATFORM_LANG_PART(Versailles, ALL, KO),
GAME_PLATFORM_LANG_PART(Versailles, ALL, ZT),
};
#define CRYOMNI3D_DAT_VER 1 // 32-bit integer
size_t writeFileHeader(FILE *f, uint16 games) {
size_t headerSize = 0;
fwrite("CY3DDATA", 8, 1, f);
headerSize += 8;
headerSize += writeUint16LE(f, CRYOMNI3D_DAT_VER);
headerSize += writeUint16LE(f, games);
// Dummy value to pad to 16 bytes
headerSize += writeUint32LE(f, 0);
assert((headerSize & PADDING_MASK) == 0);
return headerSize;
}
size_t writeGameHeader(FILE *f, uint32 gameId, uint16 version, uint16 lang, uint32 platforms,
uint32 offset, uint32 size) {
size_t headerSize = 0;
headerSize += writeUint32BE(f, gameId); // BE to keep the tag readable
headerSize += writeUint16LE(f, version);
headerSize += writeUint16BE(f, lang); // BE to keep the tag readable
headerSize += writeUint32LE(f, platforms);
headerSize += writeUint32LE(f, offset);
headerSize += writeUint32LE(f, size);
return headerSize;
}
static int emitData(char *outputFilename) {
FILE *f = fopen(outputFilename, "w+b");
if (!f) {
printf("ERROR: Unable to create output file %s\n", outputFilename);
return 1;
}
printf("Generating %s...\n", outputFilename);
writeFileHeader(f);
for (unsigned int i = 0; i < ARRAYSIZE(gamesParts); i++) {
gamesParts[i].writeHeader(f, 0xdeadfeed, 0xdeadfeed);
}
// Pad the games list
writePadding(f);
for (unsigned int i = 0; i < ARRAYSIZE(gamesParts); i++) {
gamesParts[i].offset = ftell(f);
gamesParts[i].size = gamesParts[i].writeData(f);
}
fseek(f, 0, SEEK_SET);
writeFileHeader(f, ARRAYSIZE(gamesParts));
for (unsigned int i = 0; i < ARRAYSIZE(gamesParts); i++) {
gamesParts[i].writeHeader(f, gamesParts[i].offset, gamesParts[i].size);
}
fclose(f);
printf("Done!\n");
return 0;
}
int main(int argc, char **argv) {
if (argc > 1) {
return emitData(argv[1]);
} else {
printf("Usage: %s <output.dat>\n", argv[0]);
}
return 0;
}

View File

@@ -0,0 +1,50 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef CREATE_CRYOMNI3D_DAT_H
#define CREATE_CRYOMNI3D_DAT_H
#ifndef MKTAG16
#define MKTAG16(a0,a1) ((uint16)((a1) | ((a0) << 8)))
#endif
size_t writeFileHeader(FILE *f, uint16 games = 0xdead);
size_t writeGameHeader(FILE *f, uint32 gameId, uint16 version, uint16 lang, uint32 platforms,
uint32 offset = 0xdeadfeed, uint32 size = 0xdeadfeed);
#define PLATFORM_WIN 0x1
#define PLATFORM_DOS 0x2
#define PLATFORM_MAC 0x4
#define PLATFORM_PLAYSTATION 0x8
#define PLATFORM_SATURN 0x10
#define PLATFORM_ALL 0xffffffff
#define LANG_BR MKTAG16('b', 'r')
#define LANG_DE MKTAG16('d', 'e')
#define LANG_EN MKTAG16('e', 'n')
#define LANG_ES MKTAG16('e', 's')
#define LANG_FR MKTAG16('f', 'r')
#define LANG_IT MKTAG16('i', 't')
#define LANG_JA MKTAG16('j', 'a')
#define LANG_KO MKTAG16('k', 'o')
#define LANG_ZT MKTAG16('z', 't') // ZH_TWN
#endif

View File

@@ -0,0 +1,14 @@
MODULE := devtools/create_cryomni3d
MODULE_OBJS := \
create_cryomni3d_dat.o \
util.o \
versailles.o
# Set the name of the executable
TOOL_EXECUTABLE := create_cryomni3d_dat
# Include common rules
include $(srcdir)/rules.mk

View File

@@ -0,0 +1,162 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
// Disable symbol overrides so that we can use system headers.
#define FORBIDDEN_SYMBOL_ALLOW_ALL
#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);
}
int scumm_stricmp(const char *s1, const char *s2) {
byte l1, l2;
do {
// Don't use ++ inside tolower, in case the macro uses its
// arguments more than once.
l1 = (byte) * s1++;
l1 = tolower(l1);
l2 = (byte) * s2++;
l2 = tolower(l2);
} while (l1 == l2 && l1 != 0);
return l1 - l2;
}
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);
}
size_t writeByte(FILE *fp, uint8 b) {
fwrite(&b, 1, 1, fp);
return sizeof(b);
}
size_t writeUint16BE(FILE *fp, uint16 value) {
writeByte(fp, (uint8)(value >> 8));
writeByte(fp, (uint8)(value));
return sizeof(value);
}
size_t writeUint16LE(FILE *fp, uint16 value) {
writeByte(fp, (uint8)(value));
writeByte(fp, (uint8)(value >> 8));
return sizeof(value);
}
size_t writeUint32BE(FILE *fp, uint32 value) {
writeByte(fp, (uint8)(value >> 24));
writeByte(fp, (uint8)(value >> 16));
writeByte(fp, (uint8)(value >> 8));
writeByte(fp, (uint8)(value));
return sizeof(value);
}
size_t writeUint32LE(FILE *fp, uint32 value) {
writeByte(fp, (uint8)(value));
writeByte(fp, (uint8)(value >> 8));
writeByte(fp, (uint8)(value >> 16));
writeByte(fp, (uint8)(value >> 24));
return sizeof(value);
}
size_t writeString16(FILE *fp, const char *string) {
if (string == nullptr) {
// Like an empty string
return writeUint16LE(fp, 0);
}
size_t n = strlen(string);
if (n > 0xffff) {
return 0;
}
size_t written = 0;
written += writeUint16LE(fp, n);
fwrite(string, n, 1, fp);
written += n;
return written;
}
size_t writeString16Array16(FILE *fp, char const *const *array, uint16 elems) {
return writeArray<char const *, writeString16, uint16, writeUint16LE>(fp, array, elems);
}
//#define DEBUG
static const char padBuf[PADDING_ALIGNMENT] = {
#ifndef DEBUG
0
#else
0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C,
#endif
};
size_t writePadding(FILE *fp) {
long pos = ftell(fp);
pos = pos & PADDING_MASK; // Keep only remainder
if (pos == 0) {
return 0;
}
pos = PADDING_ALIGNMENT - pos;
fwrite(padBuf, pos, 1, fp);
return pos;
}
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;
}

View File

@@ -0,0 +1,75 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef UTIL_H
#define UTIL_H
#include "common/scummsys.h"
#include "common/endian.h"
#include "common/util.h"
#ifdef WIN32
#include <io.h>
#include <process.h>
#endif
#define PADDING_ALIGNMENT 16
#define PADDING_MASK 0xf
/* File I/O */
size_t writeByte(FILE *fp, uint8 b);
size_t writeUint16BE(FILE *fp, uint16 value);
size_t writeUint16LE(FILE *fp, uint16 value);
size_t writeUint32BE(FILE *fp, uint32 value);
size_t writeUint32LE(FILE *fp, uint32 value);
size_t writeString16(FILE *fp, char const *string);
size_t writeString16Array16(FILE *fp, char const *const *string, uint16 elems);
size_t writePadding(FILE *fp);
uint32 fileSize(FILE *fp);
// Helper
template<typename T, size_t (*Tf)(FILE *fp, const T &), typename U, size_t (*Uf)(FILE *fp, U)>
size_t writeArray(FILE *fp, T const *array, U elems) {
size_t written = 0;
written += Uf(fp, elems);
for (U i = 0; i < elems; i++) {
written += Tf(fp, array[i]);
}
return written;
}
template<typename T, size_t (*Tf)(FILE *fp, T), typename U, size_t (*Uf)(FILE *fp, U)>
size_t writeArray(FILE *fp, T const *array, U elems) {
size_t written = 0;
written += Uf(fp, elems);
for (U i = 0; i < elems; i++) {
written += Tf(fp, array[i]);
}
return written;
}
/* Misc stuff */
void NORETURN_PRE error(const char *s, ...) NORETURN_POST;
void warning(const char *s, ...);
void debug(int level, const char *s, ...);
using namespace Common;
#endif

View File

@@ -0,0 +1,131 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
// Disable symbol overrides so that we can use system headers.
#define FORBIDDEN_SYMBOL_ALLOW_ALL
#include "util.h"
#include "create_cryomni3d_dat.h"
#include "versailles.h"
size_t writeVersaillesSubtitleEntry(FILE *fp, const SubtitleEntry &entry) {
size_t size = 0;
size += writeUint32LE(fp, entry.frameStart);
size += writeString16(fp, entry.text);
return size;
}
size_t writeVersaillesSubtitle(FILE *fp, Subtitle const &subtitle) {
size_t size = 0;
size += writeString16(fp, subtitle.videoName);
size_t count = 0;
for (; count < ARRAYSIZE(subtitle.entries) &&
(subtitle.entries[count].text != nullptr ||
subtitle.entries[count].frameStart != 0); count++) { }
size += writeArray<SubtitleEntry, writeVersaillesSubtitleEntry, uint16, writeUint16LE>(fp,
subtitle.entries, count);
return size;
}
size_t writeVersaillesSubtitles16(FILE *fp, Subtitle const *subtitles, uint16 elems) {
return writeArray<Subtitle, writeVersaillesSubtitle, uint16, writeUint16LE>(fp, subtitles, elems);
}
// In Versailles platform doesn't seem to change anything
#define DEFINE_FUNCS(lang) \
size_t writeVersailles_ALL_ ## lang ## _Header(FILE *f, uint32 offset, uint32 size) { \
return writeGameHeader(f, VERSAILLES_GAMEID, VERSAILLES_VERSION, LANG_ ## lang, PLATFORM_ALL, \
offset, size); \
} \
\
size_t writeVersailles_ALL_ ## lang ## _Data(FILE *f) { \
size_t size = 0; \
\
assert(VERSAILLES_LOCALIZED_FILENAMES_COUNT == ARRAYSIZE(versailles ## lang ## localizedFilenames)); \
size += writeString16Array16(f, versailles ## lang ## localizedFilenames, \
VERSAILLES_LOCALIZED_FILENAMES_COUNT); \
\
size += writeString16(f, versailles ## lang ## EpilMsg); \
size += writeString16(f, versailles ## lang ## EpilPwd); \
\
size += writeString16(f, versailles ## lang ## BombPwd); \
\
assert(VERSAILLES_MESSAGES_COUNT == ARRAYSIZE(versailles ## lang ## messages)); \
size += writeString16Array16(f, versailles ## lang ## messages, ARRAYSIZE(versailles ## lang ## messages)); \
\
assert(VERSAILLES_PAINTINGS_COUNT == ARRAYSIZE(versailles ## lang ## paintings)); \
size += writeString16Array16(f, versailles ## lang ## paintings, ARRAYSIZE(versailles ## lang ## paintings)); \
\
size += writePadding(f); \
return size; \
}
#define DEFINE_FUNCS_CJK(lang) \
size_t writeVersailles_ALL_ ## lang ## _Header(FILE *f, uint32 offset, uint32 size) { \
return writeGameHeader(f, VERSAILLES_GAMEID, VERSAILLES_VERSION, LANG_ ## lang, PLATFORM_ALL, \
offset, size); \
} \
\
size_t writeVersailles_ALL_ ## lang ## _Data(FILE *f) { \
size_t size = 0; \
\
assert(VERSAILLES_LOCALIZED_FILENAMES_COUNT == ARRAYSIZE(versailles ## lang ## localizedFilenames)); \
size += writeString16Array16(f, versailles ## lang ## localizedFilenames, \
VERSAILLES_LOCALIZED_FILENAMES_COUNT); \
\
size += writeString16(f, versailles ## lang ## EpilMsg); \
size += writeString16(f, versailles ## lang ## EpilPwd); \
\
if ((LANG_ ## lang == LANG_JA)) { \
assert(VERSAILLES_JA_BOMB_ALPHABET_SIZE + 1 == sizeof(versaillesJABombAlphabet)); \
size += writeString16(f, versaillesJABombAlphabet); \
} \
size += writeString16(f, versailles ## lang ## BombPwd); \
\
assert(VERSAILLES_MESSAGES_COUNT_CJK == ARRAYSIZE(versailles ## lang ## messages)); \
size += writeString16Array16(f, versailles ## lang ## messages, ARRAYSIZE(versailles ## lang ## messages)); \
\
assert(VERSAILLES_PAINTINGS_COUNT == ARRAYSIZE(versailles ## lang ## paintings)); \
size += writeString16Array16(f, versailles ## lang ## paintings, ARRAYSIZE(versailles ## lang ## paintings)); \
\
/* No need to assert as we don't expect a fixed count in engine */ \
size += writeVersaillesSubtitles16(f, versailles ## lang ## subtitles, ARRAYSIZE(versailles ## lang ## subtitles)); \
\
size += writePadding(f); \
return size; \
}
DEFINE_FUNCS(FR)
DEFINE_FUNCS(BR)
DEFINE_FUNCS(DE)
DEFINE_FUNCS(EN)
DEFINE_FUNCS(ES)
DEFINE_FUNCS(IT)
DEFINE_FUNCS_CJK(JA)
DEFINE_FUNCS_CJK(KO)
DEFINE_FUNCS_CJK(ZT)

File diff suppressed because it is too large Load Diff