diff options
author | Filippos Karapetis | 2011-12-18 20:17:55 +0200 |
---|---|---|
committer | Filippos Karapetis | 2011-12-18 20:17:55 +0200 |
commit | 25b99c448d63da48b639834d41146d2f30a11e49 (patch) | |
tree | e9a053cd4d1a5765183ad7b2ab9548d8afb91ce9 | |
parent | 833507695e9a096489cb6e3a7ca5ad854a769fc7 (diff) | |
download | scummvm-rg350-25b99c448d63da48b639834d41146d2f30a11e49.tar.gz scummvm-rg350-25b99c448d63da48b639834d41146d2f30a11e49.tar.bz2 scummvm-rg350-25b99c448d63da48b639834d41146d2f30a11e49.zip |
DREAMWEB: Rewrite signOn into C++, and remove the users and passwords from the data blob
Note that the string processing logic in signOn is a bit different from
the original, but the end result is the same (with cleaner code)
-rwxr-xr-x | devtools/tasmrecover/tasm-recover | 2 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.cpp | 183 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.h | 24 | ||||
-rw-r--r-- | engines/dreamweb/monitor.cpp | 97 | ||||
-rw-r--r-- | engines/dreamweb/stubs.h | 1 |
5 files changed, 121 insertions, 186 deletions
diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 840d961edb..102f51df46 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -56,6 +56,7 @@ p = parser(skip_binary_data = [ 'diarylist', # monitor.asm 'comlist', + 'keys', # newplace.asm 'destlist', # object.asm @@ -798,6 +799,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'showtime', 'showwatch', 'showword', + 'signon', 'singlekey', 'sitdowninbar', 'slabdoora', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 644187c558..5be71266cd 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -1773,14 +1773,14 @@ void DreamGenContext::getDestInfo() { push(ax); dx = data; es = dx; - si = 661; + si = 555; _add(si, ax); cl = es.byte(si); ax = pop(); push(cx); dx = data; es = dx; - si = 677; + si = 571; _add(si, ax); ax = pop(); } @@ -1832,7 +1832,7 @@ clearedlocations: bx = ax; dx = data; es = dx; - _add(bx, 661); + _add(bx, 555); es.byte(bx) = 0; } @@ -1852,7 +1852,7 @@ dirroot: si = offset_rootdir; _inc(si); es = cs; - di = 586; + di = 480; _inc(di); cx = 12; _movsb(cx, true); @@ -1885,107 +1885,6 @@ directloop1: goto directloop1; } -void DreamGenContext::signOn() { - STACK_CHECK; - parser(); - _inc(di); - ds = cs; - si = offset_keys; - cx = 4; -signonloop: - push(cx); - push(si); - push(di); - _add(si, 14); - cx = 11; -signonloop2: - _lodsb(); - _cmp(al, 32); - if (flags.z()) - goto foundsign; - makeCaps(); - ah = es.byte(di); - _inc(di); - _cmp(al, ah); - if (!flags.z()) - goto nomatch; - if (--cx) - goto signonloop2; -nomatch: - di = pop(); - si = pop(); - cx = pop(); - _add(si, 26); - if (--cx) - goto signonloop; - al = 13; - monMessage(); - return; -foundsign: - di = pop(); - si = pop(); - cx = pop(); - bx = si; - es = ds; - _cmp(es.byte(bx), 0); - if (flags.z()) - goto notyetassigned; - al = 17; - monMessage(); - return; -notyetassigned: - push(es); - push(bx); - scrollMonitor(); - al = 15; - monMessage(); - di = data.word(kMonadx); - bx = data.word(kMonady); - push(di); - push(bx); - input(); - bx = pop(); - di = pop(); - data.word(kMonadx) = di; - data.word(kMonady) = bx; - bx = pop(); - es = pop(); - push(es); - push(bx); - _add(bx, 2); - ds = cs; - si = 695; -checkpass: - _lodsw(); - ah = es.byte(bx); - _inc(bx); - _cmp(ah, 32); - if (flags.z()) - goto passpassed; - _cmp(al, ah); - if (flags.z()) - goto checkpass; - bx = pop(); - es = pop(); - scrollMonitor(); - al = 16; - monMessage(); - return; -passpassed: - al = 14; - monMessage(); - bx = pop(); - es = pop(); - push(es); - push(bx); - _add(bx, 14); - monPrint(); - scrollMonitor(); - bx = pop(); - es = pop(); - es.byte(bx) = 1; -} - void DreamGenContext::read() { STACK_CHECK; cx = 40; @@ -1998,7 +1897,7 @@ void DreamGenContext::read() { return; okcom: es = cs; - di = 586; + di = 480; ax = data.word(kTextfile1); data.word(kMonsource) = ax; ds = ax; @@ -2128,7 +2027,7 @@ keyok2: ds = cs; si = offset_operand1+1; es = cs; - di = 586+1; + di = 480+1; cx = 12; _movsb(cx, true); monitorLogo(); @@ -2210,7 +2109,7 @@ void DreamGenContext::parser() { al = '='; _stosb(); ds = cs; - si = 695; + si = 589; notspace1: _lodsw(); _cmp(al, 32); @@ -2393,55 +2292,41 @@ void DreamGenContext::__start() { //0x01a0: .... .... .... .... 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x44, 0x52, 0x45, 0x41, 0x4d, 0x57, 0x45, 0x42, 0x2e, //0x01b0: .... ...D REAM WEB. - 0x56, 0x39, 0x39, 0x00, 0x01, 0x00, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x20, 0x20, 0x20, - //0x01c0: V99. ..PU BLIC - 0x20, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, - //0x01d0: PU BLIC ... - 0x42, 0x4c, 0x41, 0x43, 0x4b, 0x44, 0x52, 0x41, 0x47, 0x4f, 0x4e, 0x20, 0x52, 0x59, 0x41, 0x4e, - //0x01e0: BLAC KDRA GON RYAN - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x48, 0x45, 0x4e, 0x44, 0x52, 0x49, - //0x01f0: . ..HE NDRI - 0x58, 0x20, 0x20, 0x20, 0x20, 0x20, 0x4c, 0x4f, 0x55, 0x49, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, - //0x0200: X LO UIS - 0x20, 0x00, 0x00, 0x00, 0x53, 0x45, 0x50, 0x54, 0x49, 0x4d, 0x55, 0x53, 0x20, 0x20, 0x20, 0x20, - //0x0210: ... SEPT IMUS - 0x42, 0x45, 0x43, 0x4b, 0x45, 0x54, 0x54, 0x20, 0x20, 0x20, 0x20, 0x00, 0xff, 0xff, 0x20, 0x20, - //0x0220: BECK ETT . .. - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x22, 0x52, 0x4f, 0x4f, - //0x0230: . "ROO - 0x54, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, - //0x0240: T ." - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x0d, 0x0a, 0x0d, 0x0a, 0x24, 0x10, 0x12, 0x12, - //0x0250: . .... $... - 0x11, 0x10, 0x10, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, - //0x0260: .... .... .... .... - 0x02, 0x02, 0x02, 0x02, 0x02, 0x44, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x0270: .... .D:. .... .... + 0x56, 0x39, 0x39, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + //0x01c0: V99. + 0x20, 0x00, 0x22, 0x52, 0x4f, 0x4f, 0x54, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, + //0x01d0: ."R OOT . + 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x0d, 0x0a, + //0x01e0: " ... + 0x0d, 0x0a, 0x24, 0x10, 0x12, 0x12, 0x11, 0x10, 0x10, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + //0x01f0: ..$. .... .... .... + 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x44, 0x3a, 0x00, 0x00, 0x00, + //0x0200: .... .... ...D :... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x0280: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x0290: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x02, 0x04, 0x01, 0x0a, 0x09, 0x08, 0x06, 0x0b, - //0x02a0: .... .... .... .... - 0x04, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x02b0: .... .... .... .... + //0x0210: .... .... .... .... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, + //0x0220: .... .... .... .... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x02, 0x04, + //0x0230: .... .... .... .... + 0x01, 0x0a, 0x09, 0x08, 0x06, 0x0b, 0x04, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + //0x0240: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x02c0: .... .... .... .... + //0x0250: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x02d0: .... .... .... .... + //0x0260: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x02e0: .... .... .... .... + //0x0270: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x02f0: .... .... .... .... + //0x0280: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x0300: .... .... .... .... + //0x0290: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x0310: .... .... .... .... + //0x02a0: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x0320: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, - //0x0330: .... .... .... .... - }; + //0x02b0: .... .... .... .... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, + //0x02c0: .... .... .... .... + 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, }; ds.assign(src, src + sizeof(src)); dreamweb(); } diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 6e06941d18..9b5665c0f3 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -32,9 +32,8 @@ namespace DreamGen { -static const uint16 offset_rootdir = 0x023c; -static const uint16 offset_operand1 = 0x022e; -static const uint16 offset_keys = 0x01c4; +static const uint16 offset_operand1 = 0x01c4; +static const uint16 offset_rootdir = 0x01d2; static const uint16 kStartvars = 0; static const uint16 kProgresspoints = 1; static const uint16 kWatchon = 2; @@ -356,15 +355,15 @@ static const uint16 kSoundbufferwrite = 435; static const uint16 kCurrentsample = 437; static const uint16 kRoomssample = 438; static const uint16 kBasicsample = 439; -static const uint16 kCurrentfile = 586; -static const uint16 kRoomscango = 661; -static const uint16 kRoompics = 677; -static const uint16 kOplist = 692; -static const uint16 kInputline = 695; -static const uint16 kPresslist = 823; -static const uint16 kQuitrequested = 829; -static const uint16 kSubtitles = 830; -static const uint16 kForeignrelease = 831; +static const uint16 kCurrentfile = 480; +static const uint16 kRoomscango = 555; +static const uint16 kRoompics = 571; +static const uint16 kOplist = 586; +static const uint16 kInputline = 589; +static const uint16 kPresslist = 717; +static const uint16 kQuitrequested = 723; +static const uint16 kSubtitles = 724; +static const uint16 kForeignrelease = 725; static const uint16 kBlocktextdat = (0); static const uint16 kPersonframes = (0); static const uint16 kDebuglevel1 = (0); @@ -499,7 +498,6 @@ public: void getEitherAd(); void dropObject(); void useOpened(); - void signOn(); void locationPic(); void swapWithOpen(); void dreamweb(); diff --git a/engines/dreamweb/monitor.cpp b/engines/dreamweb/monitor.cpp index dd94633105..26caeb29ec 100644 --- a/engines/dreamweb/monitor.cpp +++ b/engines/dreamweb/monitor.cpp @@ -25,33 +25,28 @@ namespace DreamGen { struct MonitorKeyEntry { - uint8 keyHeld; - uint8 b1; // unused, for alignment - char userpass[24]; - //char password[12]; // for the new monitor key list below - //char username[12]; // for the new monitor key list below + uint8 keyAssigned; + char username[12]; + char password[12]; }; -#if 0 // New monitor key list static MonitorKeyEntry monitorKeyEntries[4] = { - { 1, "PUBLIC ", "PUBLIC " }, - { 0, "BLACKDRAGON", "RYAN " }, - { 0, "HENDRIX ", "LOUIS " }, - { 0, "SEPTIMUS ", "BECKETT " } + { 1, "PUBLIC", "PUBLIC" }, + { 0, "RYAN", "BLACKDRAGON" }, + { 0, "LOUIS", "HENDRIX" }, + { 0, "BECKETT", "SEPTIMUS" } }; -#endif void DreamGenContext::useMon() { data.byte(kLasttrigger) = 0; memset(data.ptr(kCurrentfile+1, 0), ' ', 12); memset(data.ptr(offset_operand1+1, 0), ' ', 12); - MonitorKeyEntry *monitorKeyEntries = (MonitorKeyEntry *)data.ptr(offset_keys, 0); - monitorKeyEntries[0].keyHeld = 1; - monitorKeyEntries[1].keyHeld = 0; - monitorKeyEntries[2].keyHeld = 0; - monitorKeyEntries[3].keyHeld = 0; + monitorKeyEntries[0].keyAssigned = 1; + monitorKeyEntries[1].keyAssigned = 0; + monitorKeyEntries[2].keyAssigned = 0; + monitorKeyEntries[3].keyAssigned = 0; createPanel(); showPanel(); @@ -434,12 +429,9 @@ void DreamGenContext::showKeys() { scrollMonitor(); monMessage(18); - MonitorKeyEntry *monitorKeyEntries = (MonitorKeyEntry *)data.ptr(offset_keys, 0); - for (int i = 0; i < 4; i++) { - if (monitorKeyEntries[i].keyHeld) - monPrint(monitorKeyEntries[i].userpass + 12); // username - //monPrint(monitorKeyEntries[i].username); + if (monitorKeyEntries[i].keyAssigned) + monPrint(monitorKeyEntries[i].username); } scrollMonitor(); @@ -447,20 +439,77 @@ void DreamGenContext::showKeys() { void DreamGenContext::getKeyAndLogo() { byte newLogo = es.byte(bx + 1) - 48; - MonitorKeyEntry *monitorKeyEntries = (MonitorKeyEntry *)data.ptr(offset_keys, 0); byte keyNum = es.byte(bx + 1 + 2) - 48; bx += 1 + 2 + 1; - if (monitorKeyEntries[keyNum].keyHeld == 1) { + if (monitorKeyEntries[keyNum].keyAssigned == 1) { // Key OK data.byte(kLogonum) = newLogo; al = 0; } else { monMessage(12); // "Access denied, key required -" - monPrint(monitorKeyEntries[keyNum].userpass + 12); // username + monPrint(monitorKeyEntries[keyNum].username); scrollMonitor(); al = 1; } } +void DreamGenContext::signOn() { + parser(); + + int8 foundIndex = -1; + Common::String inputLine = (const char *)data.ptr(offset_operand1 + 1, 0); + inputLine.trim(); + + for (byte i = 0; i < 4; i++) { + if (inputLine.equalsIgnoreCase(monitorKeyEntries[i].username)) { + // Check if the key has already been assigned + if (monitorKeyEntries[i].keyAssigned) { + monMessage(17); + return; + } else { + foundIndex = i; + break; + } + } + } + + if (foundIndex == -1) { + monMessage(13); + return; + } + + monMessage(15); + + uint16 prevX = data.word(kMonadx); + uint16 prevY = data.word(kMonady); + input(); // password input + data.word(kMonadx) = prevX; + data.word(kMonady) = prevY; + + inputLine = (const char *)data.ptr(kInputline, 0); + inputLine.toUppercase(); + + // The entered line has zeroes in-between each character + uint32 len = strlen(monitorKeyEntries[foundIndex].password); + bool found = true; + + for (uint32 i = 0; i < len; i++) { + if (monitorKeyEntries[foundIndex].password[i] != inputLine[i * 2]) { + found = false; + break; + } + } + + if (!found) { + scrollMonitor(); + monMessage(16); + } else { + monMessage(14); + monPrint(monitorKeyEntries[foundIndex].username); + scrollMonitor(); + monitorKeyEntries[foundIndex].keyAssigned = 1; + } +} + } // End of namespace DreamGen diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 3f38ad4beb..bb86175b0d 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -373,5 +373,6 @@ void deleteExText(uint8 textNum) { DreamBase::deleteExText(textNum); } + void signOn(); #endif |