aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb/monitor.cpp
diff options
context:
space:
mode:
authorMax Horn2011-12-13 13:45:47 +0100
committerWillem Jan Palenstijn2011-12-14 12:45:52 +0100
commita87a63c1bd45c925cc4d85458ccd78c82557cd18 (patch)
tree0c170ae46119b3cc2d91d1c712e5208edcccfef1 /engines/dreamweb/monitor.cpp
parent5948b5a9e3b587fa257d7dea0ec32633060bbc38 (diff)
downloadscummvm-rg350-a87a63c1bd45c925cc4d85458ccd78c82557cd18.tar.gz
scummvm-rg350-a87a63c1bd45c925cc4d85458ccd78c82557cd18.tar.bz2
scummvm-rg350-a87a63c1bd45c925cc4d85458ccd78c82557cd18.zip
DREAMWEB: Convert execCommand to C++, remove comlist from data blob
Diffstat (limited to 'engines/dreamweb/monitor.cpp')
-rw-r--r--engines/dreamweb/monitor.cpp72
1 files changed, 70 insertions, 2 deletions
diff --git a/engines/dreamweb/monitor.cpp b/engines/dreamweb/monitor.cpp
index f01664632a..dba0d56c31 100644
--- a/engines/dreamweb/monitor.cpp
+++ b/engines/dreamweb/monitor.cpp
@@ -70,6 +70,7 @@ void DreamGenContext::useMon() {
scrollMonitor();
data.word(kBufferin) = 0;
data.word(kBufferout) = 0;
+ bool stop = false;
do {
di = data.word(kMonadx);
bx = data.word(kMonady);
@@ -80,10 +81,10 @@ void DreamGenContext::useMon() {
di = pop();
data.word(kMonadx) = di;
data.word(kMonady) = bx;
- execCommand();
+ stop = execCommand();
if (quitRequested()) //TODO : Check why it crashes when put before the execcommand
break;
- } while (al == 0);
+ } while (!stop);
getRidOfTemp();
getRidOfTempCharset();
deallocateMem(data.word(kTextfile1));
@@ -97,6 +98,73 @@ void DreamGenContext::useMon() {
workToScreenM();
}
+bool DreamGenContext::execCommand() {
+ static const char *comlist[] = {
+ "EXIT",
+ "HELP",
+ "LIST",
+ "READ",
+ "LOGON",
+ "KEYS"
+ };
+
+ const char *inputLine = (const char *)data.ptr(kInputline, 64);
+ if (*inputLine == 0) {
+ // No input
+ scrollMonitor();
+ return false;
+ }
+
+ int cmd;
+ bool done = false;
+ // Loop over all commands in the list and see if we get a match
+ for (cmd = 0; cmd < ARRAYSIZE(comlist); ++cmd) {
+ const char *cmdStr = comlist[cmd];
+ const char *inputStr = inputLine;
+ // Compare the command, char by char, to see if we get a match.
+ // We only care about the prefix matching, though.
+ char inputChar, cmdChar;
+ do {
+ inputChar = *inputStr; inputStr += 2;
+ cmdChar = *cmdStr++;
+ if (cmdChar == 0) {
+ done = true;
+ break;
+ }
+ } while (inputChar == cmdChar);
+
+ if (done)
+ break;
+ }
+
+ // Execute the selected command
+ switch (cmd) {
+ case 0:
+ return true;
+ case 1:
+ monMessage(6);
+ break;
+ case 2:
+ dirCom();
+ break;
+ case 3:
+ read();
+ break;
+ case 4:
+ signOn();
+ break;
+ case 5:
+ showKeys();
+ break;
+ default:
+ netError();
+ break;
+ }
+ return false;
+}
+
+
+
void DreamGenContext::monitorLogo() {
if (data.byte(kLogonum) != data.byte(kOldlogonum)) {
data.byte(kOldlogonum) = data.byte(kLogonum);