From 93bf275f4c9ef168ceab23a07a1219d2c78b65ec Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 15 Dec 2011 12:15:22 +0200 Subject: DREAMWEB: Port 'helicopter' to C++ --- engines/dreamweb/dreamgen.cpp | 65 ------------------------------------------- engines/dreamweb/dreamgen.h | 1 - engines/dreamweb/people.cpp | 52 ++++++++++++++++++++++++++++++++-- engines/dreamweb/stubs.h | 1 + 4 files changed, 51 insertions(+), 68 deletions(-) (limited to 'engines/dreamweb') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index dfeda18d6c..2ee3d512cd 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -26,71 +26,6 @@ namespace DreamGen { -void DreamGenContext::helicopter() { - STACK_CHECK; - ax = es.word(bx+3); - _cmp(ax, 203); - if (flags.z()) - goto heliwon; - checkSpeed(); - if (!flags.z()) - goto helispeed; - ax = es.word(bx+3); - _inc(ax); - _cmp(ax, 53); - if (!flags.z()) - goto notbeforehdead; - _inc(data.byte(kCombatcount)); - _cmp(data.byte(kCombatcount), 8); - if (flags.c()) - goto waitabit; - data.byte(kMandead) = 2; -waitabit: - ax = 49; - goto gotheliframe; -notbeforehdead: - _cmp(ax, 9); - if (!flags.z()) - goto gotheliframe; - _dec(ax); - _cmp(data.byte(kLastweapon), 1); - if (!flags.z()) - goto notgunonheli; - data.byte(kLastweapon) = -1; - ax = 55; - goto gotheliframe; -notgunonheli: - ax = 5; - _inc(data.byte(kCombatcount)); - _cmp(data.byte(kCombatcount), 20); - if (!flags.z()) - goto gotheliframe; - data.byte(kCombatcount) = 0; - ax = 9; -gotheliframe: - es.word(bx+3) = ax; -helispeed: - showGameReel(); - al = data.byte(kMapx); - es.byte(bx+1) = al; - ax = es.word(bx+3); - _cmp(ax, 9); - if (!flags.c()) - goto notwaitingheli; - _cmp(data.byte(kCombatcount), 7); - if (flags.c()) - goto notwaitingheli; - data.byte(kPointermode) = 2; - data.word(kWatchingtime) = 0; - return; -notwaitingheli: - data.byte(kPointermode) = 0; - data.word(kWatchingtime) = 2; - return; -heliwon: - data.byte(kPointermode) = 0; -} - void DreamGenContext::mugger() { STACK_CHECK; ax = es.word(bx+3); diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index e530a3b968..582caa712f 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -530,7 +530,6 @@ public: void findAllOpen(); void showSlots(); void deleteExObject(); - void helicopter(); void getEitherAd(); void setPickup(); void dropObject(); diff --git a/engines/dreamweb/people.cpp b/engines/dreamweb/people.cpp index 99a83f44d3..e060df9fcc 100644 --- a/engines/dreamweb/people.cpp +++ b/engines/dreamweb/people.cpp @@ -42,7 +42,7 @@ static void (DreamGenContext::*reelCallbacks[57])() = { NULL, &DreamGenContext::poolGuard, NULL, &DreamGenContext::businessMan, NULL, NULL, - &DreamGenContext::mugger, &DreamGenContext::helicopter, + &DreamGenContext::mugger, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -74,7 +74,7 @@ static void (DreamGenContext::*reelCallbacksCPP[57])(ReelRoutine &) = { &DreamGenContext::copper, /*&DreamGenContext::poolGuard*/NULL, &DreamGenContext::rockstar, /*&DreamGenContext::businessMan*/NULL, &DreamGenContext::train, &DreamGenContext::genericPerson /*aide*/, - /*&DreamGenContext::mugger*/NULL, /*&DreamGenContext::helicopter*/NULL, + /*&DreamGenContext::mugger*/NULL, &DreamGenContext::helicopter, &DreamGenContext::introMagic1, &DreamGenContext::introMusic, &DreamGenContext::introMagic2, &DreamGenContext::candles2, &DreamGenContext::gates, &DreamGenContext::introMagic3, @@ -859,4 +859,52 @@ void DreamGenContext::heavy(ReelRoutine &routine) { addToPeopleList(&routine); } +void DreamGenContext::helicopter(ReelRoutine &routine) { + if (routine.reelPointer() == 203) { + // Won helicopter + data.byte(kPointermode) = 0; + return; + } + + if (checkSpeed(routine)) { + uint16 nextReelPointer = routine.reelPointer() + 1; + if (nextReelPointer == 53) { + // Before killing helicopter + data.byte(kCombatcount)++; + if (data.byte(kCombatcount) != 8) + data.byte(kMandead) = 2; + nextReelPointer = 49; + } else if (nextReelPointer == 9) { + nextReelPointer--; + if (data.byte(kLastweapon) == 1) { + data.byte(kLastweapon) = (byte)-1; + nextReelPointer = 55; + } else { + nextReelPointer = 5; + data.byte(kCombatcount)++; + if (data.byte(kCombatcount) == 20) { + data.byte(kCombatcount) = 0; + nextReelPointer = 9; + } + } + } else { + // Not waiting helicopter + data.byte(kPointermode) = 0; + data.word(kWatchingtime) = 2; + } + + routine.setReelPointer(nextReelPointer); + } + + showGameReel(&routine); + routine.mapX = data.byte(kMapx); + if (routine.reelPointer() == 9 && data.byte(kCombatcount) != 7) { + data.byte(kPointermode) = 2; + data.word(kWatchingtime) = 0; + } else { + data.byte(kPointermode) = 0; + data.word(kWatchingtime) = 2; + } +} + } // End of namespace DreamGen diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 3413c5eef0..8218a1ac0f 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -418,6 +418,7 @@ void receptionist(ReelRoutine &routine); void bartender(ReelRoutine &routine); void heavy(ReelRoutine &routine); + void helicopter(ReelRoutine &routine); void singleKey(uint8 key, uint16 x, uint16 y); void loadSaveBox(); void loadKeypad(); -- cgit v1.2.3