TONY: Move font related arrays to a DAT file
This commit is contained in:
parent
5cc63df513
commit
7cb29f1522
7 changed files with 1710 additions and 1417 deletions
183
devtools/create_tony/create_tony.cpp
Normal file
183
devtools/create_tony/create_tony.cpp
Normal file
|
@ -0,0 +1,183 @@
|
|||
/* 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 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.
|
||||
*
|
||||
* This is a utility for storing all the hardcoded data of Tony Tough in a separate
|
||||
* data file, used by the game engine
|
||||
*/
|
||||
|
||||
// Disable symbol overrides so that we can use system headers.
|
||||
#define FORBIDDEN_SYMBOL_ALLOW_ALL
|
||||
|
||||
// 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 "common/scummsys.h"
|
||||
#include "common/events.h"
|
||||
|
||||
#include "create_tony.h"
|
||||
#include "staticdata.h"
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
void writeSint16BE(FILE *fp, int16 value) {
|
||||
writeUint16BE(fp, (uint16)value);
|
||||
}
|
||||
|
||||
static void writeUint32BE(FILE *fp, uint32 value) {
|
||||
writeByte(fp, (uint8)(value >> 24));
|
||||
writeByte(fp, (uint8)((value >> 16) & 0xFF));
|
||||
writeByte(fp, (uint8)((value >> 8) & 0xFF));
|
||||
writeByte(fp, (uint8)(value & 0xFF));
|
||||
}
|
||||
|
||||
void writeSint32BE(FILE *fp, int32 value) {
|
||||
writeUint32BE(fp, (uint16)value);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
FILE *outFile;
|
||||
|
||||
outFile = fopen("tony.dat", "wb");
|
||||
|
||||
// Write header
|
||||
fwrite("TONY", 4, 1, outFile);
|
||||
|
||||
writeByte(outFile, TONY_DAT_VER_MAJ);
|
||||
writeByte(outFile, TONY_DAT_VER_MIN);
|
||||
|
||||
// game versions/variants
|
||||
writeUint16BE(outFile, NUM_VARIANTS);
|
||||
|
||||
// Italian
|
||||
for (int i = 0; i < 256; i++) {
|
||||
writeSint16BE(outFile, _cTableDialogIta[i]);
|
||||
writeSint16BE(outFile, _lTableDialogIta[i]);
|
||||
writeSint16BE(outFile, _cTableMaccIta[i]);
|
||||
writeSint16BE(outFile, _lTableMaccIta[i]);
|
||||
writeSint16BE(outFile, _cTableCredIta[i]);
|
||||
writeSint16BE(outFile, _lTableCredIta[i]);
|
||||
writeSint16BE(outFile, _cTableObjIta[i]);
|
||||
writeSint16BE(outFile, _lTableObjIta[i]);
|
||||
}
|
||||
|
||||
// Polish
|
||||
for (int i = 0; i < 256; i++) {
|
||||
writeSint16BE(outFile, _cTableDialogPol[i]);
|
||||
writeSint16BE(outFile, _lTableDialogPol[i]);
|
||||
writeSint16BE(outFile, _cTableMaccPol[i]);
|
||||
writeSint16BE(outFile, _lTableMaccPol[i]);
|
||||
writeSint16BE(outFile, _cTableCredPol[i]);
|
||||
writeSint16BE(outFile, _lTableCredPol[i]);
|
||||
writeSint16BE(outFile, _cTableObjPol[i]);
|
||||
writeSint16BE(outFile, _lTableObjPol[i]);
|
||||
}
|
||||
|
||||
//Russian
|
||||
for (int i = 0; i < 256; i++) {
|
||||
writeSint16BE(outFile, _cTableDialogRus[i]);
|
||||
writeSint16BE(outFile, _lTableDialogRus[i]);
|
||||
writeSint16BE(outFile, _cTableMaccRus[i]);
|
||||
writeSint16BE(outFile, _lTableMaccRus[i]);
|
||||
writeSint16BE(outFile, _cTableCredRus[i]);
|
||||
writeSint16BE(outFile, _lTableCredRus[i]);
|
||||
writeSint16BE(outFile, _cTableObjRus[i]);
|
||||
writeSint16BE(outFile, _lTableObjRus[i]);
|
||||
}
|
||||
|
||||
// Czech
|
||||
for (int i = 0; i < 256; i++) {
|
||||
writeSint16BE(outFile, _cTableDialogCze[i]);
|
||||
writeSint16BE(outFile, _lTableDialogCze[i]);
|
||||
writeSint16BE(outFile, _cTableMaccCze[i]);
|
||||
writeSint16BE(outFile, _lTableMaccCze[i]);
|
||||
writeSint16BE(outFile, _cTableCredCze[i]);
|
||||
writeSint16BE(outFile, _lTableCredCze[i]);
|
||||
writeSint16BE(outFile, _cTableObjCze[i]);
|
||||
writeSint16BE(outFile, _lTableObjCze[i]);
|
||||
}
|
||||
|
||||
// French
|
||||
for (int i = 0; i < 256; i++) {
|
||||
writeSint16BE(outFile, _cTableDialogFra[i]);
|
||||
writeSint16BE(outFile, _lTableDialogFra[i]);
|
||||
writeSint16BE(outFile, _cTableMaccFra[i]);
|
||||
writeSint16BE(outFile, _lTableMaccFra[i]);
|
||||
writeSint16BE(outFile, _cTableCredFra[i]);
|
||||
writeSint16BE(outFile, _lTableCredFra[i]);
|
||||
writeSint16BE(outFile, _cTableObjFra[i]);
|
||||
writeSint16BE(outFile, _lTableObjFra[i]);
|
||||
}
|
||||
|
||||
// Deutsch
|
||||
for (int i = 0; i < 256; i++) {
|
||||
writeSint16BE(outFile, _cTableDialogDeu[i]);
|
||||
writeSint16BE(outFile, _lTableDialogDeu[i]);
|
||||
writeSint16BE(outFile, _cTableMaccDeu[i]);
|
||||
writeSint16BE(outFile, _lTableMaccDeu[i]);
|
||||
writeSint16BE(outFile, _cTableCredDeu[i]);
|
||||
writeSint16BE(outFile, _lTableCredDeu[i]);
|
||||
writeSint16BE(outFile, _cTableObjDeu[i]);
|
||||
writeSint16BE(outFile, _lTableObjDeu[i]);
|
||||
}
|
||||
|
||||
fclose(outFile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void writeTextArray(FILE *outFile, const char *textArray[], int nbrText) {
|
||||
int len, len1, pad;
|
||||
uint8 padBuf[DATAALIGNMENT];
|
||||
|
||||
for (int i = 0; i < DATAALIGNMENT; i++)
|
||||
padBuf[i] = 0;
|
||||
|
||||
writeUint16BE(outFile, nbrText);
|
||||
len = DATAALIGNMENT - 2;
|
||||
for (int i = 0; i < nbrText; i++) {
|
||||
len1 = strlen(textArray[i]) + 1;
|
||||
pad = DATAALIGNMENT - (len1 + 2) % DATAALIGNMENT;
|
||||
len += 2 + len1 + pad;
|
||||
}
|
||||
writeUint16BE(outFile, len);
|
||||
|
||||
fwrite(padBuf, DATAALIGNMENT - 2, 1, outFile); // padding
|
||||
for (int i = 0; i < nbrText; i++) {
|
||||
len = strlen(textArray[i]) + 1;
|
||||
pad = DATAALIGNMENT - (len + 2) % DATAALIGNMENT;
|
||||
|
||||
writeUint16BE(outFile, len + pad + 2);
|
||||
fwrite(textArray[i], len, 1, outFile);
|
||||
fwrite(padBuf, pad, 1, outFile);
|
||||
}
|
||||
}
|
44
devtools/create_tony/create_tony.h
Normal file
44
devtools/create_tony/create_tony.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* 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 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CREATE_TONY_H
|
||||
#define CREATE_TONY_H
|
||||
|
||||
#define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0])))
|
||||
|
||||
#define DATAALIGNMENT 4
|
||||
|
||||
#define TONY_DAT_VER_MAJ 0 // 1 byte
|
||||
#define TONY_DAT_VER_MIN 1 // 1 byte
|
||||
|
||||
// Number of variants of the game. For the moment, it's the same
|
||||
// as the number of languages
|
||||
#define NUM_VARIANTS 6
|
||||
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short uint16;
|
||||
typedef signed short int16;
|
||||
|
||||
void writeTextArray(FILE *outFile, const char *textData[], int nbrText);
|
||||
|
||||
#endif // CREATE_TONY_H
|
1370
devtools/create_tony/staticdata.h
Normal file
1370
devtools/create_tony/staticdata.h
Normal file
File diff suppressed because it is too large
Load diff
BIN
dists/engine-data/tony.dat
Normal file
BIN
dists/engine-data/tony.dat
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
@ -111,6 +111,10 @@ Common::Error TonyEngine::run() {
|
|||
* Initialize the game
|
||||
*/
|
||||
Common::ErrorCode TonyEngine::init() {
|
||||
// Load DAT file (used by font manager)
|
||||
if (!loadTonyDat())
|
||||
return Common::kUnknownError;
|
||||
|
||||
if (isCompressed()) {
|
||||
Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember("data1.cab");
|
||||
if (!stream)
|
||||
|
@ -177,6 +181,94 @@ Common::ErrorCode TonyEngine::init() {
|
|||
return Common::kNoError;
|
||||
}
|
||||
|
||||
bool TonyEngine::loadTonyDat() {
|
||||
Common::String msg;
|
||||
Common::File in;
|
||||
|
||||
in.open("tony.dat");
|
||||
|
||||
if (!in.isOpen()) {
|
||||
msg = "You're missing the 'tony.dat' file. Get it from the ScummVM website";
|
||||
GUIErrorMessage(msg);
|
||||
warning("%s", msg.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read header
|
||||
char buf[4+1];
|
||||
in.read(buf, 4);
|
||||
buf[4] = '\0';
|
||||
|
||||
if (strcmp(buf, "TONY")) {
|
||||
msg = "File 'tony.dat' is corrupt. Get it from the ScummVM website";
|
||||
GUIErrorMessage(msg);
|
||||
warning("%s", msg.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
int majVer = in.readByte();
|
||||
int minVer = in.readByte();
|
||||
|
||||
if ((majVer != TONY_DAT_VER_MAJ) || (minVer != TONY_DAT_VER_MIN)) {
|
||||
msg = Common::String::format("File 'tony.dat' is wrong version. Expected %d.%d but got %d.%d. Get it from the ScummVM website", TONY_DAT_VER_MAJ, TONY_DAT_VER_MIN, majVer, minVer);
|
||||
GUIErrorMessage(msg);
|
||||
warning("%s", msg.c_str());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int expectedLangVariant = -1;
|
||||
switch (g_vm->getLanguage()) {
|
||||
case Common::IT_ITA:
|
||||
expectedLangVariant = 0;
|
||||
break;
|
||||
case Common::PL_POL:
|
||||
expectedLangVariant = 1;
|
||||
break;
|
||||
case Common::RU_RUS:
|
||||
expectedLangVariant = 2;
|
||||
break;
|
||||
case Common::CZ_CZE:
|
||||
expectedLangVariant = 3;
|
||||
break;
|
||||
case Common::FR_FRA:
|
||||
expectedLangVariant = 4;
|
||||
break;
|
||||
case Common::DE_DEU:
|
||||
expectedLangVariant = 5;
|
||||
break;
|
||||
default:
|
||||
msg = Common::String::format("Font variant not present in 'tony.dat'. Get it from the ScummVM website");
|
||||
GUIErrorMessage(msg);
|
||||
warning("%s", msg.c_str());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int numVariant = in.readUint16BE();
|
||||
if (expectedLangVariant > numVariant) {
|
||||
msg = Common::String::format("Font variant not present in 'tony.dat'. Get it from the ScummVM website");
|
||||
GUIErrorMessage(msg);
|
||||
warning("%s", msg.c_str());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
in.seek(in.pos() + (2 * 256 * 8 * expectedLangVariant));
|
||||
for (int i = 0; i < 256; i++) {
|
||||
_cTableDialog[i] = in.readSint16BE();
|
||||
_lTableDialog[i] = in.readSint16BE();
|
||||
_cTableMacc[i] = in.readSint16BE();
|
||||
_lTableMacc[i] = in.readSint16BE();
|
||||
_cTableCred[i] = in.readSint16BE();
|
||||
_lTableCred[i] = in.readSint16BE();
|
||||
_cTableObj[i] = in.readSint16BE();
|
||||
_lTableObj[i] = in.readSint16BE();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TonyEngine::initCustomFunctionMap() {
|
||||
INIT_CUSTOM_FUNCTION(_funcList, _funcListStrings);
|
||||
}
|
||||
|
|
|
@ -70,6 +70,8 @@ enum {
|
|||
struct TonyGameDescription;
|
||||
|
||||
#define MAX_SFX_CHANNELS 32
|
||||
#define TONY_DAT_VER_MAJ 0
|
||||
#define TONY_DAT_VER_MIN 1
|
||||
|
||||
struct VoiceHeader {
|
||||
int _offset;
|
||||
|
@ -81,6 +83,7 @@ struct VoiceHeader {
|
|||
class TonyEngine : public Engine {
|
||||
private:
|
||||
Common::ErrorCode init();
|
||||
bool loadTonyDat();
|
||||
void initMusic();
|
||||
void closeMusic();
|
||||
bool openVoiceDatabase();
|
||||
|
@ -106,6 +109,15 @@ public:
|
|||
Globals _globals;
|
||||
Debugger *_debugger;
|
||||
|
||||
int16 _cTableDialog[256];
|
||||
int16 _lTableDialog[256];
|
||||
int16 _cTableMacc[256];
|
||||
int16 _lTableMacc[256];
|
||||
int16 _cTableCred[256];
|
||||
int16 _lTableCred[256];
|
||||
int16 _cTableObj[256];
|
||||
int16 _lTableObj[256];
|
||||
|
||||
enum DataDir {
|
||||
DD_BASE = 1,
|
||||
DD_SAVE,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue