aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision/core/events.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2014-12-26 12:41:36 +0200
committerFilippos Karapetis2014-12-26 12:41:36 +0200
commit5a72eea2bb102bafb6da112ea90ad1f4af11e1f2 (patch)
tree5bf667f3b56fb751f1a9d9bd3ea6ce752cc41c61 /engines/zvision/core/events.cpp
parent4258750f5025e471ba682945e3091fdaa50c7bc9 (diff)
downloadscummvm-rg350-5a72eea2bb102bafb6da112ea90ad1f4af11e1f2.tar.gz
scummvm-rg350-5a72eea2bb102bafb6da112ea90ad1f4af11e1f2.tar.bz2
scummvm-rg350-5a72eea2bb102bafb6da112ea90ad1f4af11e1f2.zip
ZVISION: Move some event/rendering code out of the main engine code
Diffstat (limited to 'engines/zvision/core/events.cpp')
-rw-r--r--engines/zvision/core/events.cpp37
1 files changed, 32 insertions, 5 deletions
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index 227cf213dc..70fd425949 100644
--- a/engines/zvision/core/events.cpp
+++ b/engines/zvision/core/events.cpp
@@ -39,6 +39,33 @@
namespace ZVision {
+void ZVision::pushKeyToCheatBuf(uint8 key) {
+ for (int i = 0; i < KEYBUF_SIZE - 1; i++)
+ _cheatBuffer[i] = _cheatBuffer[i + 1];
+
+ _cheatBuffer[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] != _cheatBuffer[KEYBUF_SIZE - codeLen + i] && code[i] != '?')
+ return false;
+
+ return true;
+}
+
+uint8 ZVision::getBufferedKey(uint8 pos) {
+ if (pos >= KEYBUF_SIZE)
+ return 0;
+ else
+ return _cheatBuffer[KEYBUF_SIZE - pos - 1];
+}
+
void ZVision::shortKeys(Common::Event event) {
if (event.kbd.hasFlags(Common::KBD_CTRL)) {
switch (event.kbd.keycode) {
@@ -70,11 +97,11 @@ void ZVision::cheatCodes(uint8 key) {
if (getGameId() == GID_GRANDINQUISITOR) {
if (checkCode("IMNOTDEAF")) {
// Unknown cheat
- showDebugMsg(Common::String::format("IMNOTDEAF cheat or debug, not implemented"));
+ _renderManager->showDebugMsg(Common::String::format("IMNOTDEAF cheat or debug, not implemented"));
}
if (checkCode("3100OPB")) {
- showDebugMsg(Common::String::format("Current location: %c%c%c%c",
+ _renderManager->showDebugMsg(Common::String::format("Current location: %c%c%c%c",
_scriptManager->getStateValue(StateKey_World),
_scriptManager->getStateValue(StateKey_Room),
_scriptManager->getStateValue(StateKey_Node),
@@ -101,7 +128,7 @@ void ZVision::cheatCodes(uint8 key) {
}
if (checkCode("77MASSAVE")) {
- showDebugMsg(Common::String::format("Current location: %c%c%c%c",
+ _renderManager->showDebugMsg(Common::String::format("Current location: %c%c%c%c",
_scriptManager->getStateValue(StateKey_World),
_scriptManager->getStateValue(StateKey_Room),
_scriptManager->getStateValue(StateKey_Node),
@@ -131,13 +158,13 @@ void ZVision::cheatCodes(uint8 key) {
}
if (checkCode("FRAME"))
- showDebugMsg(Common::String::format("FPS: ???, not implemented"));
+ _renderManager->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"));
+ _renderManager->showDebugMsg(Common::String::format("COMPUTERARCH: var-viewer not implemented"));
if (_scriptManager->getStateValue(StateKey_DebugCheats) == 1)
if (checkCode("GO????"))