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 | |
| 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
| -rw-r--r-- | engines/mads/nebular/dialogs_nebular.cpp | 39 | ||||
| -rw-r--r-- | engines/mads/nebular/dialogs_nebular.h | 30 | ||||
| -rw-r--r-- | engines/mads/nebular/game_nebular.cpp | 5 | 
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;  } | 
