From 2bbc1cbd6ae367eb2e36813fd8617b2c1751585c Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 27 Dec 2011 01:19:19 +0100 Subject: DREAMWEB: Clean up monitor functions --- engines/dreamweb/dreambase.h | 6 +++++ engines/dreamweb/monitor.cpp | 55 +++++++++++++++----------------------------- engines/dreamweb/print.cpp | 7 ------ engines/dreamweb/stubs.h | 24 ------------------- engines/dreamweb/use.cpp | 4 ++-- 5 files changed, 27 insertions(+), 69 deletions(-) diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h index d9b77c1ec0..340ecbb390 100644 --- a/engines/dreamweb/dreambase.h +++ b/engines/dreamweb/dreambase.h @@ -182,6 +182,12 @@ public: void showKeys(); const char *parser(); const char *searchForString(const char *topic, const char *text); + const char *getKeyAndLogo(const char *foundString); + void read(); + void dirFile(const char *dirName); + void dirCom(); + void useMon(); + bool execCommand(); // from newplace.cpp void getUnderCentre(); diff --git a/engines/dreamweb/monitor.cpp b/engines/dreamweb/monitor.cpp index eca0ff52aa..3d66a49420 100644 --- a/engines/dreamweb/monitor.cpp +++ b/engines/dreamweb/monitor.cpp @@ -38,7 +38,7 @@ static MonitorKeyEntry monitorKeyEntries[4] = { { 0, "BECKETT", "SEPTIMUS" } }; -void DreamGenContext::useMon() { +void DreamBase::useMon() { data.byte(kLasttrigger) = 0; memset(data.ptr(kCurrentfile+1, 0), ' ', 12); memset(data.ptr(offset_operand1+1, 0), ' ', 12); @@ -101,7 +101,7 @@ void DreamGenContext::useMon() { workToScreenM(); } -bool DreamGenContext::execCommand() { +bool DreamBase::execCommand() { static const char *comlist[] = { "EXIT", "HELP", @@ -232,10 +232,6 @@ void DreamBase::input() { } } -void DreamGenContext::makeCaps() { - al = makeCaps(al); -} - byte DreamBase::makeCaps(byte c) { // TODO: Replace calls to this by toupper() ? if (c >= 'a') @@ -312,10 +308,6 @@ void DreamBase::accessLightOff() { multiDump(74, 182, 12, 8); } -void DreamGenContext::randomAccess() { - randomAccess(cx); -} - void DreamBase::randomAccess(uint16 count) { for (uint16 i = 0; i < count; ++i) { vSync(); @@ -329,10 +321,6 @@ void DreamBase::randomAccess(uint16 count) { accessLightOff(); } -void DreamGenContext::monMessage() { - monMessage(al); -} - void DreamBase::monMessage(uint8 index) { assert(index > 0); const char *string = (const char *)getSegment(data.word(kTextfile1)).ptr(kTextstart, 0); @@ -436,19 +424,19 @@ void DreamBase::showKeys() { scrollMonitor(); } -bool DreamGenContext::getKeyAndLogo(const char *foundString) { +const char *DreamBase::getKeyAndLogo(const char *foundString) { byte newLogo = foundString[1] - 48; byte keyNum = foundString[3] - 48; if (monitorKeyEntries[keyNum].keyAssigned == 1) { // Key OK data.byte(kLogonum) = newLogo; - return true; + return foundString + 4; } else { monMessage(12); // "Access denied, key required -" monPrint(monitorKeyEntries[keyNum].username); scrollMonitor(); - return false; + return 0; } } @@ -476,14 +464,12 @@ const char *DreamBase::searchForString(const char *topic, const char *text) { } } -void DreamGenContext::dirCom() { +void DreamBase::dirCom() { randomAccess(30); const char *dirname = parser(); if (dirname[1]) { - es = cs; - di = offset_operand1; // cs:operand1 == dirname - dirFile(); + dirFile(dirname); return; } @@ -498,10 +484,11 @@ void DreamGenContext::dirCom() { scrollMonitor(); } -void DreamGenContext::dirFile() { - es.byte(di) = 34; +void DreamBase::dirFile(const char *dirName) { + char topic[13]; - const char *topic = (const char*)es.ptr(di, 0); + memcpy(topic, dirName, 13); + topic[0] = 34; const char *text = (const char *)getSegment(data.word(kTextfile1)).ptr(kTextstart, 0); const char *found = searchForString(topic, text); @@ -515,25 +502,22 @@ void DreamGenContext::dirFile() { } if (found) { - if (!getKeyAndLogo(found)) - return; + found = getKeyAndLogo(found); + if (!found) + return; // not logged in } else { monMessage(7); return; } // "keyok2" - memcpy(data.ptr(kCurrentfile+1, 0), data.ptr(offset_operand1+1, 0), 12); + memcpy(data.ptr(kCurrentfile+1, 0), dirName+1, 12); monitorLogo(); scrollMonitor(); monMessage(10); - byte curChar; - found += 4; // originally adjusted in getKeyAndLogo() - while (true) { - curChar = found[0]; - found++; + byte curChar = *found++; if (curChar == 34 || curChar == '*') { // "endofdir2" scrollMonitor(); @@ -545,7 +529,7 @@ void DreamGenContext::dirFile() { } } -void DreamGenContext::read() { +void DreamBase::read() { randomAccess(40); const char *name = parser(); if (name[1] == 0) { @@ -553,7 +537,7 @@ void DreamGenContext::read() { return; } - const char *topic = (const char*)cs.ptr(kCurrentfile, 0); + const char *topic = (const char*)data.ptr(kCurrentfile, 0); const char *text = (const char *)getSegment(data.word(kTextfile1)).ptr(kTextstart, 0); const char *found = searchForString(topic, text); @@ -575,8 +559,7 @@ void DreamGenContext::read() { } // "keyok1" - topic = (const char*)cs.ptr(offset_operand1, 0); - found = searchForString(topic, found); + found = searchForString(name, found); if (!found) { data.byte(kLogonum) = data.byte(kOldlogonum); monMessage(11); diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index 6cb25412dd..7edf44443f 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -204,13 +204,6 @@ uint16 DreamBase::waitFrames() { return data.word(kMousebutton); } -void DreamGenContext::monPrint() { - uint16 originalBx = bx; - const char *string = (const char *)es.ptr(bx, 0); - const char *nextString = monPrint(string); - bx = originalBx + (nextString - string); -} - const char *DreamBase::monPrint(const char *string) { data.byte(kKerning) = 1; uint16 x = data.word(kMonadx); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 79b708d7b3..ea3c17157d 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -57,23 +57,6 @@ void useRoutine(); void examineOb(bool examineAgain = true); void readSetData(); - void useMon(); - void makeCaps(); - byte makeCaps(byte c) { - return DreamBase::makeCaps(c); - } - void monPrint(); - const char *monPrint(const char *string) { - return DreamBase::monPrint(string); - } - void randomAccess(); - void randomAccess(uint16 count) { - DreamBase::randomAccess(count); - } - void monMessage(); - void monMessage(uint8 index) { - DreamBase::monMessage(index); - } void look(); void autoLook(); void doLook(); @@ -87,14 +70,7 @@ void afterNewRoom(); void madmanRun(); void showGun(); - bool execCommand(); void identifyOb(); void selectOb(); - bool getKeyAndLogo(const char *foundString); - void read(); - void dirCom(); - const char *searchForString(const char *topic, const char *text) { - return DreamBase::searchForString(topic, text); - } #endif diff --git a/engines/dreamweb/use.cpp b/engines/dreamweb/use.cpp index 25ed8d50e5..3e38215cca 100644 --- a/engines/dreamweb/use.cpp +++ b/engines/dreamweb/use.cpp @@ -25,7 +25,7 @@ namespace DreamGen { -typedef void (DreamGenContext::*UseCallback)(void); +typedef void (DreamBase::*UseCallback)(void); // Note: The callback pointer has been placed before the // ID to keep MSVC happy (otherwise, it throws warnings @@ -38,7 +38,7 @@ struct UseListEntry { void DreamGenContext::useRoutine() { static const UseListEntry kUseList[] = { - { &DreamGenContext::useMon, "NETW" }, + { &DreamBase::useMon, "NETW" }, { &DreamBase::useElevator1, "ELVA" }, { &DreamBase::useElevator2, "ELVB" }, { &DreamBase::useElevator3, "ELVC" }, -- cgit v1.2.3