diff options
author | Eugene Sandulenko | 2008-06-07 20:47:52 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2008-06-07 20:47:52 +0000 |
commit | 09597d028c827654ab805544bb505c69302dd93a (patch) | |
tree | 94f11a5b4e99382ff5b80b0af820252a72c812ba /engines/drascula | |
parent | 9fc94f8cca3e3c70e2bf572c236a337d6cd3b1d8 (diff) | |
download | scummvm-rg350-09597d028c827654ab805544bb505c69302dd93a.tar.gz scummvm-rg350-09597d028c827654ab805544bb505c69302dd93a.tar.bz2 scummvm-rg350-09597d028c827654ab805544bb505c69302dd93a.zip |
WIP of drascula.dat loading.
DISCLAIMER: this is too far from finished. From now drascula.dat is required to
run the game, but in the meantime you have to make it by yourself. Do not
update DRASCULA_DAT_VER as I want it to be version 1 once all loading will
be implemented, but that may lead to some changes similar to r32602.
svn-id: r32603
Diffstat (limited to 'engines/drascula')
-rw-r--r-- | engines/drascula/drascula.cpp | 54 | ||||
-rw-r--r-- | engines/drascula/drascula.h | 17 | ||||
-rw-r--r-- | engines/drascula/graphics.cpp | 19 | ||||
-rw-r--r-- | engines/drascula/staticdata.h | 57 |
4 files changed, 75 insertions, 72 deletions
diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 835e893d57..e795dee46d 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -70,6 +70,8 @@ DrasculaEngine::DrasculaEngine(OSystem *syst, const DrasculaGameDescription *gam DrasculaEngine::~DrasculaEngine() { delete _rnd; + + free(_charMap); } int DrasculaEngine::init() { @@ -100,6 +102,9 @@ int DrasculaEngine::init() { _lang = 0; } + if (!loadDrasculaDat()) + return 1; + setupRoomsTable(); loadArchives(); @@ -718,4 +723,53 @@ void DrasculaEngine::hipo_sin_nadie(int counter){ updateScreen(); } +bool DrasculaEngine::loadDrasculaDat() { + Common::File in; + + in.open("drascula.dat"); + + if (!in.isOpen()) { + Common::String errorMessage = "You're missing the 'drascula.dat' file. Get it from the ScummVM website"; + GUIErrorMessage(errorMessage); + warning(errorMessage.c_str()); + + return false; + } + + char buf[256]; + int ver; + + in.read(buf, 8); + buf[8] = '\0'; + + if (strcmp(buf, "DRASCULA")) { + Common::String errorMessage = "File 'drascula.dat' is corrupt. Get it from the ScummVM website"; + GUIErrorMessage(errorMessage); + warning(errorMessage.c_str()); + + return false; + } + + ver = in.readByte(); + + if (ver != DRASCULA_DAT_VER) { + snprintf(buf, 256, "File 'drascula.dat' is wrong version. Expected %d but got %d. Get it from the ScummVM website", DRASCULA_DAT_VER, ver); + GUIErrorMessage(buf); + warning(buf); + + return false; + } + + _charMapSize = in.readUint16BE(); + _charMap = (CharInfo *)malloc(sizeof(CharInfo) * _charMapSize); + + for (int i = 0; i < _charMapSize; i++) { + _charMap[i].inChar = in.readByte(); + _charMap[i].mappedChar = in.readUint16BE(); + _charMap[i].charType = in.readByte(); + } + + return true; +} + } // End of namespace Drascula diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 8167fc136a..a5c1d4262f 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -46,6 +46,9 @@ namespace Drascula { +// Do not update this yet. The file is not loaded fully +#define DRASCULA_DAT_VER 1 + enum DrasculaGameFeatures { GF_PACKED = (1 << 0) }; @@ -174,12 +177,11 @@ struct ItemLocation { }; struct CharInfo { - int inChar; - int mappedChar; - int charType; // 0 - letters, 1 - signs, 2 - accented + byte inChar; + uint16 mappedChar; + byte charType; // 0 - letters, 1 - signs, 2 - accented }; -#define CHARMAP_SIZE 93 #define NUM_SAVES 10 #define NUM_FLAGS 50 #define DIF_MASK 55 @@ -356,6 +358,8 @@ public: int leftMouseButton; int rightMouseButton; + bool loadDrasculaDat(); + bool runCurrentChapter(); void black(); void pickObject(int); @@ -671,6 +675,9 @@ public: private: int _lang; + + CharInfo *_charMap; + int _charMapSize; }; extern const char *_text[][501]; @@ -695,8 +702,6 @@ extern const int x_pol[44], y_pol[44]; extern const int verbBarX[]; extern const int x1d_menu[], y1d_menu[]; -extern const CharInfo charMap[]; - } // End of namespace Drascula #endif /* DRASCULA_H */ diff --git a/engines/drascula/graphics.cpp b/engines/drascula/graphics.cpp index 803b26f96d..38a324fff7 100644 --- a/engines/drascula/graphics.cpp +++ b/engines/drascula/graphics.cpp @@ -234,17 +234,18 @@ void DrasculaEngine::updateScreen(int xorg, int yorg, int xdes, int ydes, int wi void DrasculaEngine::print_abc(const char *said, int screenX, int screenY) { int textPos[8]; - int letterY = 0, letterX = 0, c, i; + int letterY = 0, letterX = 0, i; uint len = strlen(said); + byte c; for (uint h = 0; h < len; h++) { c = toupper(said[h]); - for (i = 0; i < CHARMAP_SIZE; i++) { - if (c == charMap[i].inChar) { - letterX = charMap[i].mappedChar; + for (i = 0; i < _charMapSize; i++) { + if (c == _charMap[i].inChar) { + letterX = _charMap[i].mappedChar; - switch (charMap[i].charType) { + switch (_charMap[i].charType) { case 0: // letters letterY = (_lang == kSpanish) ? 149 : 158; break; @@ -301,16 +302,16 @@ void DrasculaEngine::print_abc_opc(const char *said, int screenX, int screenY, i if (c == '\'') c = '\244'; - for (int i = 0; i < CHARMAP_SIZE; i++) { - if (c == charMap[i].inChar) { + for (int i = 0; i < _charMapSize; i++) { + if (c == _charMap[i].inChar) { // Convert the mapped char of the normal font to the // mapped char of the dialogue font - int multiplier = (charMap[i].mappedChar - 6) / 9; + int multiplier = (_charMap[i].mappedChar - 6) / 9; letterX = multiplier * 7 + 10; - if (charMap[i].charType > 0) + if (_charMap[i].charType > 0) letterY = signY; break; } // if diff --git a/engines/drascula/staticdata.h b/engines/drascula/staticdata.h index dc289fb4ce..3cf8f0f2c9 100644 --- a/engines/drascula/staticdata.h +++ b/engines/drascula/staticdata.h @@ -30,63 +30,6 @@ namespace Drascula { -const CharInfo charMap[CHARMAP_SIZE] = { - // Letters - // --------------------------------------- - { 'A', 6, 0 }, { 'B', 15, 0 }, - { 'C', 24, 0 }, { 'D', 33, 0 }, - { 'E', 42, 0 }, { 'F', 51, 0 }, - { 'G', 60, 0 }, { 'H', 69, 0 }, - { 'I', 78, 0 }, { 'J', 87, 0 }, - { 'K', 96, 0 }, { 'L', 105, 0 }, - { 'M', 114, 0 }, { 'N', 123, 0 }, - { '\244', 132, 0 }, { '\245', 132, 0 }, // special Spanish char - { 'O', 141, 0 }, { 'P', 150, 0 }, - { 'Q', 159, 0 }, { 'R', 168, 0 }, - { 'S', 177, 0 }, { 'T', 186, 0 }, - { 'U', 195, 0 }, { 'V', 204, 0 }, - { 'W', 213, 0 }, { 'X', 222, 0 }, - { 'Y', 231, 0 }, { 'Z', 240, 0 }, - // --------------------------------------- - { 0xa7, 250, 0 }, { ' ', 250, 0 }, - // Signs - // --------------------------------------- - { '.', 6, 1 }, { ',', 15, 1 }, - { '-', 24, 1 }, { '?', 33, 1 }, - { '\250', 42, 1 }, { '"', 51, 1 }, - { '!', 60, 1 }, { '\255', 69, 1 }, - { ';', 78, 1 }, { '>', 87, 1 }, - { '<', 96, 1 }, { '$', 105, 1 }, - { '%', 114, 1 }, { ':', 123, 1 }, - { '&', 132, 1 }, { '/', 141, 1 }, - { '(', 150, 1 }, { ')', 159, 1 }, - { '*', 168, 1 }, { '+', 177, 1 }, - { '1', 186, 1 }, { '2', 195, 1 }, - { '3', 204, 1 }, { '4', 213, 1 }, - { '5', 222, 1 }, { '6', 231, 1 }, - { '7', 240, 1 }, { '8', 249, 1 }, - { '9', 258, 1 }, { '0', 267, 1 }, - // Accented - // --------------------------------------- - { '\240', 6, 2 }, { '\202', 15, 2 }, // A, B - { '\241', 24, 2 }, { '\242', 33, 2 }, // C, D - { '\243', 42, 2 }, { '\205', 51, 2 }, // E, F - { '\212', 60, 2 }, { '\215', 69, 2 }, // G, H - { '\225', 78, 2 }, { '\227', 87, 2 }, // I, J - { '\203', 96, 2 }, { '\210', 105, 2 }, // K, L - { '\214', 114, 2 }, { '\223', 123, 2 }, // M, N - { '\226', 132, 2 }, { '\'', 141, 2 }, // special Spanish char, O - { '\200', 150, 2 }, { '\207', 150, 2 }, // P, P - { '\265', 6, 2 }, { '\220', 15, 2 }, // A, B - { '\326', 24, 2 }, { '\340', 33, 2 }, // C, D - { '\351', 42, 2 }, { '\267', 51, 2 }, // E, F - { '\324', 60, 2 }, { '\336', 69, 2 }, // G, H - { '\343', 78, 2 }, { '\353', 87, 2 }, // I, J - { '\266', 96, 2 }, { '\322', 105, 2 }, // K, L - { '\327', 114, 2 }, { '\342', 123, 2 }, // M, N - { '\352', 132, 2 } // special Spanish char -}; - const ItemLocation itemLocations[] = { { 0, 0 }, // empty { 5, 10 }, { 50, 10 }, { 95, 10 }, // 1-3 |