Skip to content

Commit

Permalink
ACCESS: Partially implement cmdHelp
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 18, 2014
1 parent 9150e18 commit d31b27b
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 10 deletions.
6 changes: 6 additions & 0 deletions engines/access/amazon/amazon_game.cpp
Expand Up @@ -51,7 +51,9 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_rawInactiveX = 0;
_rawInactiveY = 0;
_inactiveYOff = 0;

Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
_hintLevel = 0;
}

AmazonEngine::~AmazonEngine() {
Expand Down Expand Up @@ -182,6 +184,10 @@ void AmazonEngine::setupGame() {
_player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1];
}

void AmazonEngine::drawHelp() {
error("TODO: drawHelp");
}

} // End of namespace Amazon

} // End of namespace Access
5 changes: 5 additions & 0 deletions engines/access/amazon/amazon_game.h
Expand Up @@ -93,10 +93,15 @@ class AmazonEngine : public AccessEngine {
int &_aniFlag;
int &_allenFlag;
int &_noSound;

// Other game specific fields
int _hintLevel;
public:
AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);

virtual ~AmazonEngine();

void drawHelp();
};

} // End of namespace Amazon
Expand Down
7 changes: 7 additions & 0 deletions engines/access/amazon/amazon_resources.cpp
Expand Up @@ -1187,6 +1187,13 @@ const byte FONT6x6_DATA[] = {
0x54, 0x49, 0x4f, 0x4e, 0x00, 0x4d, 0x4f, 0x56, 0x49,
};

const char *const NO_HELP_MESSAGE =
"WE ARE UNABLE TO PROVIDE YOU WITH ANY MORE HINTS. YOUR IQ \
HAS DECREASED SO FAR THAT WE CAN NO LONGER PUT THE HINTS IN TERMS \
YOU CAN UNDERSTAND.";
const char *const NO_HINTS_MESSAGE =
"THE HELP SYSTEM HAS BEEN TURNED OFF FOR THIS GAME.";

} // End of namespace Amazon

} // End of namespace Access
3 changes: 3 additions & 0 deletions engines/access/amazon/amazon_resources.h
Expand Up @@ -49,6 +49,9 @@ extern const int FONT6x6_INDEX[];

extern const byte FONT6x6_DATA[];

extern const char *const NO_HELP_MESSAGE;
extern const char *const NO_HINTS_MESSAGE;

} // End of namespace Amazon

} // End of namespace Access
Expand Down
29 changes: 26 additions & 3 deletions engines/access/amazon/amazon_scripts.cpp
Expand Up @@ -22,13 +22,16 @@

#include "common/scummsys.h"
#include "access/access.h"
#include "access/amazon/amazon_game.h"
#include "access/amazon/amazon_resources.h"
#include "access/amazon/amazon_scripts.h"

namespace Access {

namespace Amazon {

AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
_game = (AmazonEngine *)_vm;
}

void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
Expand Down Expand Up @@ -75,7 +78,7 @@ typedef void(AmazonScripts::*AmazonScriptMethodPtr)();

void AmazonScripts::executeCommand(int commandIndex) {
static const AmazonScriptMethodPtr COMMAND_LIST[] = {
&AmazonScripts::CMDHELP, &AmazonScripts::CMDCYCLEBACK,
&AmazonScripts::cmdHelp, &AmazonScripts::CMDCYCLEBACK,
&AmazonScripts::CMDCHAPTER, &AmazonScripts::cmdSetHelp,
&AmazonScripts::cmdCenterPanel, &AmazonScripts::cmdMainPanel,
&AmazonScripts::CMDRETFLASH
Expand All @@ -87,8 +90,28 @@ void AmazonScripts::executeCommand(int commandIndex) {
Scripts::executeCommand(commandIndex);
}

void AmazonScripts::CMDHELP() {
error("TODO CMDHELP");
void AmazonScripts::cmdHelp() {
Common::String helpMessage = readString();

if (_game->_helpLevel == 0) {
_game->_timers.saveTimers();
_game->_useItem = 0;

if (_game->_noHints) {
printString(NO_HELP_MESSAGE);
return;
} else if (_game->_hintLevel == 0) {
printString(NO_HINTS_MESSAGE);
return;
}
}

int level = _game->_hintLevel - 1;
if (level < _game->_helpLevel)
_game->_moreHelp = 0;

_game->drawHelp();
error("TODO: more cmdHelp");
}

void AmazonScripts::CMDCYCLEBACK() {
Expand Down
6 changes: 5 additions & 1 deletion engines/access/amazon/amazon_scripts.h
Expand Up @@ -30,12 +30,16 @@ namespace Access {

namespace Amazon {

class AmazonEngine;

class AmazonScripts: public Scripts {
private:
AmazonEngine *_game;
protected:
virtual void executeSpecial(int commandIndex, int param1, int param2);
virtual void executeCommand(int commandIndex);

void CMDHELP();
void cmdHelp();
void CMDCYCLEBACK();
void CMDCHAPTER();
void cmdSetHelp();
Expand Down
15 changes: 10 additions & 5 deletions engines/access/scripts.cpp
Expand Up @@ -180,11 +180,7 @@ void Scripts::cmdNull() {

void Scripts::cmdPrint() {
// Get a text line for display
Common::String msg;
byte c;
while ((c = (char)_data->readByte()) != '\0')
msg += c;

Common::String msg = readString();
printString(msg);
}

Expand All @@ -208,6 +204,15 @@ void Scripts::printString(const Common::String &msg) {
_vm->_screen->restoreBlock();
}

Common::String Scripts::readString() {
Common::String msg;
byte c;
while ((c = (char)_data->readByte()) != '\0')
msg += c;

return msg;
}

void Scripts::cmdRetPos() {
_endFlag = true;
_returnCode = 0;
Expand Down
12 changes: 11 additions & 1 deletion engines/access/scripts.h
Expand Up @@ -37,12 +37,22 @@ class Scripts: public Manager {
const byte *_rawData;
int _specialFunction;

void printString(const Common::String &msg);
protected:
Common::MemoryReadStream *_data;

virtual void executeSpecial(int commandIndex, int param1, int param2) = 0;
virtual void executeCommand(int commandIndex);

/**
* Print a given message to the screen in a bubble box
*/
void printString(const Common::String &msg);

/**
* Read a null terminated string from the script
*/
Common::String readString();

void CMDOBJECT();
void cmdEndObject();
void cmdJumpLook();
Expand Down

0 comments on commit d31b27b

Please sign in to comment.