MORTEVIELLE: First "English" version.

DAT file needs to be rebuilt
This commit is contained in:
Strangerke 2012-02-26 02:04:25 +01:00
parent 8072e9e97a
commit ce56512c99
6 changed files with 105 additions and 45 deletions

View File

@ -82,10 +82,15 @@ void writeFontBlock() {
outputFile.write(fontBuffer, 121 * 6);
}
void writeStaticStrings(const char **strings, int languageId) {
void writeStaticStrings(const char **strings, DataType dataType, int languageId) {
// Write out a section header
char sStaticStrings[4] = { 'S', 'S', 'T', 'R' };
outputFile.write(sStaticStrings, 4);
char sGameStrings[4] = { 'G', 'S', 'T', 'R' };
if (dataType == kStaticStrings)
outputFile.write(sStaticStrings, 4);
else if (dataType == kGameStrings)
outputFile.write(sGameStrings, 4);
// Figure out the block size
int blockSize = 1;
@ -112,22 +117,22 @@ void writeStaticStrings(const char **strings, int languageId) {
* Write out the strings previously hard-coded into the engine
*/
void writeEngineStrings() {
writeStaticStrings(engineDataEn, 1);
writeStaticStrings(engineDataFr, 0);
writeStaticStrings(engineDataEn, kStaticStrings, 1);
writeStaticStrings(engineDataFr, kStaticStrings, 0);
}
/**
* Write out the strings used in the game
*/
void writeGameStrings() {
writeStaticStrings(gameDataEn, 1);
writeStaticStrings(gameDataFr, 0);
writeStaticStrings(gameDataEn, kGameStrings, 1);
writeStaticStrings(gameDataFr, kGameStrings, 0);
}
void process() {
writeFontBlock();
writeEngineStrings();
writeGameStrings();
writeEngineStrings();
}
/**

View File

@ -31,6 +31,11 @@ enum AccessMode {
kFileWriteMode = 2
};
enum DataType {
kStaticStrings = 0,
kGameStrings = 1
};
#define MORT_DAT "mort.dat"
class File {

View File

@ -38,6 +38,7 @@
#include "mortevielle/mor.h"
#include "mortevielle/mor2.h"
#include "mortevielle/mouse.h"
#include "mortevielle/outtext.h"
#include "mortevielle/ovd1.h"
#include "mortevielle/parole2.h"
#include "mortevielle/prog.h"
@ -123,11 +124,28 @@ Common::ErrorCode MortevielleEngine::initialise() {
_currGraphicalDevice = MODE_EGA;
res = 2;
_txxFileFl = false;
// Load texts from TXX files
chartex();
// Load the mort.dat resource
Common::ErrorCode result = loadMortDat();
if (result != Common::kNoError)
return result;
// Load some error messages (was previously in chartex())
int length = 0;
char str[1410];
deline(578, str, length);
al_mess = delig;
deline(579, str, length);
err_mess = delig;
deline(580, str, length);
ind_mess = delig;
deline(581, str, length);
al_mess2 = delig;
// Set default EGA palette
_paletteManager.setDefaultPalette();
@ -138,7 +156,6 @@ Common::ErrorCode MortevielleEngine::initialise() {
_newGraphicalDevice = _currGraphicalDevice;
zuul = false;
tesok = false;
chartex();
charpal();
charge_cfiph();
charge_cfiec();
@ -202,7 +219,9 @@ Common::ErrorCode MortevielleEngine::loadMortDat() {
// Font resource
_screenSurface.readFontData(f, dataSize);
} else if (!strncmp(dataType, "SSTR", 4)) {
readStaticStrings(f, dataSize);
readStaticStrings(f, dataSize, kStaticStrings);
} else if ((!strncmp(dataType, "GSTR", 4)) && (!_txxFileFl)) {
readStaticStrings(f, dataSize, kGameStrings);
} else {
// Unknown section
f.skip(dataSize);
@ -219,7 +238,7 @@ Common::ErrorCode MortevielleEngine::loadMortDat() {
/**
* Read in a static strings block, and if the language matches, load up the static strings
*/
void MortevielleEngine::readStaticStrings(Common::File &f, int dataSize) {
void MortevielleEngine::readStaticStrings(Common::File &f, int dataSize, DataType dataType) {
// Figure out what language Id is needed
byte desiredLanguageId = (getLanguage() == Common::EN_ANY) ? LANG_ENGLISH : LANG_FRENCH;
@ -240,7 +259,11 @@ void MortevielleEngine::readStaticStrings(Common::File &f, int dataSize) {
while ((ch = (char)f.readByte()) != '\0')
s += ch;
_engineStrings.push_back(s);
if (dataType == kStaticStrings)
_engineStrings.push_back(s);
else if (dataType == kGameStrings)
_gameStrings.push_back(s);
dataSize -= s.size() + 1;
}
assert(dataSize == 0);

View File

@ -48,7 +48,8 @@ enum {
// Game languages
enum {
LANG_FRENCH = 0,
LANG_ENGLISH = 1
LANG_ENGLISH = 1,
LANG_GERMAN = 2
};
// Static string list
@ -65,6 +66,11 @@ enum {
S_SMELL = 40, S_SCRATCH = 41, S_PROBE2 = 42, S_BEFORE_USE_DEP_MENU = 43, S_DAY = 44
};
enum DataType {
kStaticStrings = 0,
kGameStrings = 1
};
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 400
#define SCREEN_ORIG_HEIGHT 200
@ -81,10 +87,10 @@ private:
Common::Point _mousePos;
bool _inMainGameLoop; // Flag when the main game loop is active
Common::StringArray _engineStrings;
Common::StringArray _gameStrings;
Common::ErrorCode initialise();
Common::ErrorCode loadMortDat();
void readStaticStrings(Common::File &f, int dataSize);
void readStaticStrings(Common::File &f, int dataSize, DataType dataType);
void loadFont(Common::File &f);
bool handleEvents();
void addKeypress(Common::Event &evt);
@ -105,6 +111,7 @@ public:
bool _quitGame; // Quit game flag. Originally called 'arret'
bool _endGame; // End game flag. Originally called 'solu'
bool _loseGame; // Lose game flag. Originally called 'perdu'
bool _txxFileFl; // Flag used to determine if texts are from the original files or from a DAT file
public:
MortevielleEngine(OSystem *system, const ADGameDescription *gameDesc);
~MortevielleEngine();
@ -125,6 +132,7 @@ public:
void setMouseClick(bool v) { _mouseClick = v; }
void delay(int amount);
Common::String getEngineString(int idx) const { return _engineStrings[idx]; }
Common::String getGameString(int idx) const { return _gameStrings[idx]; }
void endGame();
void loseGame();

View File

@ -132,6 +132,16 @@ void deline(int num, char *line , int &length) {
return;
}
if (!g_vm->_txxFileFl) {
delig = g_vm->getGameString(num);
if (line) {
strcpy(line, delig.c_str());
length = delig.size();
}
return;
}
// DETEX
delig = "";
int ts = t_rec[num].indis;
@ -155,6 +165,8 @@ void deline(int num, char *line , int &length) {
if (length < 255)
// Remove trailing '$'
delig.deleteLastChar();
warning("deline: delig %s - line %s", delig.c_str(), line);
}

View File

@ -100,45 +100,52 @@ void charpal() {
}
void chartex() {
Common::File f;
Common::File inpFile;
Common::File ntpFile;
char s[1410];
/* debug('o3 chartex'); */
if (!f.open("TXX.INP"))
if (!f.open("TXX.MOR"))
error("Missing file - TXX.INP or .MOR");
assert(f.size() <= (maxti * 2));
for (int i = 0; i < f.size() / 2; ++i)
t_mot[i] = f.readUint16LE();
f.close();
if (!f.open("TXX.NTP"))
if (!f.open("TXX.IND"))
error("Missing file - TXX.NTP or .IND");
assert(f.size() <= (maxtd * 3));
int i;
for (i = 0; i < (f.size() / 3); ++i) {
t_rec[i].indis = f.readSint16LE();
t_rec[i].point = f.readByte();
g_vm->_txxFileFl = false;
if (g_vm->getLanguage() == Common::EN_ANY) {
warning("English version expected - Switching to DAT file");
return;
}
f.close();
if (!inpFile.open("TXX.INP")) {
if (!inpFile.open("TXX.MOR")) {
warning("Missing file - TXX.INP or .MOR - Switching to DAT file");
return;
}
}
deline(578, s, i);
al_mess = delig;
deline(579, s, i);
err_mess = delig;
deline(580, s, i);
ind_mess = delig;
deline(581, s, i);
al_mess2 = delig;
if (!ntpFile.open("TXX.NTP")) {
if (!ntpFile.open("TXX.IND")) {
warning("Missing file - TXX.NTP or .IND - Switching to DAT file");
return;
}
}
if ((inpFile.size() > (maxti * 2)) || (ntpFile.size() > (maxtd * 3))) {
warning("TXX file - Unexpected format - Switching to DAT file");
return;
}
for (int i = 0; i < inpFile.size() / 2; ++i)
t_mot[i] = inpFile.readUint16LE();
inpFile.close();
for (int i = 0; i < (ntpFile.size() / 3); ++i) {
t_rec[i].indis = ntpFile.readSint16LE();
t_rec[i].point = ntpFile.readByte();
}
ntpFile.close();
g_vm->_txxFileFl = true;
}
/**
* The original engine used this method to display a starting text screen letting the palyer
* The original engine used this method to display a starting text screen letting the player
* select the graphics mode to use
*/
void dialpre() {