aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mads/nebular/dialogs_nebular.cpp39
-rw-r--r--engines/mads/nebular/dialogs_nebular.h30
-rw-r--r--engines/mads/nebular/game_nebular.cpp5
3 files changed, 68 insertions, 6 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
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index a747f7575d..6417c2cdc3 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef MADS_GAME_NEBULAR_H
-#define MADS_GAME_NEBULAR_H
+#ifndef MADS_DIALOGS_NEBULAR_H
+#define MADS_DIALOGS_NEBULAR_H
#include "common/scummsys.h"
#include "mads/game.h"
@@ -30,15 +30,37 @@ namespace MADS {
namespace Nebular {
+struct HOGANUS {
+ int _bookId;
+ int _pageNum;
+ int _lineNum;
+ int _wordNum;
+ Common::String _word;
+};
+
class CopyProtectionDialog {
private:
+ MADSEngine *_vm;
+ HOGANUS _hogEntry;
+
+ /**
+ * Constructor
+ */
+ CopyProtectionDialog(MADSEngine *vm);
+ /**
+ * Get a random copy protection entry from the HOGANUS resource
+ */
+ bool getHogAnusEntry(HOGANUS &entry);
public:
- static bool show() { return false; }
+ /**
+ * Show the dialog
+ */
+ static bool show(MADSEngine *vm);
};
} // End of namespace Nebular
} // End of namespace MADS
-#endif /* MADS_GAME_NEBULAR_H */
+#endif /* MADS_DIALOGS_NEBULAR_H */
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 43d705fcf8..10c210c6eb 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -27,6 +27,7 @@
#include "mads/graphics.h"
#include "mads/msurface.h"
#include "mads/nebular/game_nebular.h"
+#include "mads/nebular/dialogs_nebular.h"
namespace MADS {
@@ -37,10 +38,10 @@ GameNebular::GameNebular(MADSEngine *vm): Game(vm) {
}
bool GameNebular::checkCopyProtection() {
- if (!ConfMan.getBool("copy_protection") || (ConfMan.hasKey("passed_protection") &&
- ConfMan.getInt("passed_protection") == 1))
+ if (!ConfMan.getBool("copy_protection"))
return true;
+ CopyProtectionDialog::show(_vm);
return false;
}