diff options
Diffstat (limited to 'engines/dreamweb/people.cpp')
-rw-r--r-- | engines/dreamweb/people.cpp | 904 |
1 files changed, 618 insertions, 286 deletions
diff --git a/engines/dreamweb/people.cpp b/engines/dreamweb/people.cpp index 889a430a22..dfb5c62618 100644 --- a/engines/dreamweb/people.cpp +++ b/engines/dreamweb/people.cpp @@ -22,153 +22,191 @@ #include "dreamweb/dreamweb.h" -namespace DreamGen { - -static void (DreamGenContext::*reelCallbacks[57])() = { - NULL, NULL, - NULL, NULL, - NULL, NULL, - NULL, NULL, - &DreamGenContext::receptionist, NULL, - NULL, NULL, - NULL, NULL, - NULL, NULL, - &DreamGenContext::heavy, NULL, - NULL, NULL, - &DreamGenContext::bartender, NULL, - NULL, NULL, - NULL, NULL, - NULL, NULL, - NULL, &DreamGenContext::poolGuard, - NULL, &DreamGenContext::businessMan, - NULL, NULL, - &DreamGenContext::mugger, &DreamGenContext::helicopter, - NULL, NULL, - NULL, NULL, - NULL, NULL, - NULL, NULL, - NULL, NULL, - NULL, &DreamGenContext::endGameSeq, - NULL, NULL, - NULL, NULL, - NULL, NULL, - NULL, NULL, - NULL +namespace DreamWeb { + +static void (DreamWebEngine::*reelCallbacks[57])(ReelRoutine &) = { + &DreamWebEngine::gamer, &DreamWebEngine::sparkyDrip, + &DreamWebEngine::eden, &DreamWebEngine::edenInBath, + &DreamWebEngine::sparky, &DreamWebEngine::smokeBloke, + &DreamWebEngine::manAsleep, &DreamWebEngine::drunk, + &DreamWebEngine::receptionist, &DreamWebEngine::genericPerson /*maleFan*/, + &DreamWebEngine::genericPerson /*femaleFan*/, &DreamWebEngine::louis, + &DreamWebEngine::louisChair, &DreamWebEngine::soldier1, + &DreamWebEngine::bossMan, &DreamWebEngine::interviewer, + &DreamWebEngine::heavy, &DreamWebEngine::manAsleep /*manAsleep2*/, + &DreamWebEngine::genericPerson /*manSatStill*/, &DreamWebEngine::drinker, + &DreamWebEngine::bartender, &DreamWebEngine::genericPerson /*otherSmoker*/, + &DreamWebEngine::genericPerson /*tattooMan*/, &DreamWebEngine::attendant, + &DreamWebEngine::keeper, &DreamWebEngine::candles1, + &DreamWebEngine::smallCandle, &DreamWebEngine::security, + &DreamWebEngine::copper, &DreamWebEngine::poolGuard, + &DreamWebEngine::rockstar, &DreamWebEngine::businessMan, + &DreamWebEngine::train, &DreamWebEngine::genericPerson /*aide*/, + &DreamWebEngine::mugger, &DreamWebEngine::helicopter, + &DreamWebEngine::introMagic1, &DreamWebEngine::introMusic, + &DreamWebEngine::introMagic2, &DreamWebEngine::candles2, + &DreamWebEngine::gates, &DreamWebEngine::introMagic3, + &DreamWebEngine::introMonks1, &DreamWebEngine::candles, + &DreamWebEngine::introMonks2, &DreamWebEngine::handClap, + &DreamWebEngine::monkAndRyan, &DreamWebEngine::endGameSeq, + &DreamWebEngine::priest, &DreamWebEngine::madman, + &DreamWebEngine::madmansTelly, &DreamWebEngine::alleyBarkSound, + &DreamWebEngine::foghornSound, &DreamWebEngine::carParkDrip, + &DreamWebEngine::carParkDrip, &DreamWebEngine::carParkDrip, + &DreamWebEngine::carParkDrip }; -static void (DreamGenContext::*reelCallbacksCPP[57])(ReelRoutine &) = { - &DreamGenContext::gamer, &DreamGenContext::sparkyDrip, - &DreamGenContext::eden, &DreamGenContext::edenInBath, - &DreamGenContext::sparky, &DreamGenContext::smokeBloke, - &DreamGenContext::manAsleep, &DreamGenContext::drunk, - /*&DreamGenContext::receptionist*/NULL, &DreamGenContext::genericPerson /*maleFan*/, - &DreamGenContext::genericPerson /*femaleFan*/, &DreamGenContext::louis, - &DreamGenContext::louisChair, &DreamGenContext::soldier1, - &DreamGenContext::bossMan, &DreamGenContext::interviewer, - /*&DreamGenContext::heavy*/NULL, &DreamGenContext::manAsleep /*manAsleep2*/, - &DreamGenContext::genericPerson /*manSatStill*/, &DreamGenContext::drinker, - /*&DreamGenContext::bartender*/NULL, &DreamGenContext::genericPerson /*otherSmoker*/, - &DreamGenContext::genericPerson /*tattooMan*/, &DreamGenContext::attendant, - &DreamGenContext::keeper, &DreamGenContext::candles1, - &DreamGenContext::smallCandle, &DreamGenContext::security, - &DreamGenContext::copper, /*&DreamGenContext::poolGuard*/NULL, - &DreamGenContext::rockstar, /*&DreamGenContext::businessMan*/NULL, - &DreamGenContext::train, &DreamGenContext::genericPerson /*aide*/, - /*&DreamGenContext::mugger*/NULL, /*&DreamGenContext::helicopter*/NULL, - &DreamGenContext::introMagic1, &DreamGenContext::introMusic, - &DreamGenContext::introMagic2, &DreamGenContext::candles2, - &DreamGenContext::gates, &DreamGenContext::introMagic3, - &DreamGenContext::introMonks1, &DreamGenContext::candles, - &DreamGenContext::introMonks2, &DreamGenContext::handClap, - &DreamGenContext::monkAndRyan, /*&DreamGenContext::endGameSeq*/NULL, - &DreamGenContext::priest, &DreamGenContext::madman, - &DreamGenContext::madmansTelly, &DreamGenContext::alleyBarkSound, - &DreamGenContext::foghornSound, &DreamGenContext::carParkDrip, - &DreamGenContext::carParkDrip, &DreamGenContext::carParkDrip, - &DreamGenContext::carParkDrip +static const ReelRoutine g_initialReelRoutines[] = { +// Room number and x,y +// reel pointer +// speed,speed count,convers. no. + { 1,44,0, 20, 2,0,1 }, + { 1,55,0, 0, 50,20,0 }, + { 24,22,0, 74, 1,0,0 }, + { 24,33,10, 75, 1,0,1 }, + { 1,44,0, 27, 2,0,2 }, + { 1,44,0, 96, 3,0,4 }, + { 1,44,0, 118, 2,0,5 }, + { 1,44,10, 0, 2,0,0 }, + { 5,22,20, 53, 3,0,0 }, + { 5,22,20, 40, 1,0,2 }, + { 5,22,20, 50, 1,0,3 }, + { 2,11,10, 192, 1,0,0 }, + { 2,11,10, 182, 2,0,1 }, + { 8,11,10, 0, 2,0,1 }, + { 23,0,50, 0, 3,0,0 }, + { 28,11,20, 250, 4,0,0 }, + { 23,0,50, 43, 2,0,8 }, + { 23,11,40, 130, 2,0,1 }, + { 23,22,40, 122, 2,0,2 }, + { 23,22,40, 105, 2,0,3 }, + { 23,22,40, 81, 2,0,4 }, + { 23,11,40, 135, 2,0,5 }, + { 23,22,40, 145, 2,0,6 }, + { 4,22,30, 0, 2,0,0 }, + { 45,22,30, 200, 0,0,20 }, + { 45,22,30, 39, 2,0,0 }, + { 45,22,30, 25, 2,0,0 }, + { 8,22,40, 32, 2,0,0 }, + { 7,11,20, 64, 2,0,0 }, + { 22,22,20, 82, 2,0,0 }, + { 27,11,30, 0, 2,0,0 }, + { 20,0,30, 0, 2,0,0 }, + { 14,33,40, 21, 1,0,0 }, + { 29,11,10, 0, 1,0,0 }, + { 2,22,0, 2, 2,0,0 }, + { 25,0,50, 4, 2,0,0 }, + { 50,22,30, 121, 2,0,0 }, + { 50,22,30, 0, 20,0,0 }, + { 52,22,30, 192, 2,0,0 }, + { 52,22,30, 233, 2,0,0 }, + { 50,22,40, 104, 55,0,0 }, // ...., 65,0,0 for German CD + { 53,33,0, 99, 2,0,0 }, + { 50,22,40, 0, 3,0,0 }, + { 50,22,30, 162, 2,0,0 }, + { 52,22,30, 57, 2,0,0 }, + { 52,22,30, 0, 2,0,0 }, + { 54,0,0, 72, 3,0,0 }, + { 55,44,0, 0, 2,0,0 }, + { 19,0,0, 0, 28,0,0 }, + { 14,22,0, 2, 2,0,0 }, + { 14,22,0, 300, 1,0,0 }, + { 10,22,30, 174, 0,0,0 }, + { 12,22,20, 0, 1,0,0 }, + { 11,11,20, 0, 50,20,0 }, + { 11,11,30, 0, 50,20,0 }, + { 11,22,20, 0, 50,20,0 }, + { 14,33,40, 0, 50,20,0 }, + { 255,0,0, 0, 0,0,0 } }; -void DreamGenContext::updatePeople() { - data.word(kListpos) = kPeoplelist; - memset(getSegment(data.word(kBuffers)).ptr(kPeoplelist, 12 * sizeof(People)), 0xff, 12 * sizeof(People)); - ++data.word(kMaintimer); - - // The original callbacks are called with es:bx pointing to their reelRoutine entry. - // The new callbacks take a mutable ReelRoutine parameter. - - es = data; - ReelRoutine *r = (ReelRoutine *)data.ptr(kReelroutines, 0); - - for (int i = 0; r[i].reallocation != 255; ++i) { - bx = kReelroutines + 8*i; - if (r[i].reallocation == data.byte(kReallocation) && - r[i].mapX == data.byte(kMapx) && - r[i].mapY == data.byte(kMapy)) { - if (reelCallbacks[i]) { - assert(!reelCallbacksCPP[i]); - (this->*(reelCallbacks[i]))(); - } else { - assert(reelCallbacksCPP[i]); - (this->*(reelCallbacksCPP[i]))(r[i]); - } +void DreamWebEngine::setupInitialReelRoutines() { + for (unsigned int i = 0; i < kNumReelRoutines + 1; ++i) { + _reelRoutines[i] = g_initialReelRoutines[i]; + if (_reelRoutines[i].period == 55 && hasSpeech() && getLanguage() == Common::DE_DEU) + _reelRoutines[i].period = 65; + } +} + +void DreamWebEngine::updatePeople() { + _peopleList.clear(); + ++_mainTimer; + + for (int i = 0; _reelRoutines[i].reallocation != 255; ++i) { + if (_reelRoutines[i].reallocation == _realLocation && + _reelRoutines[i].mapX == _mapX && + _reelRoutines[i].mapY == _mapY) { + assert(reelCallbacks[i]); + (this->*(reelCallbacks[i]))(_reelRoutines[i]); } } } -void DreamGenContext::madmanText() { - if (isCD()) { - if (data.byte(kSpeechcount) >= 63) +void DreamWebEngine::madmanText() { + byte origCount; + + uint16 length = 90; + if (hasSpeech()) { + if (_speechCount > 15) return; - if (data.byte(kCh1playing) != 255) + if (_channel1Playing != 255) return; - al = data.byte(kSpeechcount); - ++data.byte(kSpeechcount); + origCount = _speechCount; + ++_speechCount; + + if (origCount != 15) + length = 32000; // Set subtitle time very high to make it + // always wait for the next line, except for the + // last one, when there is no next line. } else { - if (data.byte(kCombatcount) >= 61) + if (_vars._combatCount >= 61) return; - al = data.byte(kCombatcount); - _and(al, 3); - if (!flags.z()) + if (_vars._combatCount & 3) return; - al = data.byte(kCombatcount) / 4; + origCount = _vars._combatCount / 4; } - setupTimedTemp(47 + al, 82, 72, 80, 90, 1); + setupTimedTemp(47 + origCount, 82, 72, 80, length, 1); } -void DreamGenContext::madman(ReelRoutine &routine) { - data.word(kWatchingtime) = 2; +void DreamWebEngine::madman(ReelRoutine &routine) { + _vars._watchingTime = 2; if (checkSpeed(routine)) { uint16 newReelPointer = routine.reelPointer(); if (newReelPointer >= 364) { - data.byte(kMandead) = 2; + _vars._manDead = 2; showGameReel(&routine); return; } if (newReelPointer == 10) { - loadTempText("DREAMWEB.T82"); - data.byte(kCombatcount) = (uint8)-1; - data.byte(kSpeechcount) = 0; + loadTempText("T82"); + _vars._combatCount = (uint8)-1; + _speechCount = 0; } ++newReelPointer; if (newReelPointer == 294) { - if (data.byte(kWongame) != 1) { - data.byte(kWongame) = 1; + if (!_wonGame) { + _wonGame = true; getRidOfTempText(); } return; } if (newReelPointer == 66) { - ++data.byte(kCombatcount); + ++_vars._combatCount; + + if (_lastHardKey == 1) // ESC pressed, skip the mad man's speech + _vars._combatCount = _speechCount = (hasSpeech() ? 65 : 63); + madmanText(); newReelPointer = 53; - if (data.byte(kCombatcount) >= (isCD() ? 64 : 62)) { - if (data.byte(kCombatcount) == (isCD() ? 70 : 68)) + + if (_vars._combatCount >= (hasSpeech() ? 64 : 62)) { + if (_vars._combatCount == (hasSpeech() ? 70 : 68)) newReelPointer = 310; else { - if (data.byte(kLastweapon) == 8) { - data.byte(kCombatcount) = isCD() ? 72 : 70; - data.byte(kLastweapon) = (uint8)-1; - data.byte(kMadmanflag) = 1; + if (_vars._lastWeapon == 8) { + _vars._combatCount = hasSpeech() ? 72 : 70; + _vars._lastWeapon = (uint8)-1; + _vars._madmanFlag = 1; newReelPointer = 67; } } @@ -177,41 +215,31 @@ void DreamGenContext::madman(ReelRoutine &routine) { routine.setReelPointer(newReelPointer); } showGameReel(&routine); - routine.mapX = data.byte(kMapx); + routine.mapX = _mapX; madMode(); } -void DreamGenContext::madMode() { - data.word(kWatchingtime) = 2; - data.byte(kPointermode) = 0; - if (data.byte(kCombatcount) < (isCD() ? 65 : 63)) +void DreamWebEngine::madMode() { + _vars._watchingTime = 2; + _pointerMode = 0; + if (_vars._combatCount < (hasSpeech() ? 65 : 63)) return; - if (data.byte(kCombatcount) >= (isCD() ? 70 : 68)) + if (_vars._combatCount >= (hasSpeech() ? 70 : 68)) return; - data.byte(kPointermode) = 2; + _pointerMode = 2; } -void DreamGenContext::addToPeopleList() { - addToPeopleList((ReelRoutine *)es.ptr(bx, sizeof(ReelRoutine))); -} +void DreamWebEngine::addToPeopleList(ReelRoutine *routine) { + People people; + people._reelPointer = routine->reelPointer(); + people._routinePointer = routine; + people.b4 = routine->b7; -void DreamGenContext::addToPeopleList(ReelRoutine *routine) { - uint16 routinePointer = (const uint8 *)routine - data.ptr(0, 0); - - People *people = (People *)getSegment(data.word(kBuffers)).ptr(data.word(kListpos), sizeof(People)); - people->setReelPointer(routine->reelPointer()); - people->setRoutinePointer(routinePointer); - people->b4 = routine->b7; - data.word(kListpos) += sizeof(People); + _peopleList.push_back(people); } -void DreamGenContext::checkSpeed() { - ReelRoutine *routine = (ReelRoutine *)es.ptr(bx, sizeof(ReelRoutine)); - flags._z = checkSpeed(*routine); -} - -bool DreamGenContext::checkSpeed(ReelRoutine &routine) { - if (data.byte(kLastweapon) != (uint8)-1) +bool DreamWebEngine::checkSpeed(ReelRoutine &routine) { + if (_vars._lastWeapon != (uint8)-1) return true; ++routine.counter; if (routine.counter != routine.period) @@ -220,21 +248,21 @@ bool DreamGenContext::checkSpeed(ReelRoutine &routine) { return true; } -void DreamGenContext::sparkyDrip(ReelRoutine &routine) { +void DreamWebEngine::sparkyDrip(ReelRoutine &routine) { if (checkSpeed(routine)) playChannel0(14, 0); } -void DreamGenContext::genericPerson(ReelRoutine &routine) { +void DreamWebEngine::genericPerson(ReelRoutine &routine) { showGameReel(&routine); addToPeopleList(&routine); } -void DreamGenContext::gamer(ReelRoutine &routine) { +void DreamWebEngine::gamer(ReelRoutine &routine) { if (checkSpeed(routine)) { uint8 v; do { - v = 20 + engine->randomNumber() % 5; + v = _rnd.getRandomNumberRng(20, 24); } while (v == routine.reelPointer()); routine.setReelPointer(v); } @@ -243,19 +271,19 @@ void DreamGenContext::gamer(ReelRoutine &routine) { addToPeopleList(&routine); } -void DreamGenContext::eden(ReelRoutine &routine) { - if (data.byte(kGeneraldead)) +void DreamWebEngine::eden(ReelRoutine &routine) { + if (_vars._generalDead) return; showGameReel(&routine); addToPeopleList(&routine); } -void DreamGenContext::sparky(ReelRoutine &routine) { - if (data.word(kCard1money)) +void DreamWebEngine::sparky(ReelRoutine &routine) { + if (_vars._card1Money) routine.b7 = 3; if (checkSpeed(routine)) { - if (routine.reelPointer() != 34) { - if (engine->randomNumber() < 30) + if (routine.reelPointer() == 34) { + if (randomNumber() < 30) routine.incReelPointer(); else routine.setReelPointer(27); @@ -269,29 +297,29 @@ void DreamGenContext::sparky(ReelRoutine &routine) { showGameReel(&routine); addToPeopleList(&routine); if (routine.b7 & 128) - data.byte(kTalkedtosparky) = 1; + _vars._talkedToSparky = 1; } -void DreamGenContext::rockstar(ReelRoutine &routine) { +void DreamWebEngine::rockstar(ReelRoutine &routine) { if ((routine.reelPointer() == 303) || (routine.reelPointer() == 118)) { - data.byte(kNewlocation) = 45; + _newLocation = 45; showGameReel(&routine); return; } if (checkSpeed(routine)) { uint16 nextReelPointer = routine.reelPointer() + 1; if (nextReelPointer == 118) { - data.byte(kMandead) = 2; + _vars._manDead = 2; } else if (nextReelPointer == 79) { --nextReelPointer; - if (data.byte(kLastweapon) != 1) { - ++data.byte(kCombatcount); - if (data.byte(kCombatcount) == 40) { - data.byte(kCombatcount) = 0; + if (_vars._lastWeapon != 1) { + ++_vars._combatCount; + if (_vars._combatCount == 40) { + _vars._combatCount = 0; nextReelPointer = 79; } } else { - data.byte(kLastweapon) = (uint8)-1; + _vars._lastWeapon = (uint8)-1; nextReelPointer = 123; } } @@ -300,16 +328,16 @@ void DreamGenContext::rockstar(ReelRoutine &routine) { showGameReel(&routine); if (routine.reelPointer() == 78) { addToPeopleList(&routine); - data.byte(kPointermode) = 2; - data.word(kWatchingtime) = 0; + _pointerMode = 2; + _vars._watchingTime = 0; } else { - data.word(kWatchingtime) = 2; - data.byte(kPointermode) = 0; - routine.mapY = data.byte(kMapy); + _vars._watchingTime = 2; + _pointerMode = 0; + routine.mapY = _mapY; } } -void DreamGenContext::madmansTelly(ReelRoutine &routine) { +void DreamWebEngine::madmansTelly(ReelRoutine &routine) { uint16 nextReelPointer = routine.reelPointer() + 1; if (nextReelPointer == 307) nextReelPointer = 300; @@ -318,14 +346,14 @@ void DreamGenContext::madmansTelly(ReelRoutine &routine) { } -void DreamGenContext::smokeBloke(ReelRoutine &routine) { - if (data.byte(kRockstardead) == 0) { +void DreamWebEngine::smokeBloke(ReelRoutine &routine) { + if (_vars._rockstarDead == 0) { if (routine.b7 & 128) setLocation(5); } if (checkSpeed(routine)) { if (routine.reelPointer() == 100) { - if (engine->randomNumber() < 30) + if (randomNumber() < 30) routine.incReelPointer(); else routine.setReelPointer(96); @@ -338,46 +366,46 @@ void DreamGenContext::smokeBloke(ReelRoutine &routine) { addToPeopleList(&routine); } -void DreamGenContext::manAsleep(ReelRoutine &routine) { +void DreamWebEngine::manAsleep(ReelRoutine &routine) { routine.b7 &= 127; showGameReel(&routine); addToPeopleList(&routine); } -void DreamGenContext::attendant(ReelRoutine &routine) { +void DreamWebEngine::attendant(ReelRoutine &routine) { showGameReel(&routine); addToPeopleList(&routine); if (routine.b7 & 128) - data.byte(kTalkedtoattendant) = 1; + _vars._talkedToAttendant = 1; } -void DreamGenContext::keeper(ReelRoutine &routine) { - if (data.byte(kKeeperflag) != 0) { +void DreamWebEngine::keeper(ReelRoutine &routine) { + if (_vars._keeperFlag != 0) { // Not waiting addToPeopleList(&routine); showGameReel(&routine); return; } - if (data.word(kReeltowatch) < 190) + if (_vars._reelToWatch < 190) return; // waiting - data.byte(kKeeperflag)++; + _vars._keeperFlag++; - if ((routine.b7 & 127) != data.byte(kDreamnumber)) - routine.b7 = data.byte(kDreamnumber); + if ((routine.b7 & 127) != _vars._dreamNumber) + routine.b7 = _vars._dreamNumber; } -void DreamGenContext::drunk(ReelRoutine &routine) { - if (data.byte(kGeneraldead)) +void DreamWebEngine::drunk(ReelRoutine &routine) { + if (_vars._generalDead) return; routine.b7 &= 127; showGameReel(&routine); addToPeopleList(&routine); } -void DreamGenContext::interviewer(ReelRoutine &routine) { - if (data.word(kReeltowatch) == 68) +void DreamWebEngine::interviewer(ReelRoutine &routine) { + if (_vars._reelToWatch == 68) routine.incReelPointer(); if (routine.reelPointer() != 250 && routine.reelPointer() != 259 && checkSpeed(routine)) @@ -386,12 +414,12 @@ void DreamGenContext::interviewer(ReelRoutine &routine) { showGameReel(&routine); } -void DreamGenContext::drinker(ReelRoutine &routine) { +void DreamWebEngine::drinker(ReelRoutine &routine) { if (checkSpeed(routine)) { routine.incReelPointer(); if ( routine.reelPointer() == 115 || - (routine.reelPointer() == 106 && engine->randomNumber() >= 3)) + (routine.reelPointer() == 106 && randomNumber() >= 3)) routine.setReelPointer(105); } @@ -399,7 +427,7 @@ void DreamGenContext::drinker(ReelRoutine &routine) { addToPeopleList(&routine); } -void DreamGenContext::alleyBarkSound(ReelRoutine &routine) { +void DreamWebEngine::alleyBarkSound(ReelRoutine &routine) { uint16 prevReelPointer = routine.reelPointer() - 1; if (prevReelPointer == 0) { playChannel1(14); @@ -409,29 +437,25 @@ void DreamGenContext::alleyBarkSound(ReelRoutine &routine) { } } -void DreamGenContext::introMagic1(ReelRoutine &routine) { +void DreamWebEngine::introMagic1(ReelRoutine &routine) { if (checkSpeed(routine)) { uint16 nextReelPointer = routine.reelPointer() + 1; if (nextReelPointer == 145) nextReelPointer = 121; routine.setReelPointer(nextReelPointer); if (nextReelPointer == 121) { - ++data.byte(kIntrocount); - push(es); - push(bx); + ++_introCount; intro1Text(); - bx = pop(); - es = pop(); - if (data.byte(kIntrocount) == 8) { - data.byte(kMapy) += 10; - data.byte(kNowinnewroom) = 1; + if (_introCount == 8) { + _mapY += 10; + _nowInNewRoom = 1; } } } showGameReel(&routine); } -void DreamGenContext::introMagic2(ReelRoutine &routine) { +void DreamWebEngine::introMagic2(ReelRoutine &routine) { if (checkSpeed(routine)) { uint16 nextReelPointer = routine.reelPointer() + 1; if (nextReelPointer == 216) @@ -441,18 +465,18 @@ void DreamGenContext::introMagic2(ReelRoutine &routine) { showGameReel(&routine); } -void DreamGenContext::introMagic3(ReelRoutine &routine) { +void DreamWebEngine::introMagic3(ReelRoutine &routine) { if (checkSpeed(routine)) { uint16 nextReelPointer = routine.reelPointer() + 1; if (nextReelPointer == 218) - data.byte(kGetback) = 1; + _getBack = 1; routine.setReelPointer(nextReelPointer); } showGameReel(&routine); - routine.mapX = data.byte(kMapx); + routine.mapX = _mapX; } -void DreamGenContext::candles1(ReelRoutine &routine) { +void DreamWebEngine::candles1(ReelRoutine &routine) { if (checkSpeed(routine)) { uint16 nextReelPointer = routine.reelPointer() + 1; if (nextReelPointer == 44) @@ -462,7 +486,7 @@ void DreamGenContext::candles1(ReelRoutine &routine) { showGameReel(&routine); } -void DreamGenContext::candles2(ReelRoutine &routine) { +void DreamWebEngine::candles2(ReelRoutine &routine) { if (checkSpeed(routine)) { uint16 nextReelPointer = routine.reelPointer() + 1; if (nextReelPointer == 238) @@ -472,7 +496,7 @@ void DreamGenContext::candles2(ReelRoutine &routine) { showGameReel(&routine); } -void DreamGenContext::smallCandle(ReelRoutine &routine) { +void DreamWebEngine::smallCandle(ReelRoutine &routine) { if (checkSpeed(routine)) { uint16 nextReelPointer = routine.reelPointer() + 1; if (nextReelPointer == 37) @@ -482,10 +506,10 @@ void DreamGenContext::smallCandle(ReelRoutine &routine) { showGameReel(&routine); } -void DreamGenContext::introMusic(ReelRoutine &routine) { +void DreamWebEngine::introMusic(ReelRoutine &routine) { } -void DreamGenContext::candles(ReelRoutine &routine) { +void DreamWebEngine::candles(ReelRoutine &routine) { if (checkSpeed(routine)) { uint16 nextReelPointer = routine.reelPointer() + 1; if (nextReelPointer == 167) @@ -495,7 +519,7 @@ void DreamGenContext::candles(ReelRoutine &routine) { showGameReel(&routine); } -void DreamGenContext::gates(ReelRoutine &routine) { +void DreamWebEngine::gates(ReelRoutine &routine) { if (checkSpeed(routine)) { uint16 nextReelPointer = routine.reelPointer() + 1; if (nextReelPointer == 116) @@ -503,33 +527,28 @@ void DreamGenContext::gates(ReelRoutine &routine) { if (nextReelPointer >= 110) routine.period = 2; if (nextReelPointer == 120) { - data.byte(kGetback) = 1; + _getBack = 1; nextReelPointer = 119; } routine.setReelPointer(nextReelPointer); - push(es); - push(bx); - ax = nextReelPointer; - intro3Text(); - bx = pop(); - es = pop(); + intro3Text(nextReelPointer); } showGameReel(&routine); } -void DreamGenContext::security(ReelRoutine &routine) { +void DreamWebEngine::security(ReelRoutine &routine) { if (routine.reelPointer() == 32) { - if (data.byte(kLastweapon) == 1) { - data.word(kWatchingtime) = 10; - if ((data.byte(kManspath) == 9) && (data.byte(kFacing) == 0)) { - data.byte(kLastweapon) = (uint8)-1; + if (_vars._lastWeapon == 1) { + _vars._watchingTime = 10; + if ((_mansPath == 9) && (_facing == 0)) { + _vars._lastWeapon = (uint8)-1; routine.incReelPointer(); } } } else if (routine.reelPointer() == 69) return; else { - data.word(kWatchingtime) = 10; + _vars._watchingTime = 10; if (checkSpeed(routine)) routine.incReelPointer(); } @@ -537,43 +556,43 @@ void DreamGenContext::security(ReelRoutine &routine) { addToPeopleList(&routine); } -void DreamGenContext::edenInBath(ReelRoutine &routine) { - if (data.byte(kGeneraldead) == 0 || data.byte(kSartaindead) != 0) +void DreamWebEngine::edenInBath(ReelRoutine &routine) { + if (_vars._generalDead == 0 || _vars._sartainDead != 0) return; showGameReel(&routine); addToPeopleList(&routine); } -void DreamGenContext::louis(ReelRoutine &routine) { - if (data.byte(kRockstardead) != 0) +void DreamWebEngine::louis(ReelRoutine &routine) { + if (_vars._rockstarDead != 0) return; showGameReel(&routine); addToPeopleList(&routine); } -void DreamGenContext::handClap(ReelRoutine &routine) { +void DreamWebEngine::handClap(ReelRoutine &routine) { } -void DreamGenContext::carParkDrip(ReelRoutine &routine) { +void DreamWebEngine::carParkDrip(ReelRoutine &routine) { if (!checkSpeed(routine)) return; // cantdrip2 playChannel1(14); } -void DreamGenContext::foghornSound(ReelRoutine &routine) { - if (engine->randomNumber() == 198) +void DreamWebEngine::foghornSound(ReelRoutine &routine) { + if (randomNumber() == 198) playChannel1(13); } -void DreamGenContext::train(ReelRoutine &routine) { +void DreamWebEngine::train(ReelRoutine &routine) { // The original code has logic for this, but it is disabled } -void DreamGenContext::louisChair(ReelRoutine &routine) { - if (data.byte(kRockstardead) == 0) +void DreamWebEngine::louisChair(ReelRoutine &routine) { + if (_vars._rockstarDead == 0) return; // notlouis2 if (checkSpeed(routine)) { @@ -583,7 +602,7 @@ void DreamGenContext::louisChair(ReelRoutine &routine) { } else if (nextReelPointer != 185) { routine.setReelPointer(nextReelPointer); } else { - if (engine->randomNumber() < 245) + if (randomNumber() < 245) routine.setReelPointer(182); // Restart Louis else routine.setReelPointer(nextReelPointer); @@ -594,19 +613,19 @@ void DreamGenContext::louisChair(ReelRoutine &routine) { addToPeopleList(&routine); } -void DreamGenContext::bossMan(ReelRoutine &routine) { +void DreamWebEngine::bossMan(ReelRoutine &routine) { if (checkSpeed(routine)) { uint16 nextReelPointer = routine.reelPointer() + 1; if (nextReelPointer == 4) { - if (data.byte(kGunpassflag) != 1 && engine->randomNumber() >= 10) + if (_vars._gunPassFlag != 1 && randomNumber() >= 10) nextReelPointer = 0; } else if (nextReelPointer == 20) { - if (data.byte(kGunpassflag) != 1) + if (_vars._gunPassFlag != 1) nextReelPointer = 0; } else if (nextReelPointer == 41) { nextReelPointer = 0; - data.byte(kGunpassflag)++; + _vars._gunPassFlag++; routine.b7 = 10; } @@ -617,49 +636,40 @@ void DreamGenContext::bossMan(ReelRoutine &routine) { addToPeopleList(&routine); if (routine.b7 & 128) - data.byte(kTalkedtoboss) = 1; + _vars._talkedToBoss = 1; } -void DreamGenContext::priest(ReelRoutine &routine) { +void DreamWebEngine::priest(ReelRoutine &routine) { if (routine.reelPointer() == 8) return; // priestspoken - data.byte(kPointermode) = 0; - data.word(kWatchingtime) = 2; + _pointerMode = 0; + _vars._watchingTime = 2; if (checkSpeed(routine)) { routine.incReelPointer(); - push(es); - push(bx); priestText(routine); - bx = pop(); - es = pop(); } } -void DreamGenContext::priestText(ReelRoutine &routine) { +void DreamWebEngine::priestText(ReelRoutine &routine) { uint16 reel = routine.reelPointer(); if (reel < 2 || reel >= 7 || (reel & 1)) return; // nopriesttext - al = ((reel & 0xFF) >> 1) + 50; - bl = 72; - bh = 80; - cx = 54; - dx = 1; - setupTimedUse(); + setupTimedUse((reel >> 1) + 50, 54, 1, 72, 80); } -void DreamGenContext::monkAndRyan(ReelRoutine &routine) { +void DreamWebEngine::monkAndRyan(ReelRoutine &routine) { if (checkSpeed(routine)) { uint16 nextReelPointer = routine.reelPointer() + 1; if (nextReelPointer == 83) { - data.byte(kIntrocount)++; + _introCount++; textForMonk(); nextReelPointer = 77; - if (data.byte(kIntrocount) == 57) { - data.byte(kGetback) = 1; + if (_introCount == 57) { + _getBack = 1; return; } } @@ -670,14 +680,14 @@ void DreamGenContext::monkAndRyan(ReelRoutine &routine) { showGameReel(&routine); } -void DreamGenContext::copper(ReelRoutine &routine) { +void DreamWebEngine::copper(ReelRoutine &routine) { if (checkSpeed(routine)) { uint16 nextReelPointer = routine.reelPointer() + 1; if (nextReelPointer == 94) { nextReelPointer = 64; } else if (nextReelPointer == 81 || nextReelPointer == 66) { // Might wait - if (engine->randomNumber() >= 7) + if (randomNumber() >= 7) nextReelPointer--; } @@ -688,18 +698,18 @@ void DreamGenContext::copper(ReelRoutine &routine) { addToPeopleList(&routine); } -void DreamGenContext::introMonks1(ReelRoutine &routine) { +void DreamWebEngine::introMonks1(ReelRoutine &routine) { if (checkSpeed(routine)) { uint16 nextReelPointer = routine.reelPointer() + 1; if (nextReelPointer == 80) { - data.byte(kMapy) += 10; - data.byte(kNowinnewroom) = 1; + _mapY += 10; + _nowInNewRoom = 1; showGameReel(&routine); return; } else if (nextReelPointer == 30) { - data.byte(kMapy) -= 10; - data.byte(kNowinnewroom) = 1; + _mapY -= 10; + _nowInNewRoom = 1; nextReelPointer = 51; } @@ -709,50 +719,38 @@ void DreamGenContext::introMonks1(ReelRoutine &routine) { nextReelPointer == 25 || nextReelPointer == 61 || nextReelPointer == 71) { // Wait step - push(es); - push(bx); - intro2Text(); - bx = pop(); - es = pop(); + intro2Text(nextReelPointer); routine.counter = (uint8)-20; } } showGameReel(&routine); - routine.mapY = data.byte(kMapy); + routine.mapY = _mapY; } -void DreamGenContext::introMonks2(ReelRoutine &routine) { +void DreamWebEngine::introMonks2(ReelRoutine &routine) { if (checkSpeed(routine)) { uint16 nextReelPointer = routine.reelPointer() + 1; if (nextReelPointer == 87) { - data.byte(kIntrocount)++; - push(es); - push(bx); + _introCount++; monks2text(); - bx = pop(); - es = pop(); - if (data.byte(kIntrocount), 19) + if (_introCount == 19) nextReelPointer = 87; else nextReelPointer = 74; } if (nextReelPointer == 110) { - data.byte(kIntrocount)++; - push(es); - push(bx); + _introCount++; monks2text(); - bx = pop(); - es = pop(); - if (data.byte(kIntrocount) == 35) + if (_introCount == 35) nextReelPointer = 111; else nextReelPointer = 98; } else if (nextReelPointer == 176) { - data.byte(kGetback) = 1; + _getBack = 1; } else if (nextReelPointer == 125) { nextReelPointer = 140; } @@ -763,27 +761,361 @@ void DreamGenContext::introMonks2(ReelRoutine &routine) { showGameReel(&routine); } -void DreamGenContext::soldier1(ReelRoutine &routine) { +void DreamWebEngine::soldier1(ReelRoutine &routine) { if (routine.reelPointer() != 0) { - data.word(kWatchingtime) = 10; + _vars._watchingTime = 10; if (routine.reelPointer() == 30) { - data.byte(kCombatcount)++; - if (data.byte(kCombatcount) == 40) - data.byte(kMandead) = 2; + _vars._combatCount++; + if (_vars._combatCount == 40) + _vars._manDead = 2; } else if (checkSpeed(routine)) { // Not after shot routine.incReelPointer(); } - } else if (data.byte(kLastweapon) == 1) { - data.word(kWatchingtime) = 10; - if (data.byte(kManspath) == 2 && data.byte(kFacing) == 4) + } else if (_vars._lastWeapon == 1) { + _vars._watchingTime = 10; + if (_mansPath == 2 && _facing == 4) routine.incReelPointer(); - data.byte(kLastweapon) = 0xFF; - data.byte(kCombatcount) = 0; + _vars._lastWeapon = 0xFF; + _vars._combatCount = 0; + } + + showGameReel(&routine); + addToPeopleList(&routine); +} + +void DreamWebEngine::receptionist(ReelRoutine &routine) { + if (checkSpeed(routine)) { + if (_vars._cardPassFlag == 1) { + // Set card + _vars._cardPassFlag++; + routine.b7 = 1; + routine.setReelPointer(64); + } + + if (routine.reelPointer() != 58) { + // notdes1 + if (routine.reelPointer() != 60) { + // notdes2 + if (routine.reelPointer() != 88) + routine.incReelPointer(); // not end card + else + routine.setReelPointer(53); + } else if (randomNumber() >= 240) { + routine.setReelPointer(53); + } + } else if (randomNumber() >= 30) { + routine.setReelPointer(55); + } else { + // notdes2 + if (routine.reelPointer() != 88) + routine.incReelPointer(); // not end card + else + routine.setReelPointer(53); + } } showGameReel(&routine); addToPeopleList(&routine); + if (routine.b7 & 128) + _vars._talkedToRecep = 1; +} + +void DreamWebEngine::bartender(ReelRoutine &routine) { + if (checkSpeed(routine)) { + if (routine.reelPointer() == 86) { + if (randomNumber() >= 18) + routine.setReelPointer(81); + else + routine.incReelPointer(); // notsmoket2 + } else if (routine.reelPointer() == 103) { + routine.setReelPointer(81); // notsmoket1 + } else { + routine.incReelPointer(); // notsmoket2 + } + } + + showGameReel(&routine); + if (_vars._gunPassFlag == 1) + routine.b7 = 9; // got gun + + addToPeopleList(&routine); +} + +void DreamWebEngine::heavy(ReelRoutine &routine) { + routine.b7 &= 127; + if (routine.reelPointer() != 43) { + _vars._watchingTime = 10; + if (routine.reelPointer() == 70) { + // After shot + _vars._combatCount++; + if (_vars._combatCount == 80) + _vars._manDead = 2; + } else { + if (checkSpeed(routine)) + routine.incReelPointer(); + } + } else if (_vars._lastWeapon == 1 && _mansPath == 5 && _facing == 4) { + // Heavy wait + _vars._lastWeapon = (byte)-1; + routine.incReelPointer(); + _vars._combatCount = 0; + } + + showGameReel(&routine); + addToPeopleList(&routine); +} + +void DreamWebEngine::helicopter(ReelRoutine &routine) { + if (routine.reelPointer() == 203) { + // Won helicopter + _pointerMode = 0; + return; + } + + if (checkSpeed(routine)) { + uint16 nextReelPointer = routine.reelPointer() + 1; + if (nextReelPointer == 53) { + // Before killing helicopter + _vars._combatCount++; + if (_vars._combatCount >= 8) + _vars._manDead = 2; + nextReelPointer = 49; + } else if (nextReelPointer == 9) { + nextReelPointer--; + if (_vars._lastWeapon == 1) { + _vars._lastWeapon = (byte)-1; + nextReelPointer = 55; + } else { + nextReelPointer = 5; + _vars._combatCount++; + if (_vars._combatCount == 20) { + _vars._combatCount = 0; + nextReelPointer = 9; + } + } + } + + routine.setReelPointer(nextReelPointer); + } + + showGameReel(&routine); + routine.mapX = _mapX; + if (routine.reelPointer() < 9 && _vars._combatCount >= 7) { + _pointerMode = 2; + _vars._watchingTime = 0; + } else { + // Not waiting helicopter + _pointerMode = 0; + _vars._watchingTime = 2; + } +} + +void DreamWebEngine::mugger(ReelRoutine &routine) { + if (routine.reelPointer() != 138) { + if (routine.reelPointer() == 176) + return; // endmugger2 + + if (routine.reelPointer() == 2) + _vars._watchingTime = 175 * 2; // set watch + + if (checkSpeed(routine)) + routine.incReelPointer(); + + showGameReel(&routine); + routine.mapX = _mapX; + } else { + createPanel2(); + showIcon(); + + const uint8 *string = (const uint8 *)_puzzleText.getString(41); + uint16 y = 104; + printDirect(&string, 33 + 20, &y, 241, 241 & 1); + workToScreen(); + hangOn(300); + routine.setReelPointer(140); + _mansPath = 2; + _finalDest = 2; + findXYFromPath(); + _resetManXY = 1; + _command = findExObject("WETA"); + _objectType = kExObjectType; + removeObFromInv(); + _command = findExObject("WETB"); + _objectType = kExObjectType; + removeObFromInv(); + makeMainScreen(); + setupTimedUse(48, 70, 10, 68 - 32, 54 + 64); + _vars._beenMugged = 1; + } +} + +// Exiting the elevator of Sartain's industries, Sartain (the businessman) and +// two bodyguards are expecting Ryan. +void DreamWebEngine::businessMan(ReelRoutine &routine) { + _pointerMode = 0; + _vars._watchingTime = 2; + if (routine.reelPointer() == 2) + setupTimedUse(49, 30, 1, 68, 174); // First + + if (routine.reelPointer() == 95) { + // Businessman combat won - end + _pointerMode = 0; + _vars._watchingTime = 0; + return; + } + + if (routine.reelPointer() == 49) + return; // Businessman combat end + + if (checkSpeed(routine)) { + uint16 nextReelPointer = routine.reelPointer() + 1; + if (nextReelPointer == 48) { + _vars._manDead = 2; // before dead body + } else if (nextReelPointer == 15) { + nextReelPointer--; + if (_vars._lastWeapon == 3) { + // Shield on bus + _vars._lastWeapon = (byte)-1; + _vars._combatCount = 0; + nextReelPointer = 51; + } else { + // No shield on businessman + _vars._combatCount++; + if (_vars._combatCount == 20) { + _vars._combatCount = 0; + nextReelPointer = 15; + } + } + } else { + // Businessman combat won + if (nextReelPointer == 91) { + turnPathOn(0); + turnPathOn(1); + turnPathOn(2); + turnPathOff(3); + _mansPath = 5; + _finalDest = 5; + findXYFromPath(); + _resetManXY = 1; + nextReelPointer = 92; + } + } + + routine.setReelPointer(nextReelPointer); + } + + showGameReel(&routine); + routine.mapY = _mapY; + if (routine.reelPointer() == 14) { + _vars._watchingTime = 0; + _pointerMode = 2; + } +} + +void DreamWebEngine::endGameSeq(ReelRoutine &routine) { + if (checkSpeed(routine)) { + uint16 nextReelPointer = routine.reelPointer() + 1; + if (nextReelPointer == 51 && _introCount != 140) { + _introCount++; + textForEnd(); + nextReelPointer = 50; + } + + routine.setReelPointer(nextReelPointer); + if (nextReelPointer == 134) { + fadeScreenDownHalf(); + } else if (nextReelPointer == 324) { + fadeScreenDowns(); + _volumeTo = 7; + _volumeDirection = 1; + } + + if (nextReelPointer == 340) + _getBack = 1; + } + + showGameReel(&routine); + routine.mapY = _mapY; + + if (routine.reelPointer() == 145) { + routine.setReelPointer(146); + rollEndCreditsGameWon(); + } +} + +void DreamWebEngine::poolGuard(ReelRoutine &routine) { + if (routine.reelPointer() == 214 || routine.reelPointer() == 258) { + // Combat over 2 + showGameReel(&routine); + _vars._watchingTime = 2; + _pointerMode = 0; + _vars._combatCount++; + if (_vars._combatCount < 100) + return; // doneover2 + _vars._watchingTime = 0; + _vars._manDead = 2; + return; + } else if (routine.reelPointer() == 185) { + // Combat over 1 + _vars._watchingTime = 0; + _pointerMode = 0; + turnPathOn(0); + turnPathOff(1); + return; + } + + if (routine.reelPointer() == 0) + turnPathOn(0); // first pool + + if (checkSpeed(routine)) { + uint16 nextReelPointer = routine.reelPointer() + 1; + + if (nextReelPointer != 122) { + // Not end guard 1 + if (nextReelPointer == 147) { + nextReelPointer--; + if (_vars._lastWeapon == 1) { + // Gun on pool + _vars._lastWeapon = (byte)-1; + nextReelPointer = 147; + } else { + // Gun not on pool + _vars._combatCount++; + if (_vars._combatCount == 40) { + _vars._combatCount = 0; + nextReelPointer = 220; + } + } + } + } else { + nextReelPointer--; + + if (_vars._lastWeapon == 2) { + // Axe on pool + _vars._lastWeapon = (byte)-1; + nextReelPointer = 122; + } else { + _vars._combatCount++; + if (_vars._combatCount == 40) { + _vars._combatCount = 0; + nextReelPointer = 195; + } + } + } + + routine.setReelPointer(nextReelPointer); + } + + showGameReel(&routine); + + if (routine.reelPointer() != 121 && routine.reelPointer() != 146) { + _pointerMode = 0; + _vars._watchingTime = 2; + } else { + _pointerMode = 2; + _vars._watchingTime = 0; + } } -} // End of namespace DreamGen +} // End of namespace DreamWeb |