Implement reading font data from external files for OS.

svn-id: r24714
This commit is contained in:
Eugene Sandulenko 2006-11-13 21:16:50 +00:00
parent cce7cba3b4
commit aba00bd320
3 changed files with 61 additions and 3 deletions

View File

@ -38,6 +38,7 @@
#include "cine/bg_list.h"
#include "cine/main_loop.h"
#include "cine/object.h"
#include "cine/texte.h"
#include "cine/sfx_player.h"
#include "cine/sound_driver.h"
#include "cine/various.h"
@ -68,6 +69,10 @@ CineEngine::CineEngine(OSystem *syst) : Engine(syst) {
}
CineEngine::~CineEngine() {
if (g_cine->getGameType() == Cine::GType_OS) {
freePoldatDat();
freeErrmessDat();
}
}
int CineEngine::init() {
@ -131,9 +136,8 @@ static void initialize() {
snd_loadBasesonEntries("BASESON.SND");
break;
case Cine::GType_OS:
// TODO
// load POLDAT.DAT
// load ERRMESS.DAT (default responses to actions)
loadPoldatDat("poldat.dat");
loadErrmessDat("errmess.dat");
break;
}

View File

@ -566,4 +566,54 @@ void initLanguage(Common::Language lang) {
}
}
void loadErrmessDat(const char *fname) {
Common::File in;
in.open(fname);
if (in.isOpen()) {
char **ptr = (char **)malloc(sizeof(char *) * 6 * 4 + 60 * 6 * 4);
for (int i = 0; i < 6 * 4; i++) {
ptr[i] = (char *)ptr + (sizeof(char *) * 6 * 4) + 60 * i;
in.read(ptr[i], 60);
}
failureMessages = (const char **)ptr;
in.close();
} else {
error("Cannot open file %s for reading", fname);
}
}
void freeErrmessDat() {
free(failureMessages);
failureMessages = 0;
}
void loadPoldatDat(const char *fname) {
Common::File in;
in.open(fname);
if (in.isOpen()) {
CharacterEntry *ptr = (CharacterEntry *)malloc(sizeof(CharacterEntry) * 256);
for (int i = 0; i < 256; i++) {
ptr[i].characterIdx = (int)in.readByte();
ptr[i].characterWidth = (int)in.readByte();
}
fontParamTable = ptr;
in.close();
} else {
error("Cannot open file %s for reading", fname);
}
}
void freePoldatDat() {
free((void *)fontParamTable);
fontParamTable = 0;
}
} // End of namespace Cine

View File

@ -50,6 +50,10 @@ struct CharacterEntry {
extern const CharacterEntry *fontParamTable;
void loadTextData(const char *pFileName, byte *pDestinationBuffer);
void loadErrmessDat(const char *fname);
void freeErrmessDat(void);
void loadPoldatDat(const char *fname);
void freePoldatDat(void);
} // End of namespace Cine