aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMarisa-Chan2014-11-12 15:47:27 +0600
committerMarisa-Chan2014-11-12 15:47:27 +0600
commit8e112edb1a7d8d1d579a235bda18b58ffcc18b8c (patch)
tree89769485c4f0273f1c16f99966e4574c656bb1b6 /engines
parentdb5e2adc5828a4bf888959ebd520bb43e89996fe (diff)
downloadscummvm-rg350-8e112edb1a7d8d1d579a235bda18b58ffcc18b8c.tar.gz
scummvm-rg350-8e112edb1a7d8d1d579a235bda18b58ffcc18b8c.tar.bz2
scummvm-rg350-8e112edb1a7d8d1d579a235bda18b58ffcc18b8c.zip
ZVISION: Implement Easter eggs and debug cheats
Diffstat (limited to 'engines')
-rw-r--r--engines/zvision/core/events.cpp92
-rw-r--r--engines/zvision/zvision.cpp30
-rw-r--r--engines/zvision/zvision.h11
3 files changed, 130 insertions, 3 deletions
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index c977125f55..97565dd4d7 100644
--- a/engines/zvision/core/events.cpp
+++ b/engines/zvision/core/events.cpp
@@ -30,6 +30,8 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/animation/rlf_animation.h"
#include "zvision/core/menu.h"
+#include "zvision/utility/win_keys.h"
+#include "zvision/sound/zork_raw.h"
#include "common/events.h"
#include "common/system.h"
@@ -40,6 +42,86 @@
namespace ZVision {
+void ZVision::cheatCodes(uint8 key) {
+ pushKeyToCheatBuf(key);
+
+ if (getGameId() == GID_GRANDINQUISITOR) {
+
+ if (checkCode("IMNOTDEAF")) {
+ // Unknow cheat
+ showDebugMsg(Common::String::format("IMNOTDEAF cheat or debug, not implemented"));
+ }
+
+ if (checkCode("3100OPB")) {
+ showDebugMsg(Common::String::format("Current location: %c%c%c%c",
+ _scriptManager->getStateValue(StateKey_World),
+ _scriptManager->getStateValue(StateKey_Room),
+ _scriptManager->getStateValue(StateKey_Node),
+ _scriptManager->getStateValue(StateKey_View)));
+ }
+
+ if (checkCode("KILLMENOW")) {
+ _scriptManager->changeLocation('g', 'j', 'd', 'e', 0);
+ _scriptManager->setStateValue(2201, 35);
+ }
+
+ if (checkCode("MIKESPANTS")) {
+ _scriptManager->changeLocation('g', 'j', 't', 'm', 0);
+ }
+ } else if (getGameId() == GID_NEMESIS) {
+
+ if (checkCode("CHLOE")) {
+ _scriptManager->changeLocation('t', 'm', '2', 'g', 0);
+ _scriptManager->setStateValue(224, 1);
+ }
+
+ if (checkCode("77MASSAVE")) {
+ showDebugMsg(Common::String::format("Current location: %c%c%c%c",
+ _scriptManager->getStateValue(StateKey_World),
+ _scriptManager->getStateValue(StateKey_Room),
+ _scriptManager->getStateValue(StateKey_Node),
+ _scriptManager->getStateValue(StateKey_View)));
+ }
+
+ if (checkCode("IDKFA")) {
+ _scriptManager->changeLocation('t', 'w', '3', 'f', 0);
+ _scriptManager->setStateValue(249, 1);
+ }
+
+ if (checkCode("309NEWDORMA")) {
+ _scriptManager->changeLocation('g', 'j', 'g', 'j', 0);
+ }
+
+ if (checkCode("HELLOSAILOR")) {
+ Location loc = _scriptManager->getCurrentLocation();
+ Audio::AudioStream *soundStream;
+ if (loc.world == 'v' && loc.room == 'b' && loc.node == '1' && loc.view == '0') {
+ soundStream = makeRawZorkStream("v000hpta.raw", this);
+ } else {
+ soundStream = makeRawZorkStream("v000hnta.raw", this);
+ }
+ Audio::SoundHandle handle;
+ _mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream);
+ }
+ }
+
+ if (checkCode("FRAME"))
+ showDebugMsg(Common::String::format("FPS: ???, not implemented"));
+
+ if (checkCode("XYZZY"))
+ _scriptManager->setStateValue(StateKey_DebugCheats, 1 - _scriptManager->getStateValue(StateKey_DebugCheats));
+
+ if (checkCode("COMPUTERARCH"))
+ showDebugMsg(Common::String::format("COMPUTERARCH: var-viewer not implemented"));
+
+ if (_scriptManager->getStateValue(StateKey_DebugCheats) == 1)
+ if (checkCode("GO????"))
+ _scriptManager->changeLocation(getBufferedKey(3),
+ getBufferedKey(2),
+ getBufferedKey(1),
+ getBufferedKey(0), 0);
+}
+
void ZVision::processEvents() {
while (_eventMan->pollEvent(_event)) {
switch (_event.type) {
@@ -72,7 +154,7 @@ void ZVision::processEvents() {
onMouseMove(_event.mouse);
break;
- case Common::EVENT_KEYDOWN:
+ case Common::EVENT_KEYDOWN: {
switch (_event.kbd.keycode) {
case Common::KEYCODE_d:
if (_event.kbd.hasFlags(Common::KBD_CTRL)) {
@@ -89,8 +171,14 @@ void ZVision::processEvents() {
break;
}
+ uint8 vkKey = VKkey(_event.kbd.keycode);
+
+ _scriptManager->setStateValue(StateKey_KeyPress, vkKey);
+
_scriptManager->addEvent(_event);
- break;
+ cheatCodes(vkKey);
+ }
+ break;
case Common::EVENT_KEYUP:
_scriptManager->addEvent(_event);
break;
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 0b03cc351d..3518e01d68 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -100,6 +100,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
_velocity(0) {
debug(1, "ZVision::ZVision");
+
+ memset(_cheatBuff, 0, sizeof(_cheatBuff));
}
ZVision::~ZVision() {
@@ -472,6 +474,34 @@ bool ZVision::ifQuit() {
}
return false;
}
+
+void ZVision::pushKeyToCheatBuf(uint8 key) {
+ for (int i = 0; i < KEYBUF_SIZE - 1; i++)
+ _cheatBuff[i] = _cheatBuff[i + 1];
+
+ _cheatBuff[KEYBUF_SIZE - 1] = key;
+}
+
+bool ZVision::checkCode(const char *code) {
+ int codeLen = strlen(code);
+
+ if (codeLen > KEYBUF_SIZE)
+ return false;
+
+ for (int i = 0; i < codeLen; i++)
+ if (code[i] != _cheatBuff[KEYBUF_SIZE - codeLen + i] && code[i] != '?')
+ return false;
+
+ return true;
+}
+
+uint8 ZVision::getBufferedKey(uint8 pos) {
+ if (pos >= KEYBUF_SIZE)
+ return 0;
+ else
+ return _cheatBuff[KEYBUF_SIZE - pos - 1];
+}
+
void ZVision::showDebugMsg(const Common::String &msg, int16 delay) {
uint16 msgid = _renderManager->createSubArea();
_renderManager->updateSubArea(msgid, msg);
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 3c9e26b5ec..041a8574a6 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -85,7 +85,9 @@ private:
WORKING_WINDOW_HEIGHT = 344,
ROTATION_SCREEN_EDGE_OFFSET = 60,
- MAX_ROTATION_SPEED = 400 // Pixels per second
+ MAX_ROTATION_SPEED = 400, // Pixels per second
+
+ KEYBUF_SIZE = 20
};
Console *_console;
@@ -122,6 +124,8 @@ private:
int _rendDelay;
int16 _velocity;
bool _halveDelay;
+
+ uint8 _cheatBuff[KEYBUF_SIZE];
public:
uint32 getFeatures() const;
Common::Language getLanguage() const;
@@ -205,6 +209,11 @@ private:
void updateRotation();
void registerDefaultSettings();
+
+ void cheatCodes(uint8 key);
+ void pushKeyToCheatBuf(uint8 key);
+ bool checkCode(const char *code);
+ uint8 getBufferedKey(uint8 pos);
};
} // End of namespace ZVision