diff options
author | Paul Gilbert | 2014-02-21 21:03:44 -0500 |
---|---|---|
committer | Paul Gilbert | 2014-02-21 21:03:44 -0500 |
commit | 40b3ab62ca8a16c2fd06bfcc691967c4f510d52a (patch) | |
tree | 9a1fa7bb691e387a4d59396e7834a3f165c77dca /engines/mads/nebular/dialogs_nebular.cpp | |
parent | 7020dbea6a56e41dc199257e898240451bb5bfb1 (diff) | |
download | scummvm-rg350-40b3ab62ca8a16c2fd06bfcc691967c4f510d52a.tar.gz scummvm-rg350-40b3ab62ca8a16c2fd06bfcc691967c4f510d52a.tar.bz2 scummvm-rg350-40b3ab62ca8a16c2fd06bfcc691967c4f510d52a.zip |
MADS: Fixes for reading in HOGANUS entries
Diffstat (limited to 'engines/mads/nebular/dialogs_nebular.cpp')
-rw-r--r-- | engines/mads/nebular/dialogs_nebular.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp index 5aede49b90..cd7ab86590 100644 --- a/engines/mads/nebular/dialogs_nebular.cpp +++ b/engines/mads/nebular/dialogs_nebular.cpp @@ -31,6 +31,45 @@ namespace MADS { namespace Nebular { +bool CopyProtectionDialog::show(MADSEngine *vm) { + CopyProtectionDialog *dlg = new CopyProtectionDialog(vm); + + delete dlg; + return true; +} + +CopyProtectionDialog::CopyProtectionDialog(MADSEngine *vm): _vm(vm) { + getHogAnusEntry(_hogEntry); +} + +bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) { + File f; + f.open("*HOGANUS.DAT"); + + // Read in the total number of entries, and randomly pick an entry to use + int numEntries = f.readUint16LE(); + int entryIndex = _vm->getRandomNumber(numEntries - 2) + 1; + + // Read in the encrypted entry + f.seek(28 * entryIndex + 2); + byte entryData[28]; + f.read(entryData, 28); + + // Decrypt it + for (int i = 0; i < 28; ++i) + entryData[i] = ~entryData[i]; + + // Fill out the fields + entry._bookId = entryData[0]; + entry._pageNum = READ_LE_UINT16(&entryData[2]); + entry._lineNum = READ_LE_UINT16(&entryData[4]); + entry._wordNum = READ_LE_UINT16(&entryData[6]); + entry._word = Common::String((char *)&entryData[8]); + + f.close(); + return true; +} + } // End of namespace Nebular |